public PreparedContext(uint statementId, SqlStringTemplate sqlStringTemplate, TableHeader tableHeader) { this.statementId = statementId; _sqlStringTemplate = sqlStringTemplate; _keys = _sqlStringTemplate.GetValueKeys(); //---------------------------------------------- _tableHeader = tableHeader; int serverFieldCount = tableHeader.ColumnCount; //add field information to _keys List <FieldPacket> fields = tableHeader.GetFields(); //---------------------------------------------- int bindingCount = 0; for (int i = 0; i < serverFieldCount; ++i) { FieldPacket f = fields[i]; if (f.name == "?") // { //this is binding field _keys[bindingCount].fieldInfo = f; bindingCount++; } } //some field from server is not binding field //so we select only binding field if (bindingCount != _keys.Count) { throw new Exception("key num not matched!"); } //------------------------------------------------- _preparedValues = new MyStructData[bindingCount]; //*** }
internal Query(Connection conn, SqlStringTemplate sql, CommandParams cmdParams) { //***a query uses conn resource such as parser,writer //so 1 query=> 1 connection if (sql == null) { throw new Exception("Sql command can not null."); } Query bindingQuery = conn.BindingQuery; if (bindingQuery != null) { //check if binding query can be close if (!bindingQuery.LateClose()) { //can't use this conn throw new Exception("connection is in used"); } } //-------------------------------------------------------------- conn.BindingQuery = this; //-------------------------------------------------------------- _conn = conn; _cmdParams = cmdParams; //-------------------------------------------------------------- _nestTables = false; _sqlParserMx = conn.MySqlParserMx; _writer = conn.PacketWriter; //_receiveBuffer = null; _sqlStrTemplate = sql; }
const int MAX_PACKET_LENGTH = (1 << 24) - 1;//(int)Math.Pow(2, 24) - 1; public Query(Connection conn, string sql, CommandParams cmdParams)//testing { if (sql == null) { throw new Exception("Sql command can not null."); } this._conn = conn; this._cmdParams = cmdParams; typeCast = conn.config.typeCast; nestTables = false; //index = 0; LoadError = null; //*** query use conn resource such as parser,writer //so 1 query 1 connection _parser = conn.PacketParser; _writer = conn.PacketWriter; _receiveBuffer = null; _sqlStrTemplate = new SqlStringTemplate(sql); }
public PreparedContext(uint statementId, SqlStringTemplate sqlStringTemplate) { this.statementId = statementId; _sqlStringTemplate = sqlStringTemplate; _keys = _sqlStringTemplate.GetValueKeys(); }