[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source PgDataReader.cs,1.1.1.1,1.2
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2003-08-02 21:13:38
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source In directory sc8-pr-cvs1:/tmp/cvs-serv19822 Modified Files: PgDataReader.cs Log Message: Fixed error closing the DataReader when the subyacent command is disposed, added test code for serial fields Index: PgDataReader.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/PgDataReader.cs,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** PgDataReader.cs 2 Aug 2003 19:43:00 -0000 1.1.1.1 --- PgDataReader.cs 2 Aug 2003 21:13:35 -0000 1.2 *************** *** 136,157 **** updateRecordsAffected(); ! if (command != null) { ! if (!command.IsDisposed) { ! command.Connection.DataReader = null; ! if (command.Statement != null) { ! // Set values of output parameters ! command.InternalSetOutputParameters(); ! ! // Close statement ! command.InternalClose(); ! ! if ((command.CommandBehavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection) ! { ! command.Connection.Close(); ! } } } --- 136,154 ---- updateRecordsAffected(); ! if (command != null && !command.IsDisposed) { ! command.Connection.DataReader = null; ! ! if (command.Statement != null) { ! // Set values of output parameters ! command.InternalSetOutputParameters(); ! // Close statement ! command.InternalClose(); ! ! if ((command.CommandBehavior & CommandBehavior.CloseConnection) == CommandBehavior.CloseConnection) { ! command.Connection.Close(); } } *************** *** 248,256 **** schemaRow["DataType"] = getFieldType(i); schemaRow["ProviderType"] = getProviderType(i); ! schemaRow["IsLong"] = isLong(i); ! schemaRow["IsReadOnly"] = isReadOnly(i); schemaRow["IsRowVersion"] = false; schemaRow["IsUnique"] = false; ! schemaRow["IsAutoIncrement"] = isAutoIncrement(i); schemaRow["IsAliased"] = isAliased(i); schemaRow["IsExpression"] = isExpression(i); --- 245,262 ---- schemaRow["DataType"] = getFieldType(i); schemaRow["ProviderType"] = getProviderType(i); ! schemaRow["IsLong"] = isLong(i); schemaRow["IsRowVersion"] = false; schemaRow["IsUnique"] = false; ! if ((bool)columnInfo[8] && ! columnInfo[9].ToString().StartsWith("nextval(")) ! { ! schemaRow["IsReadOnly"] = true; ! schemaRow["IsAutoIncrement"] = true; ! } ! else ! { ! schemaRow["IsReadOnly"] = false; ! schemaRow["IsAutoIncrement"] = false; ! } schemaRow["IsAliased"] = isAliased(i); schemaRow["IsExpression"] = isExpression(i); *************** *** 288,293 **** IDbSchema dbSchema = PgDbSchemaFactory.GetSchema(PgDbSchemaType.Columns); ! dbSchema.AddWhereFilter("Pg_attribute.attnum = " + field.OidNumber); ! dbSchema.AddWhereFilter("Pg_attribute.attrelid = " + field.OidTable); PgCommand schemaCmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); --- 294,299 ---- IDbSchema dbSchema = PgDbSchemaFactory.GetSchema(PgDbSchemaType.Columns); ! dbSchema.AddWhereFilter("pg_attribute.attnum = " + field.OidNumber); ! dbSchema.AddWhereFilter("pg_attribute.attrelid = " + field.OidTable); PgCommand schemaCmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); *************** *** 312,316 **** IDbSchema dbSchema = PgDbSchemaFactory.GetSchema(PgDbSchemaType.Primary_Keys); ! dbSchema.AddWhereFilter("Pg_class.oid = " + field.OidTable); PgCommand schemaCmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); --- 318,322 ---- IDbSchema dbSchema = PgDbSchemaFactory.GetSchema(PgDbSchemaType.Primary_Keys); ! dbSchema.AddWhereFilter("pg_class.oid = " + field.OidTable); PgCommand schemaCmd = new PgCommand(dbSchema.GetCommandText(null), command.Connection); *************** *** 687,709 **** } - private bool isReadOnly(int i) - { - PgType type = command.Statement.RowDescriptor.Fields[i].DataType; - - return type.IsSerial ? true : false; - } - - private bool isAutoIncrement(int i) - { - if (i < 0 || i >= FieldCount) - { - throw new IndexOutOfRangeException("Could not find specified column in results."); - } - - PgType type = command.Statement.RowDescriptor.Fields[i].DataType; - - return type.IsSerial ? true : false; - } - private bool isDBNull(int i) { --- 693,696 ---- *************** *** 767,774 **** private void updateRecordsAffected() { ! if (command.Statement.RecordsAffected != -1) { ! recordsAffected = recordsAffected == -1 ? 0 : recordsAffected; ! recordsAffected += command.Statement.RecordsAffected; } } --- 754,764 ---- private void updateRecordsAffected() { ! if (command != null && !command.IsDisposed) { ! if (command.Statement.RecordsAffected != -1) ! { ! recordsAffected = recordsAffected == -1 ? 0 : recordsAffected; ! recordsAffected += command.Statement.RecordsAffected; ! } } } |