FieldRead() public method

public FieldRead ( int index ) : bool
index int
return bool
Example #1
0
 private bool AllFieldsAccessed(ResultSet rs)
 {
     if (rs.Fields == null || rs.Fields.Length == 0)
     {
         return(true);
     }
     for (int i = 0; i < rs.Fields.Length; i++)
     {
         if (!rs.FieldRead(i))
         {
             return(false);
         }
     }
     return(true);
 }
Example #2
0
        private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs)
        {
            if (!Settings.UseUsageAdvisor)
            {
                return;
            }

            if (HasStatus(ServerStatusFlags.NoIndex))
            {
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                                      Resources.TraceUAWarningNoIndex, driverId, UsageAdvisorWarningFlags.NoIndex);
            }
            else if (HasStatus(ServerStatusFlags.BadIndex))
            {
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                                      Resources.TraceUAWarningBadIndex, driverId, UsageAdvisorWarningFlags.BadIndex);
            }

            // report abandoned rows
            if (rs.SkippedRows > 0)
            {
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                                      Resources.TraceUAWarningSkippedRows, driverId, UsageAdvisorWarningFlags.SkippedRows, rs.SkippedRows);
            }

            // report not all fields accessed
            if (!AllFieldsAccessed(rs))
            {
                StringBuilder notAccessed = new StringBuilder("");
                string        delimiter   = "";
                for (int i = 0; i < rs.Size; i++)
                {
                    if (!rs.FieldRead(i))
                    {
                        notAccessed.AppendFormat("{0}{1}", delimiter, rs.Fields[i].ColumnName);
                        delimiter = ",";
                    }
                }
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                                      Resources.TraceUAWarningSkippedColumns, driverId, UsageAdvisorWarningFlags.SkippedColumns,
                                      notAccessed.ToString());
            }

            // report type conversions if any
            if (rs.Fields != null)
            {
                foreach (MySqlField f in rs.Fields)
                {
                    StringBuilder s         = new StringBuilder();
                    string        delimiter = "";
                    foreach (Type t in f.TypeConversions)
                    {
                        s.AppendFormat("{0}{1}", delimiter, t.Name);
                        delimiter = ",";
                    }
                    if (s.Length > 0)
                    {
                        MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                                              Resources.TraceUAWarningFieldConversion, driverId, UsageAdvisorWarningFlags.FieldConversion,
                                              f.ColumnName, s.ToString());
                    }
                }
            }
        }
    private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs)
    {
      if (!Settings.UseUsageAdvisor) return;

      if (HasStatus(ServerStatusFlags.NoIndex))
        MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
            Resources.TraceUAWarningNoIndex, driverId, UsageAdvisorWarningFlags.NoIndex);
      else if (HasStatus(ServerStatusFlags.BadIndex))
        MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
            Resources.TraceUAWarningBadIndex, driverId, UsageAdvisorWarningFlags.BadIndex);

      // report abandoned rows
      if (rs.SkippedRows > 0)
        MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
            Resources.TraceUAWarningSkippedRows, driverId, UsageAdvisorWarningFlags.SkippedRows, rs.SkippedRows);

      // report not all fields accessed
      if (!AllFieldsAccessed(rs))
      {
        StringBuilder notAccessed = new StringBuilder("");
        string delimiter = "";
        for (int i = 0; i < rs.Size; i++)
          if (!rs.FieldRead(i))
          {
            notAccessed.AppendFormat("{0}{1}", delimiter, rs.Fields[i].ColumnName);
            delimiter = ",";
          }
        MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
            Resources.TraceUAWarningSkippedColumns, driverId, UsageAdvisorWarningFlags.SkippedColumns,
                notAccessed.ToString());
      }

      // report type conversions if any
      if (rs.Fields != null)
      {
        foreach (MySqlField f in rs.Fields)
        {
          StringBuilder s = new StringBuilder();
          string delimiter = "";
          foreach (Type t in f.TypeConversions)
          {
            s.AppendFormat("{0}{1}", delimiter, t.Name);
            delimiter = ",";
          }
          if (s.Length > 0)
            MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.UsageAdvisorWarning,
                Resources.TraceUAWarningFieldConversion, driverId, UsageAdvisorWarningFlags.FieldConversion,
                f.ColumnName, s.ToString());
        }
      }
    }
    private bool AllFieldsAccessed(ResultSet rs)
    {
      if (rs.Fields == null || rs.Fields.Length == 0) return true;

      for (int i = 0; i < rs.Fields.Length; i++)
        if (!rs.FieldRead(i)) return false;
      return true;
    }
Example #5
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()
                 });
             }
         }
     }
 }