SetTypeAndFlags() public method

public SetTypeAndFlags ( MySqlDbType type, ColumnFlags flags ) : void
type MySqlDbType
flags ColumnFlags
return void
Esempio n. 1
0
        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.GetCharacterSet(Version, (string)charSets[field.CharacterSetIndex]);
                // starting with 6.0.4 utf8 has a maxlen of 4 instead of 3.  The old
                // 3 byte utf8 is utf8mb3
                if (cs.name.ToLower(System.Globalization.CultureInfo.InvariantCulture) == "utf-8" &&
                    Version.Major >= 6)
                {
                    field.MaxLength = 4;
                }
                else
                {
                    field.MaxLength = cs.byteCount;
                }
                field.Encoding = CharSetMap.GetEncoding(version, (string)charSets[field.CharacterSetIndex]);
            }

            return(field);
        }
Esempio n. 2
0
        private MySqlField GetFieldMetaData41()
        {
            MySqlField field = new MySqlField(this.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();
            byte b = (byte)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)
            {
                int reserved = stream.ReadInteger(2);   // reserved
            }

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

            return(field);
        }
Esempio n. 3
0
        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);
        }
        private void GetColumnData(MySqlField field)
        {
            this.stream.Encoding     = this.Encoding;
            this.packet              = this.stream.ReadPacket();
            field.Encoding           = this.Encoding;
            field.CatalogName        = this.packet.ReadLenString();
            field.DatabaseName       = this.packet.ReadLenString();
            field.TableName          = this.packet.ReadLenString();
            field.RealTableName      = this.packet.ReadLenString();
            field.ColumnName         = this.packet.ReadLenString();
            field.OriginalColumnName = this.packet.ReadLenString();
            this.packet.ReadByte();
            field.CharacterSetIndex = this.packet.ReadInteger(2);
            field.ColumnLength      = this.packet.ReadInteger(4);
            MySqlDbType mySqlDbType = (MySqlDbType)this.packet.ReadByte();
            ColumnFlags columnFlags;

            if ((this.connectionFlags & ClientFlags.LONG_FLAG) != (ClientFlags)0uL)
            {
                columnFlags = (ColumnFlags)this.packet.ReadInteger(2);
            }
            else
            {
                columnFlags = (ColumnFlags)this.packet.ReadByte();
            }
            field.Scale = this.packet.ReadByte();
            if (this.packet.HasMoreData)
            {
                this.packet.ReadInteger(2);
            }
            if (mySqlDbType == MySqlDbType.Decimal || mySqlDbType == MySqlDbType.NewDecimal)
            {
                field.Precision = (byte)(field.ColumnLength - 2);
                if ((columnFlags & ColumnFlags.UNSIGNED) != (ColumnFlags)0)
                {
                    byte precision = field.Precision;
                    field.Precision = (byte)(precision + 1);
                }
            }
            field.SetTypeAndFlags(mySqlDbType, columnFlags);
        }
Esempio n. 5
0
        private MySqlField GetFieldMetaData()
        {
            MySqlField field;

            stream.Encoding = encoding;
            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);
        }
Esempio n. 6
0
        private MySqlField GetFieldMetaData()
        {
            MySqlField mySqlField;

            if (this.version.isAtLeast(4, 1, 0))
            {
                mySqlField = this.GetFieldMetaData41();
            }
            else
            {
                this.reader.OpenPacket();
                mySqlField              = new MySqlField(base.Version);
                mySqlField.Encoding     = this.encoding;
                mySqlField.TableName    = (mySqlField.RealTableName = this.reader.ReadLenString());
                mySqlField.ColumnName   = this.reader.ReadLenString();
                mySqlField.ColumnLength = this.reader.ReadNBytes();
                MySqlDbType type = (MySqlDbType)this.reader.ReadNBytes();
                this.reader.ReadByte();
                ColumnFlags flags;
                if ((this.Flags & ClientFlags.LONG_FLAG) != (ClientFlags)0)
                {
                    flags = (ColumnFlags)this.reader.ReadInteger(2);
                }
                else
                {
                    flags = (ColumnFlags)this.reader.ReadByte();
                }
                mySqlField.SetTypeAndFlags(type, flags);
                mySqlField.Scale = (byte)this.reader.ReadByte();
                if (!this.version.isAtLeast(3, 23, 15) && this.version.isAtLeast(3, 23, 0))
                {
                    MySqlField expr_F8 = mySqlField;
                    expr_F8.Scale += 1;
                }
            }
            return(mySqlField);
        }
Esempio n. 7
0
        private MySqlField GetFieldMetaData41()
        {
            MySqlField mySqlField = new MySqlField(base.Version);

            this.reader.OpenPacket();
            mySqlField.Encoding           = this.encoding;
            mySqlField.CatalogName        = this.reader.ReadLenString();
            mySqlField.DatabaseName       = this.reader.ReadLenString();
            mySqlField.TableName          = this.reader.ReadLenString();
            mySqlField.RealTableName      = this.reader.ReadLenString();
            mySqlField.ColumnName         = this.reader.ReadLenString();
            mySqlField.OriginalColumnName = this.reader.ReadLenString();
            this.reader.ReadByte();
            mySqlField.CharacterSetIndex = this.reader.ReadInteger(2);
            mySqlField.ColumnLength      = this.reader.ReadInteger(4);
            MySqlDbType type = (MySqlDbType)this.reader.ReadByte();
            ColumnFlags flags;

            if ((this.Flags & ClientFlags.LONG_FLAG) != (ClientFlags)0)
            {
                flags = (ColumnFlags)this.reader.ReadInteger(2);
            }
            else
            {
                flags = (ColumnFlags)this.reader.ReadByte();
            }
            mySqlField.SetTypeAndFlags(type, flags);
            mySqlField.Scale = (byte)this.reader.ReadByte();
            if (this.charSets != null)
            {
                CharacterSet chararcterSet = CharSetMap.GetChararcterSet(base.Version, (string)this.charSets[mySqlField.CharacterSetIndex]);
                mySqlField.MaxLength = chararcterSet.byteCount;
                mySqlField.Encoding  = CharSetMap.GetEncoding(this.version, (string)this.charSets[mySqlField.CharacterSetIndex]);
            }
            return(mySqlField);
        }
    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);
    }
Esempio n. 9
0
        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;
        }
Esempio n. 10
0
        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;
        }