public static void AddToCache(string commandText, ResultSet resultSet) { cache.AddToCache(commandText, resultSet); }
public override ResultSet NextResult(int statementId, bool force) { // first let's see if we already have a resultset on this statementId if (activeResult != null) { //oldRS = activeResults[statementId]; if (Settings.UseUsageAdvisor) ReportUsageAdvisorWarnings(statementId, activeResult); MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultClosed, Resources.TraceResultClosed, driverId, activeResult.TotalRows, activeResult.SkippedRows, rowSizeInBytes); rowSizeInBytes = 0; activeResult = null; } activeResult = base.NextResult(statementId, force); return activeResult; }
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 }
public static void AddToCache(string commandText, ResultSet resultSet) { cache.AddToCache(commandText, resultSet); }