public void AbortingSequentialAccess(MySqlField[] fields, int startIndex) { if (this.conn.Settings.UseUsageAdvisor) { this.LogUAHeader(null); Logger.WriteLine(""); Logger.WriteLine("A rowset that was being accessed using SequentialAccess had to load all of its remaining columns. This can cause performance problems. This is most likely due to calling Prepare() on a command before reading all the columns of a rowset that is being accessed with SequentialAccess"); LogUAFooter(); } }
public void ReadPartialRowSet(string cmdText, bool[] uaFieldsUsed, MySqlField[] fields) { if (this.conn.Settings.UseUsageAdvisor) { this.LogUAHeader(cmdText); Logger.WriteLine("Reason: Every column was not accessed. Consider a more focused query."); Logger.Write("Fields not accessed: "); for (int i = 0; i < uaFieldsUsed.Length; i++) { if (!uaFieldsUsed[i]) { Logger.Write(" " + fields[i].ColumnName); } } Logger.WriteLine(" "); LogUAFooter(); } }
public override IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue valObject) { bool flag; long length = -1L; if (this.nullMap != null) { flag = this.nullMap[index + 2]; } else { length = this.stream.ReadFieldLength(); flag = length == -1L; } this.stream.Encoding = field.Encoding; return valObject.ReadValue(this.stream, length, flag); }
public override MySqlField[] ReadColumnMetadata(int count) { MySqlField[] fieldArray = new MySqlField[count]; for (int i = 0; i < count; i++) { fieldArray[i] = this.GetFieldMetaData(); } this.ReadEOF(); return fieldArray; }
public override int PrepareStatement(string sql, ref MySqlField[] parameters) { byte[] bytes = base.encoding.GetBytes(sql); this.ExecuteCommand(DBCmd.PREPARE, bytes, bytes.Length); this.stream.OpenPacket(); if (this.stream.ReadByte() != 0) { throw new MySqlException("Expected prepared statement marker"); } int num2 = this.stream.ReadInteger(4); int num3 = this.stream.ReadInteger(2); int count = this.stream.ReadInteger(2); this.stream.ReadInteger(3); if (count > 0) { parameters = this.ReadColumnMetadata(count); for (int i = 0; i < parameters.Length; i++) { parameters[i].Encoding = base.encoding; } } if (num3 > 0) { while (num3-- > 0) { this.stream.OpenPacket(); this.stream.SkipPacket(); } this.ReadEOF(); } return num2; }
private MySqlField GetFieldMetaData41() { ColumnFlags flags; MySqlField field = new MySqlField(base.connection); this.stream.OpenPacket(); field.Encoding = base.encoding; field.CatalogName = this.stream.ReadLenString(); field.DatabaseName = this.stream.ReadLenString(); field.TableName = this.stream.ReadLenString(); field.RealTableName = this.stream.ReadLenString(); field.ColumnName = this.stream.ReadLenString(); field.OriginalColumnName = this.stream.ReadLenString(); this.stream.ReadByte(); field.CharacterSetIndex = this.stream.ReadInteger(2); field.ColumnLength = this.stream.ReadInteger(4); MySqlDbType type = (MySqlDbType) this.stream.ReadByte(); if ((this.Flags & ClientFlags.LONG_FLAG) != 0) { flags = (ColumnFlags) this.stream.ReadInteger(2); } else { flags = (ColumnFlags) this.stream.ReadByte(); } field.SetTypeAndFlags(type, flags); field.Scale = (byte) this.stream.ReadByte(); if (this.stream.HasMoreData) { this.stream.ReadInteger(2); } if ((base.charSets != null) && (field.CharacterSetIndex != -1)) { CharacterSet chararcterSet = CharSetMap.GetChararcterSet(base.Version, (string) base.charSets[field.CharacterSetIndex]); field.MaxLength = chararcterSet.byteCount; field.Encoding = CharSetMap.GetEncoding(base.version, (string) base.charSets[field.CharacterSetIndex]); } return field; }
private MySqlField GetFieldMetaData() { ColumnFlags flags; this.stream.Encoding = base.encoding; if (this.version.isAtLeast(4, 1, 0)) { return this.GetFieldMetaData41(); } this.stream.OpenPacket(); MySqlField field = new MySqlField(base.connection); field.Encoding = base.encoding; field.TableName = this.stream.ReadLenString(); field.ColumnName = this.stream.ReadLenString(); field.ColumnLength = this.stream.ReadNBytes(); MySqlDbType type = (MySqlDbType) this.stream.ReadNBytes(); this.stream.ReadByte(); if ((this.Flags & ClientFlags.LONG_FLAG) != 0) { flags = (ColumnFlags) this.stream.ReadInteger(2); } else { flags = (ColumnFlags) this.stream.ReadByte(); } field.SetTypeAndFlags(type, flags); field.Scale = (byte) this.stream.ReadByte(); if (!this.version.isAtLeast(3, 0x17, 15) && this.version.isAtLeast(3, 0x17, 0)) { field.Scale = (byte) (field.Scale + 1); } return field; }
public override DataTable GetSchemaTable() { if ((this.fields == null) || (this.fields.Length == 0)) { return(null); } DataTable table = new DataTable("SchemaTable"); table.Columns.Add("ColumnName", typeof(string)); table.Columns.Add("ColumnOrdinal", typeof(int)); table.Columns.Add("ColumnSize", typeof(int)); table.Columns.Add("NumericPrecision", typeof(int)); table.Columns.Add("NumericScale", typeof(int)); table.Columns.Add("IsUnique", typeof(bool)); table.Columns.Add("IsKey", typeof(bool)); DataColumn column = table.Columns["IsKey"]; column.AllowDBNull = true; table.Columns.Add("BaseCatalogName", typeof(string)); table.Columns.Add("BaseColumnName", typeof(string)); table.Columns.Add("BaseSchemaName", typeof(string)); table.Columns.Add("BaseTableName", typeof(string)); table.Columns.Add("DataType", typeof(Type)); table.Columns.Add("AllowDBNull", typeof(bool)); table.Columns.Add("ProviderType", typeof(int)); table.Columns.Add("IsAliased", typeof(bool)); table.Columns.Add("IsExpression", typeof(bool)); table.Columns.Add("IsIdentity", typeof(bool)); table.Columns.Add("IsAutoIncrement", typeof(bool)); table.Columns.Add("IsRowVersion", typeof(bool)); table.Columns.Add("IsHidden", typeof(bool)); table.Columns.Add("IsLong", typeof(bool)); table.Columns.Add("IsReadOnly", typeof(bool)); int num = 1; for (int i = 0; i < this.fields.Length; i++) { MySqlField field = this.fields[i]; DataRow row = table.NewRow(); row["ColumnName"] = field.ColumnName; row["ColumnOrdinal"] = num++; row["ColumnSize"] = field.IsTextField ? (field.ColumnLength / field.MaxLength) : field.ColumnLength; int precision = field.Precision; int scale = field.Scale; if (precision != -1) { row["NumericPrecision"] = (short)precision; } if (scale != -1) { row["NumericScale"] = (short)scale; } row["DataType"] = this.GetFieldType(i); row["ProviderType"] = (int)field.Type; row["IsLong"] = field.IsBlob && (field.ColumnLength > 0xff); row["AllowDBNull"] = field.AllowsNull; row["IsReadOnly"] = false; row["IsRowVersion"] = false; row["IsUnique"] = field.IsUnique; row["IsKey"] = field.IsPrimaryKey; row["IsAutoIncrement"] = field.IsAutoIncrement; row["BaseSchemaName"] = field.DatabaseName; row["BaseCatalogName"] = null; row["BaseTableName"] = field.RealTableName; row["BaseColumnName"] = field.OriginalColumnName; table.Rows.Add(row); } return(table); }
public abstract IMySqlValue ReadColumnValue(int index, MySqlField field, IMySqlValue value);
public abstract int PrepareStatement(string sql, ref MySqlField[] parameters);