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); }
private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs) { #if !RT 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()); } } } #endif }
private void ReportUsageAdvisorWarnings(int statementId, ResultSet rs) { #if !RT 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()); } } #endif }
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; }