public ExecuteStatement ( |
||
packetToExecute | ||
Результат | void |
public override void Execute() { // if we are not prepared, then call down to our base if (!IsPrepared) { base.Execute(); return; } //TODO: support long data here // create our null bitmap // we check this because Mono doesn't ignore the case where nullMapBytes // is zero length. // if (nullMapBytes.Length > 0) // { // byte[] bits = packet.Buffer; // nullMap.CopyTo(bits, // nullMap.CopyTo(nullMapBytes, 0); // start constructing our packet // if (Parameters.Count > 0) // nullMap.CopyTo(packet.Buffer, nullMapPosition); //if (parameters != null && parameters.Count > 0) //else // packet.WriteByte( 0 ); //TODO: only send rebound if parms change // now write out all non-null values _packet.Position = _dataPosition; for (int i = 0; i < _parametersToSend.Count; i++) { MySqlParameter p = _parametersToSend[i]; _nullMap[i] = (p.Value == DBNull.Value || p.Value == null) || p.Direction == ParameterDirection.Output; if (_nullMap[i]) { continue; } _packet.Encoding = p.Encoding; p.Serialize(_packet, true, Connection.Settings); } if (_nullMap != null) { byte[] tempByteArray = new byte[(_nullMap.Length + 7) >> 3]; _nullMap.CopyTo(tempByteArray, 0); Array.Copy(tempByteArray, 0, _packet.Buffer, _nullMapPosition, tempByteArray.Length); } ExecutionCount++; Driver.ExecuteStatement(_packet); }
public override void Execute() { // if we are not prepared, then call down to our base if (!IsPrepared) { base.Execute(); return; } MySqlStream stream = new MySqlStream(Driver.Encoding); //TODO: support long data here // create our null bitmap BitArray nullMap = new BitArray(Parameters.Count); // now we run through the parameters that PREPARE sent back and use // those names to index into the parameters the user gave us. // if the user set that parameter to NULL, then we set the null map // accordingly if (paramList != null) { for (int x = 0; x < paramList.Length; x++) { MySqlParameter p = Parameters[paramList[x].ColumnName]; if (p.Value == DBNull.Value || p.Value == null) { nullMap[x] = true; } } } byte[] nullMapBytes = new byte[(Parameters.Count + 7) / 8]; // we check this because Mono doesn't ignore the case where nullMapBytes // is zero length. if (nullMapBytes.Length > 0) { nullMap.CopyTo(nullMapBytes, 0); } // start constructing our packet stream.WriteInteger(statementId, 4); stream.WriteByte(0); // flags; always 0 for 4.1 stream.WriteInteger(1, 4); // interation count; 1 for 4.1 stream.Write(nullMapBytes); //if (parameters != null && parameters.Count > 0) stream.WriteByte(1); // rebound flag //else // packet.WriteByte( 0 ); //TODO: only send rebound if parms change // write out the parameter types if (paramList != null) { foreach (MySqlField param in paramList) { MySqlParameter parm = Parameters[param.ColumnName]; stream.WriteInteger(parm.GetPSType(), 2); } // now write out all non-null values foreach (MySqlField param in paramList) { int index = Parameters.IndexOf(param.ColumnName); if (index == -1) { throw new MySqlException("Parameter '" + param.ColumnName + "' is not defined."); } MySqlParameter parm = Parameters[index]; if (parm.Value == DBNull.Value || parm.Value == null) { continue; } stream.Encoding = param.Encoding; parm.Serialize(stream, true); } } executionCount++; Driver.ExecuteStatement(stream.InternalBuffer.ToArray()); }
public CommandResult Execute(MySqlParameterCollection parameters) { PacketWriter packet = new PacketWriter(); packet.Driver = (NativeDriver)driver; //TODO: support long data here // create our null bitmap BitArray nullMap = new BitArray(parameters.Count); //metaData.Length ); for (int x = 0; x < parameters.Count; x++) { if (parameters[x].Value == DBNull.Value || parameters[x].Value == null) { nullMap[x] = true; } } byte[] nullMapBytes = new byte[(parameters.Count + 7) / 8]; nullMap.CopyTo(nullMapBytes, 0); // start constructing our packet packet.WriteInteger(StatementId, 4); packet.WriteByte(0); // flags; always 0 for 4.1 packet.WriteInteger(1, 4); // interation count; 1 for 4.1 packet.Write(nullMapBytes); //if (parameters != null && parameters.Count > 0) packet.WriteByte(1); // rebound flag //else // packet.WriteByte( 0 ); //TODO: only send rebound if parms change // write out the parameter types foreach (MySqlField param in paramList) { MySqlParameter parm = parameters[param.ColumnName]; packet.WriteInteger((long)parm.GetPSType(), 2); } // now write out all non-null values foreach (MySqlField param in paramList) { int index = parameters.IndexOf(param.ColumnName); if (index == -1) { throw new MySqlException("Parameter '" + param.ColumnName + "' is not defined."); } MySqlParameter parm = parameters[index]; if (parm.Value == DBNull.Value || parm.Value == null) { continue; } packet.Encoding = param.Encoding; parm.Serialize(packet, true); } executionCount++; // send the data packet and return the CommandResult return(driver.ExecuteStatement(((System.IO.MemoryStream)packet.Stream).ToArray())); }