예제 #1
0
        public override void SendQuery(MySqlPacket p)
        {
            this.rowSizeInBytes = 0;
            string text  = base.Encoding.GetString(p.Buffer, 5, p.Length - 5);
            string text2 = null;

            if (text.Length > 300)
            {
                QueryNormalizer queryNormalizer = new QueryNormalizer();
                text2 = queryNormalizer.Normalize(text);
                text  = text.Substring(0, 300);
            }
            base.SendQuery(p);
            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryOpened, Resources.TraceQueryOpened, new object[]
            {
                this.driverId,
                base.ThreadID,
                text
            });
            if (text2 != null)
            {
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryNormalized, Resources.TraceQueryNormalized, new object[]
                {
                    this.driverId,
                    base.ThreadID,
                    text2
                });
            }
        }
예제 #2
0
        public override void CloseQuery(MySqlConnection connection, int statementId)
        {
            base.CloseQuery(connection, statementId);

            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryClosed,
                                  Resources.TraceQueryDone, driverId);
        }
예제 #3
0
        protected override int GetResult(int statementId, ref int affectedRows, ref long insertedId)
        {
            int result2;

            try
            {
                int result = base.GetResult(statementId, ref affectedRows, ref insertedId);
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultOpened, Resources.TraceResult, new object[]
                {
                    this.driverId,
                    result,
                    affectedRows,
                    insertedId
                });
                result2 = result;
            }
            catch (MySqlException ex)
            {
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.Error, Resources.TraceOpenResultError, new object[]
                {
                    this.driverId,
                    ex.Number,
                    ex.Message
                });
                throw ex;
            }
            return(result2);
        }
예제 #4
0
        public override bool FetchDataRow(int statementId, int columns)
        {
            bool result;

            try
            {
                bool flag = base.FetchDataRow(statementId, columns);
                if (flag)
                {
                    this.rowSizeInBytes += (this.handler as NativeDriver).Packet.Length;
                }
                result = flag;
            }
            catch (MySqlException ex)
            {
                MySqlTrace.TraceEvent(TraceEventType.Error, MySqlTraceEventType.Error, Resources.TraceFetchError, new object[]
                {
                    this.driverId,
                    ex.Number,
                    ex.Message
                });
                throw ex;
            }
            return(result);
        }
예제 #5
0
        public override int PrepareStatement(string sql, ref MySqlField[] parameters)
        {
            int statementId = base.PrepareStatement(sql, ref parameters);

            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared,
                                  Resources.TraceStatementPrepared, driverId, sql, statementId);
            return(statementId);
        }
예제 #6
0
 public override void Close()
 {
     base.Close();
     MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ConnectionClosed, Resources.TraceCloseConnection, new object[]
     {
         this.driverId
     });
 }
예제 #7
0
 public override void CloseStatement(int id)
 {
     base.CloseStatement(id);
     MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementClosed, Resources.TraceStatementClosed, new object[]
     {
         this.driverId,
         id
     });
 }
예제 #8
0
 public override void SetDatabase(string dbName)
 {
     base.SetDatabase(dbName);
     MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.NonQuery, Resources.TraceSetDatabase, new object[]
     {
         this.driverId,
         dbName
     });
 }
예제 #9
0
 public override void Open()
 {
     base.Open();
     MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ConnectionOpened, Resources.TraceOpenConnection, new object[]
     {
         this.driverId,
         base.Settings.ConnectionString,
         base.ThreadID
     });
 }
예제 #10
0
        public override List <MySqlError> ReportWarnings(MySqlConnection connection)
        {
            List <MySqlError> warnings = base.ReportWarnings(connection);

            foreach (MySqlError warning in warnings)
            {
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.Warning,
                                      Resources.TraceWarning, driverId, warning.Level, warning.Code, warning.Message);
            }
            return(warnings);
        }
예제 #11
0
        public override int PrepareStatement(string sql, ref MySqlField[] parameters)
        {
            int num = base.PrepareStatement(sql, ref parameters);

            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementPrepared, Resources.TraceStatementPrepared, new object[]
            {
                this.driverId,
                sql,
                num
            });
            return(num);
        }
예제 #12
0
        public override void ExecuteStatement(MySqlPacket packetToExecute)
        {
            base.ExecuteStatement(packetToExecute);
            int pos = packetToExecute.Position;

            packetToExecute.Position = 1;
            int statementId = packetToExecute.ReadInteger(4);

            packetToExecute.Position = pos;

            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementExecuted,
                                  Resources.TraceStatementExecuted, driverId, statementId, ThreadID);
        }
예제 #13
0
        public override List <MySqlError> ReportWarnings(MySqlConnection connection)
        {
            List <MySqlError> list = base.ReportWarnings(connection);

            foreach (MySqlError current in list)
            {
                MySqlTrace.TraceEvent(TraceEventType.Warning, MySqlTraceEventType.Warning, Resources.TraceWarning, new object[]
                {
                    this.driverId,
                    current.Level,
                    current.Code,
                    current.Message
                });
            }
            return(list);
        }
예제 #14
0
        public override void ExecuteStatement(MySqlPacket packetToExecute)
        {
            base.ExecuteStatement(packetToExecute);
            int position = packetToExecute.Position;

            packetToExecute.Position = 1;
            int num = packetToExecute.ReadInteger(4);

            packetToExecute.Position = position;
            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.StatementExecuted, Resources.TraceStatementExecuted, new object[]
            {
                this.driverId,
                num,
                base.ThreadID
            });
        }
예제 #15
0
 public override bool FetchDataRow(int statementId, int columns)
 {
     try
     {
         bool b = base.FetchDataRow(statementId, columns);
         if (b)
         {
             rowSizeInBytes += (handler as NativeDriver).Packet.Length;
         }
         return(b);
     }
     catch (MySqlException ex)
     {
         MySqlTrace.TraceEvent(TraceEventType.Error, MySqlTraceEventType.Error,
                               Resources.TraceFetchError, driverId, ex.Number, ex.Message);
         throw ex;
     }
 }
예제 #16
0
        protected override int GetResult(int statementId, ref int affectedRows, ref long insertedId)
        {
            try
            {
                int fieldCount = base.GetResult(statementId, ref affectedRows, ref insertedId);
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultOpened,
                                      Resources.TraceResult, driverId, fieldCount, affectedRows, insertedId);

                return(fieldCount);
            }
            catch (MySqlException ex)
            {
                // we got an error so we report it
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.Error,
                                      Resources.TraceOpenResultError, driverId, ex.Number, ex.Message);
                throw ex;
            }
        }
예제 #17
0
        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);
        }
예제 #18
0
 public override ResultSet NextResult(int statementId, bool force)
 {
     if (this.activeResult != null)
     {
         if (base.Settings.UseUsageAdvisor)
         {
             this.ReportUsageAdvisorWarnings(statementId, this.activeResult);
         }
         MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ResultClosed, Resources.TraceResultClosed, new object[]
         {
             this.driverId,
             this.activeResult.TotalRows,
             this.activeResult.SkippedRows,
             this.rowSizeInBytes
         });
         this.rowSizeInBytes = 0;
         this.activeResult   = null;
     }
     this.activeResult = base.NextResult(statementId, force);
     return(this.activeResult);
 }
예제 #19
0
        public override void SendQuery(MySqlPacket p)
        {
            rowSizeInBytes = 0;
            string cmdText         = Encoding.GetString(p.Buffer, 5, p.Length - 5);
            string normalizedQuery = null;

            if (cmdText.Length > 300)
            {
                QueryNormalizer normalizer = new QueryNormalizer();
                normalizedQuery = normalizer.Normalize(cmdText);
                cmdText         = cmdText.Substring(0, 300);
            }

            base.SendQuery(p);

            MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryOpened,
                                  Resources.TraceQueryOpened, driverId, ThreadID, cmdText);
            if (normalizedQuery != null)
            {
                MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.QueryNormalized,
                                      Resources.TraceQueryNormalized, driverId, ThreadID, normalizedQuery);
            }
        }
예제 #20
0
 public override void Open()
 {
     base.Open();
     MySqlTrace.TraceEvent(TraceEventType.Information, MySqlTraceEventType.ConnectionOpened,
                           Resources.TraceOpenConnection, driverId, Settings.ConnectionString, ThreadID);
 }
예제 #21
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());
                    }
                }
            }
        }
예제 #22
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()
                 });
             }
         }
     }
 }