new public MySqlDataReader ExecuteReader(CommandBehavior behavior) { MySqlDataReader reader2; this.lastInsertedId = -1L; this.CheckState(); if ((this.cmdText == null) || (this.cmdText.Trim().Length == 0)) { throw new InvalidOperationException(Resources.CommandTextNotInitialized); } string text = TrimSemicolons(this.cmdText); this.connection.IsExecutingBuggyQuery = false; if (!this.connection.driver.Version.isAtLeast(5, 0, 0) && this.connection.driver.Version.isAtLeast(4, 1, 0)) { string str2 = text; if (str2.Length > 0x11) { str2 = text.Substring(0, 0x11); } str2 = str2.ToLower(CultureInfo.InvariantCulture); this.connection.IsExecutingBuggyQuery = str2.StartsWith("describe") || str2.StartsWith("show table status"); } if ((this.statement == null) || !this.statement.IsPrepared) { if (this.CommandType == System.Data.CommandType.StoredProcedure) { this.statement = new StoredProcedure(this, text); } else { this.statement = new PreparableStatement(this, text); } } this.statement.Resolve(); this.HandleCommandBehaviors(behavior); this.updatedRowCount = -1L; Timer timer = null; try { MySqlDataReader reader = new MySqlDataReader(this, this.statement, behavior); this.timedOut = false; this.statement.Execute(); if (this.connection.driver.Version.isAtLeast(5, 0, 0) && (this.commandTimeout > 0)) { TimerCallback callback = new TimerCallback(this.TimeoutExpired); timer = new Timer(callback, this, this.CommandTimeout * 0x3e8, -1); } reader.NextResult(); this.connection.Reader = reader; reader2 = reader; } catch (MySqlException exception) { if (exception.Number == 0x525) { if (this.TimedOut) { throw new MySqlException(Resources.Timeout); } return null; } if (exception.IsFatal) { this.Connection.Close(); } if (exception.Number == 0) { throw new MySqlException(Resources.FatalErrorDuringExecute, exception); } throw; } finally { if (timer != null) { timer.Dispose(); } } return reader2; }
private static string GetString(MySqlDataReader reader, int index) { if (reader.IsDBNull(index)) { return null; } return reader.GetString(index); }