示例#1
0
 internal MySqlDataReader(MySqlCommand cmd, PreparableStatement statement, CommandBehavior behavior)
 {
     this.command = cmd;
     this.connection = this.command.Connection;
     this.commandBehavior = behavior;
     this.driver = this.connection.driver;
     this.affectedRows = -1L;
     this.statement = statement;
     this.nextResultDone = false;
     this.fieldHashCS = new Hashtable();
     this.fieldHashCI = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
 }
示例#2
0
 internal MySqlDataReader(MySqlCommand cmd, PreparableStatement statement, CommandBehavior behavior)
 {
     this.command         = cmd;
     this.connection      = this.command.Connection;
     this.commandBehavior = behavior;
     this.driver          = this.connection.driver;
     this.affectedRows    = -1L;
     this.statement       = statement;
     this.nextResultDone  = false;
     this.fieldHashCS     = new Hashtable();
     this.fieldHashCI     = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
 }
示例#3
0
        private void Prepare(int cursorPageSize)
        {
            if (!this.connection.driver.Version.isAtLeast(5, 0, 0) && (cursorPageSize > 0))
            {
                throw new InvalidOperationException("Nested commands are only supported on MySQL 5.0 and later");
            }
            string commandText = this.CommandText;

            if ((commandText != null) && (commandText.Trim().Length != 0))
            {
                if (this.CommandType == System.Data.CommandType.StoredProcedure)
                {
                    this.statement = new StoredProcedure(this, this.CommandText);
                }
                else
                {
                    this.statement = new PreparableStatement(this, this.CommandText);
                }
                this.statement.Prepare();
            }
        }
示例#4
0
        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;
            System.Threading.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))
                {
                    System.Threading.TimerCallback callback = new System.Threading.TimerCallback(this.TimeoutExpired);
                    timer = new System.Threading.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);
        }
示例#5
0
		private void Prepare( int cursorPageSize ) {
			if( !this.connection.driver.Version.isAtLeast( 5, 0, 0 ) && ( cursorPageSize > 0 ) ) {
				throw new InvalidOperationException( "Nested commands are only supported on MySQL 5.0 and later" );
			}
			string commandText = this.CommandText;
			if( ( commandText != null ) && ( commandText.Trim().Length != 0 ) ) {
				if( this.CommandType == System.Data.CommandType.StoredProcedure ) {
					this.statement = new StoredProcedure( this, this.CommandText );
				} else {
					this.statement = new PreparableStatement( this, this.CommandText );
				}
				this.statement.Prepare();
			}
		}
示例#6
0
		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;
			System.Threading.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 ) ) {
					System.Threading.TimerCallback callback = new System.Threading.TimerCallback( this.TimeoutExpired );
					timer = new System.Threading.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;
		}