[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [152] trunk/PostgreSqlClient/source/PostgreSql/Data/
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-05-19 11:12:22
|
Revision: 152 Author: carlosga_fb Date: 2006-05-19 04:12:11 -0700 (Fri, 19 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=152&view=rev Log Message: ----------- Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatementStatus.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-19 11:11:31 UTC (rev 151) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-19 11:12:11 UTC (rev 152) @@ -171,7 +171,10 @@ { try { - // Clear actual row list + // Update status + this.status = PgStatementStatus.Parsing; + + // Clear actual row list this.rows = null; this.rowIndex = 0; @@ -216,7 +219,10 @@ lock (this.db) { try - { + { + // Update status + this.status = PgStatementStatus.Describing; + string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); @@ -292,6 +298,9 @@ { try { + // Update status + this.status = PgStatementStatus.Binding; + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); // Destination portal name @@ -318,7 +327,7 @@ packet.Write((short)this.rowDescriptor.Fields.Length); for (int i = 0; i < this.rowDescriptor.Fields.Length; i++) { - packet.Write((short)this.rowDescriptor.Fields[i].FormatCode); + packet.Write((short)this.rowDescriptor.Fields[i].DataType.FormatCode); } // Send packet to the server @@ -343,6 +352,9 @@ { try { + // Update status + this.status = PgStatementStatus.Executing; + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.WriteNullString(this.PortalName); @@ -398,6 +410,9 @@ { try { + // Update status + this.status = PgStatementStatus.Executing; + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); // Function id @@ -445,14 +460,17 @@ } } - public void Query() - { - ArrayList innerRows = new ArrayList(); + public void Query() + { + ArrayList innerRows = new ArrayList(); - lock (this.db) - { + lock (this.db) + { try { + // Update Status + this.status = PgStatementStatus.OnQuery; + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.WriteNullString(this.stmtText); @@ -460,9 +478,6 @@ // Send packet to the server this.db.SendPacket(packet, PgFrontEndCodes.QUERY); - // Update Status - this.status = PgStatementStatus.OnQuery; - // Set fetch size this.fetchSize = 1; @@ -509,43 +524,40 @@ // reset fetch size this.fetchSize = 200; } - } - } + } + } - public object[] FetchRow() - { - object[] row = null; + public object[] FetchRow() + { + object[] row = null; - if ((!this.allRowsFetched && this.rows == null) || - (!this.allRowsFetched && this.rows.Length == 0) || - (!this.allRowsFetched && this.rowIndex >= this.fetchSize)) - { - lock (this) - { - // Retrieve next group of rows - this.Execute(); - } - } - - if (this.rows != null && - this.rows.Length > 0 && - this.rows[this.rowIndex] != null) - { - // Return always first row - row = (object[])this.rows[this.rowIndex++]; - } + if ((!this.allRowsFetched && this.rows == null) || + (!this.allRowsFetched && this.rows.Length == 0) || + (!this.allRowsFetched && this.rowIndex >= this.fetchSize)) + { + lock (this) + { + // Retrieve next group of rows + this.Execute(); + } + } - if (this.rows != null && - (this.rowIndex >= this.fetchSize || - this.rowIndex >= this.rows.Length || - this.rows[this.rowIndex] == null)) - { - this.rows = null; - } + if (this.rows != null && + this.rows.Length > 0 && + this.rows[this.rowIndex] != null) + { + // Return always first row + row = (object[])this.rows[this.rowIndex++]; + } - return row; - } + if (this.rows != null && (this.rowIndex >= this.rows.Length || this.rows[this.rowIndex] == null)) + { + this.rows = null; + } + return row; + } + public void Close() { this.Close('S'); @@ -774,7 +786,14 @@ break; default: - if (this.rowDescriptor.Fields[i].FormatCode == PgTypeFormat.Text) + PgTypeFormat formatCode = this.rowDescriptor.Fields[i].DataType.FormatCode; + + if (this.status == PgStatementStatus.OnQuery) + { + formatCode = this.rowDescriptor.Fields[i].FormatCode; + } + + if (formatCode == PgTypeFormat.Text) { values[i] = packet.ReadValueFromString(this.rowDescriptor.Fields[i].DataType, length); } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatementStatus.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatementStatus.cs 2006-05-19 11:11:31 UTC (rev 151) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatementStatus.cs 2006-05-19 11:12:11 UTC (rev 152) @@ -22,9 +22,13 @@ internal enum PgStatementStatus { Initial, + Parsing, Parsed, + Describing, Described, + Binding, Binded, + Executing, Executed, OnQuery, Error This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |