Summary description for Field.
Exemple #1
0
 public abstract MySqlValue ReadFieldValue(int index, MySqlField field, MySqlValue value);
Exemple #2
0
 private void SetMySqlDbType(MySqlDbType mysql_dbtype)
 {
     this.mySqlDbType = mysql_dbtype;
     this.ValueObject = MySqlField.GetIMySqlValue(this.mySqlDbType);
     this.SetDbTypeFromMySqlDbType();
 }
    public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
    {
      long length = -1;
      bool isNull;

      if (nullMap != null)
        isNull = nullMap[index + 2];
      else
      {
        length = packet.ReadFieldLength();
        isNull = length == -1;
      }

      packet.Encoding = field.Encoding;
      packet.Version = version;
      return valObject.ReadValue(packet, length, isNull);
    }
    private void GetColumnData(MySqlField field)
    {
      stream.Encoding = Encoding;
      packet = stream.ReadPacket();
      field.Encoding = Encoding;
      field.CatalogName = packet.ReadLenString();
      field.DatabaseName = packet.ReadLenString();
      field.TableName = packet.ReadLenString();
      field.RealTableName = packet.ReadLenString();
      field.ColumnName = packet.ReadLenString();
      field.OriginalColumnName = packet.ReadLenString();
      packet.ReadByte();
      field.CharacterSetIndex = packet.ReadInteger(2);
      field.ColumnLength = packet.ReadInteger(4);
      MySqlDbType type = (MySqlDbType)packet.ReadByte();
      ColumnFlags colFlags;
      if ((connectionFlags & ClientFlags.LONG_FLAG) != 0)
        colFlags = (ColumnFlags)packet.ReadInteger(2);
      else
        colFlags = (ColumnFlags)packet.ReadByte();
      field.Scale = (byte)packet.ReadByte();

      if (packet.HasMoreData)
      {
        packet.ReadInteger(2); // reserved
      }

      if (type == MySqlDbType.Decimal || type == MySqlDbType.NewDecimal)
      {
        field.Precision = (byte)(field.ColumnLength - 2);
        if ((colFlags & ColumnFlags.UNSIGNED) != 0)
          field.Precision++;
      }

      field.SetTypeAndFlags(type, colFlags);
    }
Exemple #5
0
 public abstract IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value);
Exemple #6
0
 public virtual int PrepareStatement(string sql, ref MySqlField[] parameters)
 {
     return handler.PrepareStatement(sql, ref parameters);
 }
        public override MySqlField[] ReadColumnMetadata(int count)
        {
            MySqlField[] fields = new MySqlField[count];

            for (int i = 0; i < count; i++)
                fields[i] = GetFieldMetaData();

            ReadEOF();
            return fields;
        }
Exemple #8
0
        /// <summary>
        /// Returns a DataTable that describes the column metadata of the MySqlDataReader.
        /// </summary>
        /// <returns></returns>
        public override DataTable GetSchemaTable()
        {
            // Only Results from SQL SELECT Queries
            // get a DataTable for schema of the result
            // otherwise, DataTable is null reference
            if (FieldCount == 0)
            {
                return(null);
            }

            DataTable dataTableSchema = new DataTable("SchemaTable");

            dataTableSchema.Columns.Add("ColumnName", typeof(string));
            dataTableSchema.Columns.Add("ColumnOrdinal", typeof(int));
            dataTableSchema.Columns.Add("ColumnSize", typeof(int));
            dataTableSchema.Columns.Add("NumericPrecision", typeof(int));
            dataTableSchema.Columns.Add("NumericScale", typeof(int));
            dataTableSchema.Columns.Add("IsUnique", typeof(bool));
            dataTableSchema.Columns.Add("IsKey", typeof(bool));
            DataColumn dc = dataTableSchema.Columns["IsKey"];

            dc.AllowDBNull = true; // IsKey can have a DBNull
            dataTableSchema.Columns.Add("BaseCatalogName", typeof(string));
            dataTableSchema.Columns.Add("BaseColumnName", typeof(string));
            dataTableSchema.Columns.Add("BaseSchemaName", typeof(string));
            dataTableSchema.Columns.Add("BaseTableName", typeof(string));
            dataTableSchema.Columns.Add("DataType", typeof(Type));
            dataTableSchema.Columns.Add("AllowDBNull", typeof(bool));
            dataTableSchema.Columns.Add("ProviderType", typeof(int));
            dataTableSchema.Columns.Add("IsAliased", typeof(bool));
            dataTableSchema.Columns.Add("IsExpression", typeof(bool));
            dataTableSchema.Columns.Add("IsIdentity", typeof(bool));
            dataTableSchema.Columns.Add("IsAutoIncrement", typeof(bool));
            dataTableSchema.Columns.Add("IsRowVersion", typeof(bool));
            dataTableSchema.Columns.Add("IsHidden", typeof(bool));
            dataTableSchema.Columns.Add("IsLong", typeof(bool));
            dataTableSchema.Columns.Add("IsReadOnly", typeof(bool));

            int ord = 1;

            for (int i = 0; i < FieldCount; i++)
            {
                MySqlField f = ResultSet.Fields[i];
                DataRow    r = dataTableSchema.NewRow();
                r["ColumnName"]    = f.ColumnName;
                r["ColumnOrdinal"] = ord++;
                r["ColumnSize"]    = f.IsTextField ? f.ColumnLength / f.MaxLength : f.ColumnLength;
                int prec   = f.Precision;
                int pscale = f.Scale;
                if (prec != -1)
                {
                    r["NumericPrecision"] = (short)prec;
                }
                if (pscale != -1)
                {
                    r["NumericScale"] = (short)pscale;
                }
                r["DataType"]        = GetFieldType(i);
                r["ProviderType"]    = (int)f.Type;
                r["IsLong"]          = f.IsBlob && (f.ColumnLength > 255 || f.ColumnLength == -1);
                r["AllowDBNull"]     = f.AllowsNull;
                r["IsReadOnly"]      = false;
                r["IsRowVersion"]    = false;
                r["IsUnique"]        = false;
                r["IsKey"]           = f.IsPrimaryKey;
                r["IsAutoIncrement"] = f.IsAutoIncrement;
                r["BaseSchemaName"]  = f.DatabaseName;
                r["BaseCatalogName"] = null;
                r["BaseTableName"]   = f.RealTableName;
                r["BaseColumnName"]  = f.OriginalColumnName;

                dataTableSchema.Rows.Add(r);
            }

            return(dataTableSchema);
        }
        private void SetDbType(DbType db_type)
        {
            dbType = db_type;
            switch (dbType)
            {
            case DbType.Guid:
                mySqlDbType = MySqlDbType.Guid;
                break;

            case DbType.AnsiString:
            case DbType.String:
                mySqlDbType = MySqlDbType.VarChar;
                break;

            case DbType.AnsiStringFixedLength:
            case DbType.StringFixedLength:
                mySqlDbType = MySqlDbType.String;
                break;

            case DbType.Boolean:
            case DbType.Byte:
                mySqlDbType = MySqlDbType.UByte;
                break;

            case DbType.SByte:
                mySqlDbType = MySqlDbType.Byte;
                break;

            case DbType.Date:
                mySqlDbType = MySqlDbType.Date;
                break;

            case DbType.DateTime:
                mySqlDbType = MySqlDbType.DateTime;
                break;

            case DbType.Time:
                mySqlDbType = MySqlDbType.Time;
                break;

            case DbType.Single:
                mySqlDbType = MySqlDbType.Float;
                break;

            case DbType.Double:
                mySqlDbType = MySqlDbType.Double;
                break;

            case DbType.Int16:
                mySqlDbType = MySqlDbType.Int16;
                break;

            case DbType.UInt16:
                mySqlDbType = MySqlDbType.UInt16;
                break;

            case DbType.Int32:
                mySqlDbType = MySqlDbType.Int32;
                break;

            case DbType.UInt32:
                mySqlDbType = MySqlDbType.UInt32;
                break;

            case DbType.Int64:
                mySqlDbType = MySqlDbType.Int64;
                break;

            case DbType.UInt64:
                mySqlDbType = MySqlDbType.UInt64;
                break;

            case DbType.Decimal:
            case DbType.Currency:
                mySqlDbType = MySqlDbType.Decimal;
                break;

            case DbType.Object:
            case DbType.VarNumeric:
            case DbType.Binary:
            default:
                mySqlDbType = MySqlDbType.Blob;
                break;
            }

            if (dbType == DbType.Object)
            {
                var value = this.paramValue as byte[];
                if (value != null && value.Length == GEOMETRY_LENGTH)
                {
                    mySqlDbType = MySqlDbType.Geometry;
                }
            }

            ValueObject = MySqlField.GetIMySqlValue(mySqlDbType);
        }
        public override IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject)
        {
            long length = -1;
            bool isNull;

            if (nullMap != null)
                isNull = nullMap[index + 2];
            else
            {
                length = stream.ReadFieldLength();
                isNull = length == -1;
            }

            stream.Encoding = field.Encoding;
            return valObject.ReadValue(stream, length, isNull);
        }
Exemple #11
0
        private void SetDbType(DbType db_type)
        {
            dbType = db_type;
            switch (dbType)
            {
            case DbType.Guid:
                mySqlDbType = MySqlDbType.Guid;
                break;

            case DbType.AnsiString:
            case DbType.String:
                mySqlDbType = MySqlDbType.VarChar;
                break;

            case DbType.AnsiStringFixedLength:
            case DbType.StringFixedLength:
                mySqlDbType = MySqlDbType.String;
                break;

            case DbType.Boolean:
            case DbType.Byte:
                mySqlDbType = MySqlDbType.UByte;
                break;

            case DbType.SByte:
                mySqlDbType = MySqlDbType.Byte;
                break;

            case DbType.Date:
                mySqlDbType = MySqlDbType.Date;
                break;

            case DbType.DateTime:
                mySqlDbType = MySqlDbType.DateTime;
                break;

            case DbType.Time:
                mySqlDbType = MySqlDbType.Time;
                break;

            case DbType.Single:
                mySqlDbType = MySqlDbType.Float;
                break;

            case DbType.Double:
                mySqlDbType = MySqlDbType.Double;
                break;

            case DbType.Int16:
                mySqlDbType = MySqlDbType.Int16;
                break;

            case DbType.UInt16:
                mySqlDbType = MySqlDbType.UInt16;
                break;

            case DbType.Int32:
                mySqlDbType = MySqlDbType.Int32;
                break;

            case DbType.UInt32:
                mySqlDbType = MySqlDbType.UInt32;
                break;

            case DbType.Int64:
                mySqlDbType = MySqlDbType.Int64;
                break;

            case DbType.UInt64:
                mySqlDbType = MySqlDbType.UInt64;
                break;

            case DbType.Decimal:
            case DbType.Currency:
                mySqlDbType = MySqlDbType.Decimal;
                break;

            case DbType.Object:
            case DbType.VarNumeric:
            case DbType.Binary:
            default:
                mySqlDbType = MySqlDbType.Blob;
                break;
            }
            valueObject = MySqlField.GetIMySqlValue(mySqlDbType);
        }
Exemple #12
0
        private void SetMySqlDbType(MySqlDbType mysql_dbtype)
        {
            mySqlDbType = mysql_dbtype;
            valueObject = MySqlField.GetIMySqlValue(mySqlDbType);

            switch (mySqlDbType)
            {
            case MySqlDbType.Decimal:
                dbType = DbType.Decimal;
                break;

            case MySqlDbType.Byte:
                dbType = DbType.SByte;
                break;

            case MySqlDbType.UByte:
                dbType = DbType.Byte;
                break;

            case MySqlDbType.Int16:
                dbType = DbType.Int16;
                break;

            case MySqlDbType.UInt16:
                dbType = DbType.UInt16;
                break;

            case MySqlDbType.Int24:
            case MySqlDbType.Int32:
                dbType = DbType.Int32;
                break;

            case MySqlDbType.UInt24:
            case MySqlDbType.UInt32:
                dbType = DbType.UInt32;
                break;

            case MySqlDbType.Int64:
                dbType = DbType.Int64;
                break;

            case MySqlDbType.UInt64:
                dbType = DbType.UInt64;
                break;

            case MySqlDbType.Bit:
                dbType = DbType.UInt64;
                break;

            case MySqlDbType.Float:
                dbType = DbType.Single;
                break;

            case MySqlDbType.Double:
                dbType = DbType.Double;
                break;

            case MySqlDbType.Timestamp:
            case MySqlDbType.DateTime:
                dbType = DbType.DateTime;
                break;

            case MySqlDbType.Date:
            case MySqlDbType.Newdate:
            case MySqlDbType.Year:
                dbType = DbType.Date;
                break;

            case MySqlDbType.Time:
                dbType = DbType.Time;
                break;

            case MySqlDbType.Enum:
            case MySqlDbType.Set:
            case MySqlDbType.VarChar:
                dbType = DbType.String;
                break;

            case MySqlDbType.TinyBlob:
            case MySqlDbType.MediumBlob:
            case MySqlDbType.LongBlob:
            case MySqlDbType.Blob:
                dbType = DbType.Object;
                break;

            case MySqlDbType.String:
                dbType = DbType.StringFixedLength;
                break;

            case MySqlDbType.Guid:
                dbType = DbType.Guid;
                break;
            }
        }
Exemple #13
0
 public abstract IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value);
Exemple #14
0
 public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value)
 {
     return(handler.ReadColumnValue(index, field, value));
 }
        private MySqlField GetFieldMetaData()
        {
            MySqlField field;

            if (version.isAtLeast(4, 1, 0))
                field = GetFieldMetaData41();
            else
            {
                stream.OpenPacket();
                field = new MySqlField(connection);

                field.Encoding = encoding;
                field.TableName = stream.ReadLenString();
                field.ColumnName = stream.ReadLenString();
                field.ColumnLength = stream.ReadNBytes();
                MySqlDbType type = (MySqlDbType) stream.ReadNBytes();
                stream.ReadByte();
                ColumnFlags colFlags;
                if ((Flags & ClientFlags.LONG_FLAG) != 0)
                    colFlags = (ColumnFlags) stream.ReadInteger(2);
                else
                    colFlags = (ColumnFlags) stream.ReadByte();
                field.SetTypeAndFlags(type, colFlags);

                field.Scale = (byte) stream.ReadByte();
                if (!version.isAtLeast(3, 23, 15) && version.isAtLeast(3, 23, 0))
                    field.Scale++;
            }

            return field;
        }
Exemple #16
0
 private void SetMySqlDbType(MySqlDbType mysql_dbtype)
 {
     mySqlDbType = mysql_dbtype;
     ValueObject = MySqlField.GetIMySqlValue(mySqlDbType);
     SetDbTypeFromMySqlDbType();
 }
        private MySqlField GetFieldMetaData41()
        {
            MySqlField field = new MySqlField(connection);

            stream.OpenPacket();
            field.Encoding = encoding;
            field.CatalogName = stream.ReadLenString();
            field.DatabaseName = stream.ReadLenString();
            field.TableName = stream.ReadLenString();
            field.RealTableName = stream.ReadLenString();
            field.ColumnName = stream.ReadLenString();
            field.OriginalColumnName = stream.ReadLenString();
            stream.ReadByte();
            field.CharacterSetIndex = stream.ReadInteger(2);
            field.ColumnLength = stream.ReadInteger(4);
            MySqlDbType type = (MySqlDbType) stream.ReadByte();
            ColumnFlags colFlags;
            if ((Flags & ClientFlags.LONG_FLAG) != 0)
                colFlags = (ColumnFlags) stream.ReadInteger(2);
            else
                colFlags = (ColumnFlags) stream.ReadByte();

            field.SetTypeAndFlags(type, colFlags);

            field.Scale = (byte) stream.ReadByte();


            if (stream.HasMoreData)
            {
                stream.ReadInteger(2); // reserved
            }

            if (charSets != null && field.CharacterSetIndex != -1)
            {
                CharacterSet cs = CharSetMap.GetChararcterSet(Version, (string) charSets[field.CharacterSetIndex]);
                field.MaxLength = cs.byteCount;
                field.Encoding = CharSetMap.GetEncoding(version, (string) charSets[field.CharacterSetIndex]);
            }

            return field;
        }
Exemple #18
0
 public abstract int PrepareStatement(string sql, ref MySqlField[] parameters);
        public override int PrepareStatement(string sql, ref MySqlField[] parameters)
        {
            //TODO: check this
            //ClearFetchedRow();

            byte[] bytes = encoding.GetBytes(sql);
            ExecuteCommand(DBCmd.PREPARE, bytes, bytes.Length);

            stream.OpenPacket();

            int marker = stream.ReadByte();
            if (marker != 0)
                throw new MySqlException("Expected prepared statement marker");

            int statementId = stream.ReadInteger(4);
            int numCols = stream.ReadInteger(2);
            int numParams = stream.ReadInteger(2);
            //TODO: find out what this is needed for
            stream.ReadInteger(3);
            if (numParams > 0)
            {
                parameters = ReadColumnMetadata(numParams);

                // we set the encoding for each parameter back to our connection encoding
                // since we can't trust what is coming back from the server
                for (int i = 0; i < parameters.Length; i++)
                    parameters[i].Encoding = encoding;
            }

            if (numCols > 0)
            {
                while (numCols-- > 0)
                {
                    stream.OpenPacket();
                    stream.SkipPacket();
                }

                ReadEOF();
            }

            return statementId;
        }
Exemple #20
0
        public MySqlField[] GetColumns(int count)
        {
            MySqlField[] fields = new MySqlField[count];
            for (int i = 0; i < count; i++)
                fields[i] = new MySqlField(this);
            handler.GetColumnsData(fields);

            return fields;
        }
Exemple #21
0
 private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs)
 {
     if (!base.Settings.UseUsageAdvisor)
     {
         return;
     }
     if (base.HasStatus(ServerStatusFlags.NoIndex))
     {
         MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, Resources.TraceUAWarningNoIndex, new object[]
         {
             this.driverId,
             UsageAdvisorWarningFlags.NoIndex
         });
     }
     else
     {
         if (base.HasStatus(ServerStatusFlags.BadIndex))
         {
             MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, Resources.TraceUAWarningBadIndex, new object[]
             {
                 this.driverId,
                 UsageAdvisorWarningFlags.BadIndex
             });
         }
     }
     if (rs.SkippedRows > 0)
     {
         MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, Resources.TraceUAWarningSkippedRows, new object[]
         {
             this.driverId,
             UsageAdvisorWarningFlags.SkippedRows,
             rs.SkippedRows
         });
     }
     if (!this.AllFieldsAccessed(rs))
     {
         StringBuilder stringBuilder = new StringBuilder("");
         string        arg           = "";
         for (int i = 0; i < rs.Size; i++)
         {
             if (!rs.FieldRead(i))
             {
                 stringBuilder.AppendFormat("{0}{1}", arg, rs.Fields[i].ColumnName);
                 arg = ",";
             }
         }
         MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, Resources.TraceUAWarningSkippedColumns, new object[]
         {
             this.driverId,
             UsageAdvisorWarningFlags.SkippedColumns,
             stringBuilder.ToString()
         });
     }
     if (rs.Fields != null)
     {
         MySqlField[] fields = rs.Fields;
         for (int j = 0; j < fields.Length; j++)
         {
             MySqlField    mySqlField     = fields[j];
             StringBuilder stringBuilder2 = new StringBuilder();
             string        arg2           = "";
             foreach (Type current in mySqlField.TypeConversions)
             {
                 stringBuilder2.AppendFormat("{0}{1}", arg2, current.Name);
                 arg2 = ",";
             }
             if (stringBuilder2.Length > 0)
             {
                 MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning, Resources.TraceUAWarningFieldConversion, new object[]
                 {
                     this.driverId,
                     UsageAdvisorWarningFlags.FieldConversion,
                     mySqlField.ColumnName,
                     stringBuilder2.ToString()
                 });
             }
         }
     }
 }
Exemple #22
0
 public IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value)
 {
     return handler.ReadColumnValue(index, field, value);
 }
 public override int PrepareStatement(string sql, ref MySqlField[] parameters)
 {
   int statementId = base.PrepareStatement(sql, ref parameters);
   MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared,
       Resources.TraceStatementPrepared, driverId, sql, statementId);
   return statementId;
 }
 public void GetColumnsData(MySqlField[] columns)
 {
   for (int i = 0; i < columns.Length; i++)
     GetColumnData(columns[i]);
   ReadEOF();
 }
Exemple #25
0
        private void SetDbType(DbType db_type)
        {
            this.dbType = db_type;
            switch (this.dbType)
            {
            case DbType.AnsiString:
            case DbType.String:
                this.mySqlDbType = MySqlDbType.VarChar;
                goto IL_14B;

            case DbType.Byte:
            case DbType.Boolean:
                this.mySqlDbType = MySqlDbType.UByte;
                goto IL_14B;

            case DbType.Currency:
            case DbType.Decimal:
                this.mySqlDbType = MySqlDbType.Decimal;
                goto IL_14B;

            case DbType.Date:
                this.mySqlDbType = MySqlDbType.Date;
                goto IL_14B;

            case DbType.DateTime:
                this.mySqlDbType = MySqlDbType.DateTime;
                goto IL_14B;

            case DbType.Double:
                this.mySqlDbType = MySqlDbType.Double;
                goto IL_14B;

            case DbType.Guid:
                this.mySqlDbType = MySqlDbType.Guid;
                goto IL_14B;

            case DbType.Int16:
                this.mySqlDbType = MySqlDbType.Int16;
                goto IL_14B;

            case DbType.Int32:
                this.mySqlDbType = MySqlDbType.Int32;
                goto IL_14B;

            case DbType.Int64:
                this.mySqlDbType = MySqlDbType.Int64;
                goto IL_14B;

            case DbType.SByte:
                this.mySqlDbType = MySqlDbType.Byte;
                goto IL_14B;

            case DbType.Single:
                this.mySqlDbType = MySqlDbType.Float;
                goto IL_14B;

            case DbType.Time:
                this.mySqlDbType = MySqlDbType.Time;
                goto IL_14B;

            case DbType.UInt16:
                this.mySqlDbType = MySqlDbType.UInt16;
                goto IL_14B;

            case DbType.UInt32:
                this.mySqlDbType = MySqlDbType.UInt32;
                goto IL_14B;

            case DbType.UInt64:
                this.mySqlDbType = MySqlDbType.UInt64;
                goto IL_14B;

            case DbType.AnsiStringFixedLength:
            case DbType.StringFixedLength:
                this.mySqlDbType = MySqlDbType.String;
                goto IL_14B;
            }
            this.mySqlDbType = MySqlDbType.Blob;
IL_14B:
            if (this.dbType == DbType.Object)
            {
                byte[] array = this.paramValue as byte[];
                if (array != null && array.Length == 25)
                {
                    this.mySqlDbType = MySqlDbType.Geometry;
                }
            }
            this.ValueObject = MySqlField.GetIMySqlValue(this.mySqlDbType);
        }
    public int PrepareStatement(string sql, ref MySqlField[] parameters)
    {
      //TODO: check this
      //ClearFetchedRow();

      packet.Length = sql.Length * 4 + 5;
      byte[] buffer = packet.Buffer;
      int len = Encoding.GetBytes(sql, 0, sql.Length, packet.Buffer, 5);
      packet.Position = len + 5;
      buffer[4] = (byte)DBCmd.PREPARE;
      ExecutePacket(packet);

      packet = stream.ReadPacket();

      int marker = packet.ReadByte();
      if (marker != 0)
        throw new MySqlException("Expected prepared statement marker");

      int statementId = packet.ReadInteger(4);
      int numCols = packet.ReadInteger(2);
      int numParams = packet.ReadInteger(2);
      //TODO: find out what this is needed for
      packet.ReadInteger(3);
      if (numParams > 0)
      {
        parameters = owner.GetColumns(numParams);
        // we set the encoding for each parameter back to our connection encoding
        // since we can't trust what is coming back from the server
        for (int i = 0; i < parameters.Length; i++)
          parameters[i].Encoding = Encoding;
      }

      if (numCols > 0)
      {
        while (numCols-- > 0)
        {
          packet = stream.ReadPacket();
          //TODO: handle streaming packets
        }

        ReadEOF();
      }

      return statementId;
    }
        public override DataTable GetSchemaTable()
        {
            if (this.FieldCount == 0)
            {
                return(null);
            }
            DataTable dataTable = new DataTable("SchemaTable");

            dataTable.Columns.Add("ColumnName", typeof(string));
            dataTable.Columns.Add("ColumnOrdinal", typeof(int));
            dataTable.Columns.Add("ColumnSize", typeof(int));
            dataTable.Columns.Add("NumericPrecision", typeof(int));
            dataTable.Columns.Add("NumericScale", typeof(int));
            dataTable.Columns.Add("IsUnique", typeof(bool));
            dataTable.Columns.Add("IsKey", typeof(bool));
            dataTable.Columns["IsKey"].AllowDBNull = true;
            dataTable.Columns.Add("BaseCatalogName", typeof(string));
            dataTable.Columns.Add("BaseColumnName", typeof(string));
            dataTable.Columns.Add("BaseSchemaName", typeof(string));
            dataTable.Columns.Add("BaseTableName", typeof(string));
            dataTable.Columns.Add("DataType", typeof(Type));
            dataTable.Columns.Add("AllowDBNull", typeof(bool));
            dataTable.Columns.Add("ProviderType", typeof(int));
            dataTable.Columns.Add("IsAliased", typeof(bool));
            dataTable.Columns.Add("IsExpression", typeof(bool));
            dataTable.Columns.Add("IsIdentity", typeof(bool));
            dataTable.Columns.Add("IsAutoIncrement", typeof(bool));
            dataTable.Columns.Add("IsRowVersion", typeof(bool));
            dataTable.Columns.Add("IsHidden", typeof(bool));
            dataTable.Columns.Add("IsLong", typeof(bool));
            dataTable.Columns.Add("IsReadOnly", typeof(bool));
            int num = 1;

            for (int i = 0; i < this.FieldCount; i++)
            {
                MySqlField mySqlField = this.resultSet.Fields[i];
                DataRow    dataRow    = dataTable.NewRow();
                dataRow["ColumnName"]    = mySqlField.ColumnName;
                dataRow["ColumnOrdinal"] = num++;
                dataRow["ColumnSize"]    = (mySqlField.IsTextField ? (mySqlField.ColumnLength / mySqlField.MaxLength) : mySqlField.ColumnLength);
                int precision = (int)mySqlField.Precision;
                int scale     = (int)mySqlField.Scale;
                if (precision != -1)
                {
                    dataRow["NumericPrecision"] = (short)precision;
                }
                if (scale != -1)
                {
                    dataRow["NumericScale"] = (short)scale;
                }
                dataRow["DataType"]        = this.GetFieldType(i);
                dataRow["ProviderType"]    = (int)mySqlField.Type;
                dataRow["IsLong"]          = (mySqlField.IsBlob && mySqlField.ColumnLength > 255);
                dataRow["AllowDBNull"]     = mySqlField.AllowsNull;
                dataRow["IsReadOnly"]      = false;
                dataRow["IsRowVersion"]    = false;
                dataRow["IsUnique"]        = false;
                dataRow["IsKey"]           = mySqlField.IsPrimaryKey;
                dataRow["IsAutoIncrement"] = mySqlField.IsAutoIncrement;
                dataRow["BaseSchemaName"]  = mySqlField.DatabaseName;
                dataRow["BaseCatalogName"] = null;
                dataRow["BaseTableName"]   = mySqlField.RealTableName;
                dataRow["BaseColumnName"]  = mySqlField.OriginalColumnName;
                dataTable.Rows.Add(dataRow);
            }
            return(dataTable);
        }