From: <car...@us...> - 2004-07-31 14:02:21
|
Update of /cvsroot/firebird/NETProvider/NETProvider_17/source/FirebirdSql.Data.Firebird In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26940 Modified Files: FbCommand.cs FbDataReader.cs FbTransaction.cs Log Message: 2004-07-31 Carlos Guzman Alvarez <car...@te...> * FirebirdSql.Data.Firebird/FbCommand.cs: * FirebirdSql.Data.Firebird/FbDataReader.cs: * FirebirdSql.Data.Firebird/FbTransaction.cs: - Removed the code of the partial batch command execution (that was available only using FbDataReader.NextResult) Index: FbCommand.cs =================================================================== RCS file: /cvsroot/firebird/NETProvider/NETProvider_17/source/FirebirdSql.Data.Firebird/FbCommand.cs,v retrieving revision 1.7 retrieving revision 1.8 diff -b -U3 -r1.7 -r1.8 --- FbCommand.cs 27 Jul 2004 08:53:26 -0000 1.7 +++ FbCommand.cs 31 Jul 2004 14:02:12 -0000 1.8 @@ -56,11 +56,8 @@ private string commandText; private bool disposed; private bool designTimeVisible; - private bool returnsSet; private bool implicitTransaction; private int commandTimeout; - private int actualCommand; - private StringCollection commands; private StringCollection namedParameters; #endregion @@ -90,8 +87,6 @@ } this.commandText = value; - this.actualCommand = 0; - this.commands.Clear(); } } } @@ -314,8 +309,6 @@ this.designTimeVisible = true; this.commandTimeout = 30; this.namedParameters = new StringCollection(); - this.commands = new StringCollection(); - this.actualCommand = -1; this.CommandText = cmdText; this.Connection = connection; @@ -365,7 +358,6 @@ if (disposing) { this.commandText = String.Empty; - this.actualCommand = -1; this.commandTimeout = 0; this.implicitTransaction = false; this.connection = null; @@ -373,8 +365,6 @@ this.parameters = null; this.namedParameters.Clear(); this.namedParameters = null; - this.commands.Clear(); - this.commands = null; } this.disposed = true; @@ -440,9 +430,6 @@ try { - this.actualCommand = 0; - this.returnsSet = false; - this.ExecuteCommand(CommandBehavior.Default, false); this.InternalSetOutputParameters(); @@ -491,8 +478,6 @@ try { - this.returnsSet = true; - this.ExecuteCommand(behavior, true); } catch (IscException ex) @@ -525,17 +510,9 @@ try { - this.actualCommand = 0; - if (this.CommandType == CommandType.StoredProcedure) - { - this.returnsSet = false; - } - else - { - this.returnsSet = true; - } + bool returnsSet = !(this.CommandType == CommandType.StoredProcedure); - this.ExecuteCommand(CommandBehavior.Default, false); + this.ExecuteCommand(CommandBehavior.Default, returnsSet); // Gets only the values of the first row DbValue[] values = this.statement.Fetch(); @@ -574,11 +551,7 @@ try { - this.returnsSet = false; - this.actualCommand = 0; - this.commands.Clear(); - - this.InternalPrepare(); + this.InternalPrepare(false); } catch (IscException ex) { @@ -599,7 +572,7 @@ #region Internal Methods - internal void InternalPrepare() + internal void InternalPrepare(bool returnsSet) { // Add this command to the active command list if (this.connection != null && @@ -618,9 +591,6 @@ this.transaction.BeginTransaction(); } - // Split the command text - this.SplitCommandText(false); - // Check if we have a valid statement handle if (this.statement == null) { @@ -638,16 +608,18 @@ // Prepare the statement if needed if (!this.statement.IsPrepared) { + string sql = this.commandText; + if (this.commandType == CommandType.StoredProcedure) { - this.commands[actualCommand] = this.BuildStoredProcedureSql(); + sql = this.BuildStoredProcedureSql(sql, returnsSet); } - this.statement.Prepare(this.ParseNamedParameters()); + this.statement.Prepare(this.ParseNamedParameters(sql)); if (this.parameters.Count > 0) { - Descriptor descriptor = this.buildParametersDescriptor(); + Descriptor descriptor = this.BuildParametersDescriptor(); if (descriptor == null) { this.statement.DescribeParameters(); @@ -707,36 +679,6 @@ return null; } - internal bool NextResult(CommandBehavior behavior) - { - bool returnValue = false; - - this.Release(); - - if ((behavior & CommandBehavior.SingleResult) != CommandBehavior.SingleResult) - { - this.actualCommand++; - - if (this.actualCommand >= commands.Count) - { - this.actualCommand--; - } - else - { - string commandText = this.commands[actualCommand]; - if (commandText != null && commandText.Length > 0) - { - this.InternalPrepare(); - this.InternalExecute(); - - returnValue = true; - } - } - } - - return returnValue; - } - internal void InternalSetOutputParameters() { if (this.CommandType == CommandType.StoredProcedure && @@ -843,27 +785,27 @@ #region Input parameter descriptor generation methods - private Descriptor buildParametersDescriptor() + private Descriptor BuildParametersDescriptor() { - short count = this.validateInputParameters(); + short count = this.ValidateInputParameters(); if (count > 0) { if (this.namedParameters.Count > 0) { count = (short)this.namedParameters.Count; - return this.buildNamedParametersDescriptor(count); + return this.BuildNamedParametersDescriptor(count); } else { - return this.buildPlaceHoldersDescriptor(count); + return this.BuildPlaceHoldersDescriptor(count); } } return null; } - private Descriptor buildNamedParametersDescriptor(short count) + private Descriptor BuildNamedParametersDescriptor(short count) { Descriptor descriptor = new Descriptor(count); int index = 0; @@ -875,7 +817,7 @@ if (parameter.Direction == ParameterDirection.Input || parameter.Direction == ParameterDirection.InputOutput) { - if (!this.buildParameterDescriptor(descriptor, parameter, index++)) + if (!this.BuildParameterDescriptor(descriptor, parameter, index++)) { return null; } @@ -885,7 +827,7 @@ return descriptor; } - private Descriptor buildPlaceHoldersDescriptor(short count) + private Descriptor BuildPlaceHoldersDescriptor(short count) { Descriptor descriptor = new Descriptor(count); int index = 0; @@ -897,7 +839,7 @@ if (parameter.Direction == ParameterDirection.Input || parameter.Direction == ParameterDirection.InputOutput) { - if (!this.buildParameterDescriptor(descriptor, parameter, index++)) + if (!this.BuildParameterDescriptor(descriptor, parameter, index++)) { return null; } @@ -907,7 +849,7 @@ return descriptor; } - private bool buildParameterDescriptor( + private bool BuildParameterDescriptor( Descriptor descriptor, FbParameter parameter, int index) @@ -961,7 +903,7 @@ return true; } - private short validateInputParameters() + private short ValidateInputParameters() { short count = 0; @@ -992,10 +934,9 @@ #region Private Methods - private void ExecuteCommand(CommandBehavior behavior, bool split) + private void ExecuteCommand(CommandBehavior behavior, bool returnsSet) { - this.SplitCommandText(split); - this.InternalPrepare(); + this.InternalPrepare(returnsSet); if ((behavior & CommandBehavior.SequentialAccess) == CommandBehavior.SequentialAccess || (behavior & CommandBehavior.SingleResult) == CommandBehavior.SingleResult || @@ -1007,45 +948,16 @@ } } - private void SplitCommandText(bool batchAllowed) - { - if (this.commands.Count == 0) - { - this.commands.Clear(); - - if (batchAllowed) - { - MatchCollection matches = Regex.Matches( - this.commandText, - "([^';]+('.*'))*[^';]*(?=;*)"); - - for (int i = 0; i < matches.Count; i++) - { - if (matches[i].Value != null && matches[i].Value.Length > 0) - { - this.commands.Add(matches[i].Value.Trim()); - } - } - } - else - { - this.commands.Add(this.CommandText); - } - } - } - - private string BuildStoredProcedureSql() + private string BuildStoredProcedureSql(string sql, bool returnsSet) { - string commandText = this.commands[actualCommand]; - - if (commandText != null && - !commandText.ToLower(CultureInfo.CurrentCulture).StartsWith("execute procedure ") && - !commandText.ToLower(CultureInfo.CurrentCulture).StartsWith("select ")) + if (sql != null && + !sql.ToLower(CultureInfo.CurrentCulture).StartsWith("execute procedure ") && + !sql.ToLower(CultureInfo.CurrentCulture).StartsWith("select ")) { StringBuilder paramsText = new StringBuilder(); // Append the stored proc parameter name - paramsText.Append(commandText); + paramsText.Append(sql); if (parameters.Count > 0) { paramsText.Append("("); @@ -1067,23 +979,21 @@ paramsText.Replace("()", ""); } - if (this.returnsSet) + if (returnsSet) { - commandText = "select * from " + paramsText.ToString(); + sql = "select * from " + paramsText.ToString(); } else { - commandText = "execute procedure " + paramsText.ToString(); + sql = "execute procedure " + paramsText.ToString(); } } - return commandText; + return sql; } - private string ParseNamedParameters() + private string ParseNamedParameters(string sql) { - string sql = this.commands[actualCommand]; - this.namedParameters.Clear(); if (sql.IndexOf("@") != -1) Index: FbDataReader.cs =================================================================== RCS file: /cvsroot/firebird/NETProvider/NETProvider_17/source/FirebirdSql.Data.Firebird/FbDataReader.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -b -U3 -r1.6 -r1.7 --- FbDataReader.cs 28 Jul 2004 10:12:48 -0000 1.6 +++ FbDataReader.cs 31 Jul 2004 14:02:12 -0000 1.7 @@ -196,26 +196,7 @@ /// <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="NextResult"]/*'/> public bool NextResult() { - if (this.IsClosed) - { - throw new InvalidOperationException("The datareader must be opened."); - } - - this.UpdateRecordsAffected(); - - bool returnValue = this.command.NextResult(this.behavior); - - if (returnValue) - { - this.fields = this.command.GetFieldsDescriptor(); - this.position = STARTPOS; - } - else - { - this.row = null; - } - - return returnValue; + return false; } /// <include file='Doc/en_EN/FbDataReader.xml' path='doc/class[@name="FbDataReader"]/method[@name="Read"]/*'/> @@ -271,7 +252,7 @@ schemaCmd.Parameters.Add("@TABLE_NAME", FbDbType.Char, 31); schemaCmd.Parameters.Add("@COLUMN_NAME", FbDbType.Char, 31); - schemaCmd.InternalPrepare(); + schemaCmd.Prepare(); schemaTable.BeginLoadData(); for (int i = 0; i < this.fields.Count; i++) Index: FbTransaction.cs =================================================================== RCS file: /cvsroot/firebird/NETProvider/NETProvider_17/source/FirebirdSql.Data.Firebird/FbTransaction.cs,v retrieving revision 1.5 retrieving revision 1.6 diff -b -U3 -r1.5 -r1.6 --- FbTransaction.cs 27 Jul 2004 08:53:26 -0000 1.5 +++ FbTransaction.cs 31 Jul 2004 14:02:12 -0000 1.6 @@ -239,8 +239,7 @@ "SAVEPOINT " + savePointName, this.connection, this); - command.InternalPrepare(); - command.InternalExecute(); + command.ExecuteNonQuery(); command.Dispose(); } catch(IscException ex) @@ -277,8 +276,7 @@ "ROLLBACK WORK TO SAVEPOINT " + savePointName, this.connection, this); - command.InternalPrepare(); - command.InternalExecute(); + command.ExecuteNonQuery(); command.Dispose(); } catch(IscException ex) |