[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source PgCommand.cs,1.10,1.11 PgCo
Status: Inactive
Brought to you by:
carlosga_fb
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source
In directory sc8-pr-cvs1:/tmp/cvs-serv30076
Modified Files:
PgCommand.cs PgConnection.cs PgDataAdapter.cs PgDataReader.cs
Log Message:
2003-11-08 Carlos Guzmán Álvarez <car...@te...>
* source/FbConnection.cs:
* source/FbCommand.cs:
* source/FbdataAdapter.cs:
- Added ToolboxItem attribute for allow components to be used from #Develop.
* source/FbDataAdapter.cs:
- Improved handling of behavior and Close method.
Index: PgCommand.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgCommand.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** PgCommand.cs 9 Oct 2003 11:31:23 -0000 1.10
--- PgCommand.cs 8 Nov 2003 12:55:23 -0000 1.11
***************
*** 29,33 ****
namespace PostgreSql.Data.PgSqlClient
{
! [ToolboxBitmap(typeof(PgCommand), "Resources.ToolBox.PgCommand.bmp")]
public sealed class PgCommand : Component, IDbCommand, ICloneable
{
--- 29,34 ----
namespace PostgreSql.Data.PgSqlClient
{
! [ToolboxItem(true),
! ToolboxBitmap(typeof(PgCommand), "Resources.ToolBox.PgCommand.bmp")]
public sealed class PgCommand : Component, IDbCommand, ICloneable
{
***************
*** 312,323 ****
public int ExecuteNonQuery()
{
! checkCommand();
! InternalPrepare();
! InternalExecute();
InternalSetOutputParameters();
! return statement.RecordsAffected;
}
--- 313,324 ----
public int ExecuteNonQuery()
{
! this.checkCommand();
! this.InternalPrepare();
! this.InternalExecute();
InternalSetOutputParameters();
! return this.statement.RecordsAffected;
}
***************
*** 339,347 ****
public PgDataReader ExecuteReader(CommandBehavior behavior)
{
! checkCommand();
commandBehavior = behavior;
! InternalPrepare();
if ((commandBehavior & System.Data.CommandBehavior.SequentialAccess) == System.Data.CommandBehavior.SequentialAccess ||
--- 340,348 ----
public PgDataReader ExecuteReader(CommandBehavior behavior)
{
! this.checkCommand();
commandBehavior = behavior;
! this.InternalPrepare();
if ((commandBehavior & System.Data.CommandBehavior.SequentialAccess) == System.Data.CommandBehavior.SequentialAccess ||
***************
*** 351,372 ****
commandBehavior == System.Data.CommandBehavior.Default)
{
! InternalExecute();
}
! return new PgDataReader(this);
}
public object ExecuteScalar()
{
! checkCommand();
object returnValue = null;
! InternalPrepare();
! InternalExecute();
! if (statement.HasRows)
{
! returnValue = ((object[])statement.Rows[0])[0];
}
--- 352,373 ----
commandBehavior == System.Data.CommandBehavior.Default)
{
! this.InternalExecute();
}
! return new PgDataReader(this, this.connection);
}
public object ExecuteScalar()
{
! this.checkCommand();
object returnValue = null;
! this.InternalPrepare();
! this.InternalExecute();
! if (this.statement.HasRows)
{
! returnValue = ((object[])this.statement.Rows[0])[0];
}
***************
*** 376,383 ****
public void Prepare()
{
! checkCommand();
! InternalPrepare();
! connection.ActiveCommands.Add(this);
}
--- 377,384 ----
public void Prepare()
{
! this.checkCommand();
! this.InternalPrepare();
! this.connection.ActiveCommands.Add(this);
}
***************
*** 386,402 ****
string plan;
! checkCommand();
try
{
! if (statement == null)
{
! statement = connection.DbConnection.DB.CreateStatement(commandText);
! plan = statement.GetPlan(verbose);
! statement = null;
}
else
{
! plan = statement.GetPlan(verbose);
}
}
--- 387,403 ----
string plan;
! this.checkCommand();
try
{
! if (this.statement == null)
{
! this.statement = this.connection.DbConnection.DB.CreateStatement(commandText);
! plan = this.statement.GetPlan(verbose);
! this.statement = null;
}
else
{
! plan = this.statement.GetPlan(verbose);
}
}
***************
*** 417,423 ****
try
{
! if (statement == null ||
! statement.Status == PgStatementStatus.Initial ||
! statement.Status == PgStatementStatus.Error)
{
if (commandType == CommandType.StoredProcedure)
--- 418,424 ----
try
{
! if (this.statement == null ||
! this.statement.Status == PgStatementStatus.Initial ||
! this.statement.Status == PgStatementStatus.Error)
{
if (commandType == CommandType.StoredProcedure)
***************
*** 432,436 ****
string portalName = "PR" + getStmtName();
! statement = connection.DbConnection.DB.CreateStatement(
prepareName,
portalName,
--- 433,437 ----
string portalName = "PR" + getStmtName();
! this.statement = this.connection.DbConnection.DB.CreateStatement(
prepareName,
portalName,
***************
*** 438,450 ****
// Parse the statment
! statement.Parse();
// Describe parameters
! statement.Describe();
}
else
{
// Close existent portal
! statement.ClosePortal();
}
}
--- 439,451 ----
// Parse the statment
! this.statement.Parse();
// Describe parameters
! this.statement.Describe();
}
else
{
// Close existent portal
! this.statement.ClosePortal();
}
}
***************
*** 466,473 ****
// Bind Statement
! statement.Bind();
// Execute Statement
! statement.Execute();
}
catch (PgClientException ex)
--- 467,474 ----
// Bind Statement
! this.statement.Bind();
// Execute Statement
! this.statement.Execute();
}
catch (PgClientException ex)
***************
*** 481,486 ****
try
{
! statement = connection.DbConnection.DB.CreateStatement(commandText);
! statement.Query();
}
catch (PgClientException ex)
--- 482,487 ----
try
{
! this.statement = this.connection.DbConnection.DB.CreateStatement(commandText);
! this.statement.Query();
}
catch (PgClientException ex)
***************
*** 492,502 ****
internal void InternalClose()
{
! if (statement != null)
{
try
{
// Closing the prepared statement closes all his portals too.
! statement.Close();
! statement = null;
}
catch (PgClientException ex)
--- 493,503 ----
internal void InternalClose()
{
! if (this.statement != null)
{
try
{
// Closing the prepared statement closes all his portals too.
! this.statement.Close();
! this.statement = null;
}
catch (PgClientException ex)
***************
*** 525,534 ****
if (commandText != null && commandText.Trim().Length > 0)
{
! statement.Close();
! statement.ClosePortal();
! statement = null;
! InternalPrepare();
! InternalExecute();
returnValue = true;
--- 526,535 ----
if (commandText != null && commandText.Trim().Length > 0)
{
! this.statement.Close();
! this.statement.ClosePortal();
! this.statement = null;
! this.InternalPrepare();
! this.InternalExecute();
returnValue = true;
***************
*** 548,552 ****
int i = 0;
! object[] values = (object[])statement.Rows[0];
while (paramEnumerator.MoveNext())
--- 549,553 ----
int i = 0;
! object[] values = (object[])this.statement.Rows[0];
while (paramEnumerator.MoveNext())
***************
*** 605,609 ****
{
return GetHashCode().ToString() +
! connection.GetHashCode().ToString() +
DateTime.Now.Ticks;
}
--- 606,610 ----
{
return GetHashCode().ToString() +
! this.connection.GetHashCode().ToString() +
DateTime.Now.Ticks;
}
***************
*** 628,632 ****
if (parameters.Count != 0)
{
! for (int i = 0; i < statement.Parameters.Length; i++)
{
string parameterName = parameters[i].ParameterName;
--- 629,633 ----
if (parameters.Count != 0)
{
! for (int i = 0; i < this.statement.Parameters.Length; i++)
{
string parameterName = parameters[i].ParameterName;
***************
*** 650,658 ****
if (parameters[index].Value == System.DBNull.Value)
{
! statement.Parameters[i].Value = null;
}
else
{
! statement.Parameters[i].Value = parameters[index].Value;
}
}
--- 651,659 ----
if (parameters[index].Value == System.DBNull.Value)
{
! this.statement.Parameters[i].Value = null;
}
else
{
! this.statement.Parameters[i].Value = parameters[index].Value;
}
}
***************
*** 663,686 ****
private void checkCommand()
{
! if (connection == null || connection.State != ConnectionState.Open)
{
throw new InvalidOperationException("Connection must valid and open");
}
! if (connection.DataReader != null)
{
throw new InvalidOperationException("There is already an open DataReader associated with this Connection which must be closed first.");
}
! if (connection.ActiveTransaction != null &&
! !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 (transaction != null &&
! !connection.Equals(Transaction.Connection))
{
throw new InvalidOperationException("Command Connection is not equal to Transaction Connection");
}
! if (commandText == String.Empty || commandText == null)
{
throw new InvalidOperationException ("The command text for this Command has not been set.");
--- 664,688 ----
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.");
Index: PgConnection.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgConnection.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** PgConnection.cs 6 Oct 2003 18:46:59 -0000 1.4
--- PgConnection.cs 8 Nov 2003 12:55:23 -0000 1.5
***************
*** 28,33 ****
namespace PostgreSql.Data.PgSqlClient
{
! [ToolboxBitmap(typeof(PgConnection), "Resources.ToolBox.PgConnection.bmp")]
! [DefaultEvent("InfoMessage")]
public sealed class PgConnection : Component, IDbConnection, ICloneable
{
--- 28,34 ----
namespace PostgreSql.Data.PgSqlClient
{
! [ToolboxItem(true),
! ToolboxBitmap(typeof(PgConnection), "Resources.ToolBox.PgConnection.bmp"),
! DefaultEvent("InfoMessage")]
public sealed class PgConnection : Component, IDbConnection, ICloneable
{
Index: PgDataAdapter.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgDataAdapter.cs,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** PgDataAdapter.cs 2 Aug 2003 19:43:00 -0000 1.1.1.1
--- PgDataAdapter.cs 8 Nov 2003 12:55:23 -0000 1.2
***************
*** 33,37 ****
#endregion
! [ToolboxBitmap(typeof(PgDataAdapter), "Resources.ToolBox.PgDataAdapter.bmp"),
DefaultEvent("RowUpdated")]
public sealed class PgDataAdapter : DbDataAdapter, IDbDataAdapter
--- 33,38 ----
#endregion
! [ToolboxItem(true),
! ToolboxBitmap(typeof(PgDataAdapter), "Resources.ToolBox.PgDataAdapter.bmp"),
DefaultEvent("RowUpdated")]
public sealed class PgDataAdapter : DbDataAdapter, IDbDataAdapter
Index: PgDataReader.cs
===================================================================
RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgDataReader.cs,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** PgDataReader.cs 26 Oct 2003 14:56:38 -0000 1.11
--- PgDataReader.cs 8 Nov 2003 12:55:23 -0000 1.12
***************
*** 35,47 ****
#region FIELDS
! private const int STARTPOS = -1;
! private bool disposed;
! private bool open;
! private int position;
! private int recordsAffected;
! private int fieldCount;
! private DataTable schemaTable;
! private PgCommand command;
! private object[] row;
#endregion
--- 35,49 ----
#region FIELDS
! private const int STARTPOS = -1;
! private bool disposed;
! private bool open;
! private int position;
! private int recordsAffected;
! private int fieldCount;
! private DataTable schemaTable;
! private CommandBehavior behavior;
! private PgCommand command;
! private PgConnection connection;
! private object[] row;
#endregion
***************
*** 51,65 ****
private PgDataReader()
{
! open = true;
! position = STARTPOS;
! recordsAffected = -1;
! fieldCount = -1;
}
! internal PgDataReader(PgCommand command) : this()
{
! command.Connection.DataReader = this;
!
! this.command = command;
}
--- 53,67 ----
private PgDataReader()
{
! this.open = true;
! this.position = STARTPOS;
! this.recordsAffected = -1;
! this.fieldCount = -1;
}
! internal PgDataReader(PgCommand command, PgConnection connection) : this()
{
! this.command = command;
! this.behavior = this.command.CommandBehavior;
! this.connection = connection;
}
***************
*** 70,79 ****
~PgDataReader()
{
! Dispose(false);
}
void IDisposable.Dispose()
{
! Dispose(true);
System.GC.SuppressFinalize(this);
}
--- 72,81 ----
~PgDataReader()
{
! this.Dispose(false);
}
void IDisposable.Dispose()
{
! this.Dispose(true);
System.GC.SuppressFinalize(this);
}
***************
*** 81,85 ****
private void Dispose(bool disposing)
{
! if (!disposed)
{
try
--- 83,87 ----
private void Dispose(bool disposing)
{
! if (!this.disposed)
{
try
***************
*** 88,92 ****
{
// release any managed resources
! Close();
}
--- 90,99 ----
{
// release any managed resources
! this.Close();
!
! this.command = null;
! this.connection = null;
! this.row = null;
! this.schemaTable= null;
}
***************
*** 97,101 ****
}
! disposed = true;
}
}
--- 104,108 ----
}
! this.disposed = true;
}
}
***************
*** 130,134 ****
public void Close()
{
! if (!open)
{
return;
--- 137,141 ----
public void Close()
{
! if (!this.open)
{
return;
***************
*** 136,180 ****
// This will update RecordsAffected property
! updateRecordsAffected();
! if (command != null && !command.IsDisposed)
{
! command.Connection.DataReader = null;
!
! if (command.Statement != null)
{
// Set values of output parameters
! command.InternalSetOutputParameters();
!
! if ((command.CommandBehavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)
! {
! command.Connection.Close();
! }
}
}
! open = false;
! position = STARTPOS;
}
public bool NextResult()
{
! if (IsClosed)
{
throw new InvalidOperationException("The datareader must be opened.");
}
! updateRecordsAffected();
! bool returnValue = command.NextResult();
if (returnValue)
{
! fieldCount = command.Statement.RowDescriptor.Fields.Length;
! position = STARTPOS;
}
else
{
! row = null;
}
--- 143,190 ----
// This will update RecordsAffected property
! this.updateRecordsAffected();
! if (this.command != null && !this.command.IsDisposed)
{
! if (this.command.Statement != null)
{
// Set values of output parameters
! this.command.InternalSetOutputParameters();
}
}
! if (this.connection != null)
! {
! this.connection.DataReader = null;
!
! if ((this.behavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection)
! {
! this.connection.Close();
! }
! }
!
! this.open = false;
! this.position = STARTPOS;
}
public bool NextResult()
{
! if (this.IsClosed)
{
throw new InvalidOperationException("The datareader must be opened.");
}
! this.updateRecordsAffected();
! bool returnValue = this.command.NextResult();
if (returnValue)
{
! this.fieldCount = this.command.Statement.RowDescriptor.Fields.Length;
! this.position = STARTPOS;
}
else
{
! this.row = null;
}
***************
*** 186,191 ****
bool read = false;
! if ((command.CommandBehavior == CommandBehavior.SingleRow &&
! position != STARTPOS) || !command.Statement.HasRows)
{
}
--- 196,202 ----
bool read = false;
! if ((this.behavior == CommandBehavior.SingleRow &&
! this.position != STARTPOS) ||
! !this.command.Statement.HasRows)
{
}
***************
*** 194,204 ****
try
{
! fieldCount = command.Statement.RowDescriptor.Fields.Length;
! ++position;
row = command.Statement.FetchRow();
! read = (row == null) ? false : true;
}
catch (PgClientException ex)
--- 205,215 ----
try
{
! this.fieldCount = this.command.Statement.RowDescriptor.Fields.Length;
! this.position++;
row = command.Statement.FetchRow();
! read = (this.row == null) ? false : true;
}
catch (PgClientException ex)
|