[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source PgCommand.cs,1.17,1.18 PgCo
Status: Inactive
Brought to you by:
carlosga_fb
|
From: <car...@us...> - 2003-11-24 16:39:01
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv25794
Modified Files:
PgCommand.cs PgConnection.cs PgTransaction.cs
Log Message:
2003-11-24 Carlos Guzmán Álvarez <car...@te...>
* source/PgConnection.cs:
* source/PgCommand.cs:
* source/PgTransaction.cs:
- Added better handling of connection active transaction,
(some checks done using the ODBC data provider).
Index: PgCommand.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** PgCommand.cs 21 Nov 2003 21:55:54 -0000 1.17
--- PgCommand.cs 24 Nov 2003 16:38:58 -0000 1.18
***************
*** 579,582 ****
--- 579,615 ----
#region PRIVATE_METHODS
+ private void checkCommand()
+ {
+ if (this.transaction != null &&
+ this.transaction.IsUpdated)
+ {
+ this.transaction = null;
+ }
+ if (this.connection == null ||
+ this.connection.State != ConnectionState.Open)
+ {
+ throw new InvalidOperationException("Connection must valid and open");
+ }
+ if (this.connection.DataReader != null)
+ {
+ throw new InvalidOperationException("There is already an open DataReader associated with this Connection which must be closed first.");
+ }
+ if (this.connection.ActiveTransaction != null &&
+ !this.connection.ActiveTransaction.IsUpdated &&
+ this.Transaction == null)
+ {
+ throw new InvalidOperationException("Execute requires the Command object to have a Transaction object when the Connection object assigned to the command is in a pending local transaction. The Transaction property of the Command has not been initialized.");
+ }
+ if (this.transaction != null &&
+ !this.connection.Equals(Transaction.Connection))
+ {
+ throw new InvalidOperationException("Command Connection is not equal to Transaction Connection");
+ }
+ if (this.commandText == String.Empty || this.commandText == null)
+ {
+ throw new InvalidOperationException ("The command text for this Command has not been set.");
+ }
+ }
+
private string parseSPCommandText()
{
***************
*** 682,713 ****
}
}
- }
- }
-
- private void checkCommand()
- {
- if (this.connection == null ||
- this.connection.State != ConnectionState.Open)
- {
- throw new InvalidOperationException("Connection must valid and open");
- }
- if (this.connection.DataReader != null)
- {
- throw new InvalidOperationException("There is already an open DataReader associated with this Connection which must be closed first.");
- }
- if (this.connection.ActiveTransaction != null &&
- !this.connection.ActiveTransaction.IsUpdated &&
- this.Transaction == null)
- {
- throw new InvalidOperationException("Execute requires the Command object to have a Transaction object when the Connection object assigned to the command is in a pending local transaction. The Transaction property of the Command has not been initialized.");
- }
- if (this.transaction != null &&
- !this.connection.Equals(Transaction.Connection))
- {
- throw new InvalidOperationException("Command Connection is not equal to Transaction Connection");
- }
- if (this.commandText == String.Empty || this.commandText == null)
- {
- throw new InvalidOperationException ("The command text for this Command has not been set.");
}
}
--- 715,718 ----
Index: PgConnection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnection.cs,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** PgConnection.cs 21 Nov 2003 18:04:19 -0000 1.8
--- PgConnection.cs 24 Nov 2003 16:38:58 -0000 1.9
***************
*** 191,194 ****
--- 191,195 ----
{
get { return activeTransaction; }
+ set { activeTransaction = value; }
}
Index: PgTransaction.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgTransaction.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** PgTransaction.cs 12 Nov 2003 19:54:19 -0000 1.2
--- PgTransaction.cs 24 Nov 2003 16:38:58 -0000 1.3
***************
*** 66,69 ****
--- 66,79 ----
{
get { return isUpdated; }
+ set
+ {
+ if (connection != null &&
+ value)
+ {
+ connection.ActiveTransaction = null;
+ connection = null;
+ }
+ isUpdated = value;
+ }
}
***************
*** 79,83 ****
internal PgTransaction(PgConnection connection) : this(connection, IsolationLevel.ReadCommitted)
{
! }
internal PgTransaction(PgConnection connection, IsolationLevel isolation)
--- 89,93 ----
internal PgTransaction(PgConnection connection) : this(connection, IsolationLevel.ReadCommitted)
{
! }
internal PgTransaction(PgConnection connection, IsolationLevel isolation)
***************
*** 96,99 ****
--- 106,113 ----
}
+ #endregion
+
+ #region IDISPOSABLE_METHODS
+
public void Dispose()
{
***************
*** 118,123 ****
finally
{
! connection = null;
disposed = true;
}
}
--- 132,142 ----
finally
{
! if (connection != null)
! {
! connection.ActiveTransaction = null;
! connection = null;
! }
disposed = true;
+ isUpdated = true;
}
}
***************
*** 144,149 ****
connection.DbConnection.DB.CommitTransaction();
! isUpdated = true;
! connection = null;
}
catch (PgClientException ex)
--- 163,167 ----
connection.DbConnection.DB.CommitTransaction();
! IsUpdated = true;
}
catch (PgClientException ex)
***************
*** 168,173 ****
connection.DbConnection.DB.RollbackTransction();
! isUpdated = true;
! connection = null;
}
catch (PgClientException ex)
--- 186,190 ----
connection.DbConnection.DB.RollbackTransction();
! IsUpdated = true;
}
catch (PgClientException ex)
***************
*** 183,187 ****
connection.DbConnection.DB.BeginTransaction(isolationLevel);
! isUpdated = false;
}
catch (PgClientException ex)
--- 200,204 ----
connection.DbConnection.DB.BeginTransaction(isolationLevel);
! IsUpdated = false;
}
catch (PgClientException ex)
|