Thread: [pgsqlclient-checkins] SF.net SVN: pgsqlclient: [123] trunk/PostgreSqlClient/source/PostgreSql/Data/
Status: Inactive
Brought to you by:
carlosga_fb
From: <car...@us...> - 2006-04-14 14:17:34
|
Revision: 123 Author: carlosga_fb Date: 2006-04-14 07:17:26 -0700 (Fri, 14 Apr 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=123&view=rev Log Message: ----------- Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-04-14 14:16:59 UTC (rev 122) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-04-14 14:17:26 UTC (rev 123) @@ -70,7 +70,7 @@ DataTypes.Add(629 , "_line" , PgDataType.Array , 628, PgTypeFormat.Binary, 32); DataTypes.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24); DataTypes.Add(719 , "_circle" , PgDataType.Array , 718, PgTypeFormat.Binary, 24); - DataTypes.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Binary, 4); + DataTypes.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Text, 4); DataTypes.Add(701 , "float8" , PgDataType.Double , 0, PgTypeFormat.Binary, 8); DataTypes.Add(705 , "unknown" , PgDataType.Text , 0, PgTypeFormat.Binary, 0); DataTypes.Add(790 , "money" , PgDataType.Currency , 0, PgTypeFormat.Binary, 4); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs 2006-04-14 14:16:59 UTC (rev 122) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs 2006-04-14 14:17:26 UTC (rev 123) @@ -417,8 +417,11 @@ break; case PgDataType.Float: - packet.Write(size); - packet.Write(Convert.ToSingle(value)); + { + string paramValue = Convert.ToSingle(value).ToString(CultureInfo.InvariantCulture); + packet.Write(encoding.GetByteCount(paramValue)); + packet.Write(paramValue.ToCharArray()); + } break; case PgDataType.Currency: Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-04-14 14:16:59 UTC (rev 122) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-04-14 14:17:26 UTC (rev 123) @@ -665,9 +665,13 @@ #endregion - internal byte[] ToArray() + #region \xB7 Internal Methods \xB7 + + internal byte[] ToArray() { return ((MemoryStream)this.stream).ToArray(); - } - } + } + + #endregion + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-05-18 13:32:22
|
Revision: 142 Author: carlosga_fb Date: 2006-05-18 06:32:04 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=142&view=rev Log Message: ----------- 2006-05-18 Carlos Guzman Alvarez (car...@gm...) * Initial implementation for PostgreSql Domains, not all domains are supported only those who have a base data type that is supported by the provider Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs 2006-05-18 11:37:30 UTC (rev 141) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs 2006-05-18 13:32:04 UTC (rev 142) @@ -24,6 +24,7 @@ #region \xB7 Fields \xB7 private PgType dataType; + private int dataTypeOid; private object data; #endregion @@ -42,6 +43,11 @@ set { this.data = value; } } + public int DataTypeOid + { + get { return this.dataTypeOid; } + } + #endregion #region \xB7 Constructors \xB7 @@ -50,9 +56,14 @@ { } - public PgParameter(int dataType) + public PgParameter(int dataTypeOid) { - this.dataType = PgDatabase.DataTypes[dataType]; + this.dataTypeOid = dataTypeOid; + + if (PgDatabase.DataTypes.Contains(dataTypeOid)) + { + this.dataType = PgDatabase.DataTypes[dataTypeOid]; + } } public PgParameter(int dataType, object data) : this(dataType) Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-18 11:37:30 UTC (rev 141) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-18 13:32:04 UTC (rev 142) @@ -210,7 +210,7 @@ { this.Describe('P'); } - + private void Describe(char stmtType) { lock (this.db) @@ -239,6 +239,40 @@ } while (!response.IsRowDescription && !response.IsNoData); + // Review if there are some parameter witha domain as a Data Type + foreach (PgParameter parameter in this.parameters) + { + if (parameter.DataType == null) + { + // It's a non supported data type or a domain data type + PgStatement stmt = new PgStatement(this.db, String.Format("select typbasetype from pg_type where oid = {0} and typtype = 'd'", parameter.DataTypeOid)); + + try + { + stmt.Query(); + + if (!stmt.HasRows) + { + throw new PgClientException("Unsupported data type"); + } + + int baseTypeOid = Convert.ToInt32(stmt.FetchRow()[0]); + + if (baseTypeOid == 0 || !PgDatabase.DataTypes.Contains(baseTypeOid)) + { + throw new PgClientException("Unsupported data type"); + } + + // Try to add the data type to the list of supported data types + parameter.DataType = PgDatabase.DataTypes[baseTypeOid]; + } + catch + { + throw new PgClientException("Unsupported data type"); + } + } + } + // Update status this.status = PgStatementStatus.Described; } @@ -417,63 +451,64 @@ lock (this.db) { - try - { - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + try + { + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); - packet.WriteNullString(this.stmtText); + packet.WriteNullString(this.stmtText); - // Send packet to the server - this.db.SendPacket(packet, PgFrontEndCodes.QUERY); + // Send packet to the server + this.db.SendPacket(packet, PgFrontEndCodes.QUERY); - // Update Status - this.status = PgStatementStatus.OnQuery; + // Update Status + this.status = PgStatementStatus.OnQuery; - // Set fetch size - this.fetchSize = 1; + // Set fetch size + this.fetchSize = 1; - // Receive response - PgResponsePacket response = null; - - do - { - response = this.db.ReceiveResponsePacket(); - this.ProcessSqlPacket(response); + // Receive response + PgResponsePacket response = null; - if (this.hasRows && - response.Message == PgBackendCodes.DATAROW) - { - innerRows.Add(this.rows[0]); - this.rowIndex = 0; - } - } - while (!response.IsReadyForQuery); - - if (this.hasRows) - { - // Obtain all the rows - this.rows = (object[])innerRows.ToArray(typeof(object)); + do + { + response = this.db.ReceiveResponsePacket(); + this.ProcessSqlPacket(response); - // reset rowIndex - this.rowIndex = 0; + if (this.hasRows && response.Message == PgBackendCodes.DATAROW) + { + innerRows.Add(this.rows[0]); + this.rowIndex = 0; + } + } + while (!response.IsReadyForQuery); - // Set allRowsFetched flag - this.allRowsFetched = true; - } + if (this.hasRows) + { + // Obtain all the rows + this.rows = (object[])innerRows.ToArray(typeof(object)); - // reset fetch size - this.fetchSize = 200; + // reset rowIndex + this.rowIndex = 0; - // Update status - this.status = PgStatementStatus.Executed; - } - catch - { - // Update status - this.status = PgStatementStatus.Error; - // Throw exception - throw; - } + // Set allRowsFetched flag + this.allRowsFetched = true; + } + + // Update status + this.status = PgStatementStatus.Executed; + } + catch + { + // Update status + this.status = PgStatementStatus.Error; + // Throw exception + throw; + } + finally + { + // reset fetch size + this.fetchSize = 200; + } } } @@ -529,31 +564,31 @@ { string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); - packet.Write((byte)stmtType); - packet.WriteNullString(name); + packet.Write((byte)stmtType); + packet.WriteNullString(String.IsNullOrEmpty(name) ? "" : name); - // Send packet to the server - this.db.SendPacket(packet, PgFrontEndCodes.CLOSE); + // Send packet to the server + this.db.SendPacket(packet, PgFrontEndCodes.CLOSE); - // Sync server and client - this.db.Flush(); + // Sync server and client + this.db.Flush(); - // Read until CLOSE COMPLETE message is received - PgResponsePacket response = null; - - do - { - response = this.db.ReceiveResponsePacket(); - this.ProcessSqlPacket(response); - } - while (!response.IsCloseComplete); + // Read until CLOSE COMPLETE message is received + PgResponsePacket response = null; - // Clear rows - this.rows = null; - this.rowIndex = 0; + do + { + response = this.db.ReceiveResponsePacket(); + this.ProcessSqlPacket(response); + } + while (!response.IsCloseComplete); + // Clear rows + this.rows = null; + this.rowIndex = 0; + // Update Status this.status = PgStatementStatus.Initial; } @@ -703,7 +738,7 @@ this.rowDescriptor.Fields[i].DataType = PgDatabase.DataTypes[packet.ReadInt32()]; this.rowDescriptor.Fields[i].DataTypeSize = packet.ReadInt16(); this.rowDescriptor.Fields[i].TypeModifier = packet.ReadInt32(); - this.rowDescriptor.Fields[i].FormatCode = (PgTypeFormat)packet.ReadInt16(); + this.rowDescriptor.Fields[i].FormatCode = (PgTypeFormat)packet.ReadInt16(); } } @@ -713,7 +748,7 @@ for (int i = 0; i < parameters.Length; i++) { - this.parameters[i] = new PgParameter(packet.ReadInt32()); + this.parameters[i] = new PgParameter(packet.ReadInt32()); } } @@ -739,7 +774,7 @@ break; default: - if (this.rowDescriptor.Fields[i].DataType.FormatCode == PgTypeFormat.Text) + if (this.rowDescriptor.Fields[i].FormatCode == PgTypeFormat.Text) { values[i] = packet.ReadValueFromString(this.rowDescriptor.Fields[i].DataType, length); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-05-18 19:49:23
|
Revision: 144 Author: carlosga_fb Date: 2006-05-18 12:49:14 -0700 (Thu, 18 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=144&view=rev Log Message: ----------- 2006-05-18 Carlos Guzman Alvarez (car...@gm...) * Added initial refcursor support for StoredProcedure calls to the PgDataReader class ( multiple refcursor's supported ). Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs 2006-05-18 13:32:38 UTC (rev 143) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs 2006-05-18 19:49:14 UTC (rev 144) @@ -46,6 +46,7 @@ Path , Point , Polygon , + Refcursor , Text , Time , TimeWithTZ , Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-18 13:32:38 UTC (rev 143) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-18 19:49:14 UTC (rev 144) @@ -101,7 +101,7 @@ DataTypes.Add(1560 , "bit" , PgDataType.Byte , 0, PgTypeFormat.Text, 1); DataTypes.Add(1562 , "varbit" , PgDataType.Byte , 0, PgTypeFormat.Binary, 0); DataTypes.Add(1700 , "numeric" , PgDataType.Decimal , 0, PgTypeFormat.Text, 8); - DataTypes.Add(1790 , "refcursor" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + DataTypes.Add(1790 , "refcursor" , PgDataType.Refcursor , 0, PgTypeFormat.Text, 0); DataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-18 13:32:38 UTC (rev 143) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-18 19:49:14 UTC (rev 144) @@ -397,6 +397,7 @@ return this.ReadString(length).TrimEnd(); case PgDataType.VarChar: + case PgDataType.Refcursor: return this.ReadString(length); case PgDataType.Boolean: @@ -488,7 +489,8 @@ case PgDataType.Char: return stringValue.TrimEnd(); - case PgDataType.VarChar: + case PgDataType.VarChar: + case PgDataType.Refcursor: return stringValue; case PgDataType.Boolean: Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-18 13:32:38 UTC (rev 143) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-18 19:49:14 UTC (rev 144) @@ -318,7 +318,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].DataType.FormatCode); + packet.Write((short)this.rowDescriptor.Fields[i].FormatCode); } // Send packet to the server Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-18 13:32:38 UTC (rev 143) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-18 19:49:14 UTC (rev 144) @@ -81,6 +81,48 @@ get { return this.size; } } + public bool IsNumeric + { + get + { + bool returnValue = false; + + if (this.dataType == PgDataType.Currency || + this.dataType == PgDataType.Int2 || + this.dataType == PgDataType.Int4 || + this.dataType == PgDataType.Int8 || + this.dataType == PgDataType.Float || + this.dataType == PgDataType.Double || + this.dataType == PgDataType.Decimal || + this.dataType == PgDataType.Byte) + { + returnValue = true; + } + + return returnValue; + } + } + + public bool IsLong + { + get + { + bool returnValue = false; + + if (this.dataType == PgDataType.Binary) + { + returnValue = true; + } + + return returnValue; + } + } + + public bool IsRefCursor + { + get { return (this.DataType == PgDataType.Refcursor); } + } + #endregion #region \xB7 Constructors \xB7 @@ -98,41 +140,6 @@ #endregion - #region \xB7 Methods \xB7 - - public bool IsNumeric() - { - bool returnValue = false; - - if (this.dataType == PgDataType.Currency || - this.dataType == PgDataType.Int2 || - this.dataType == PgDataType.Int4 || - this.dataType == PgDataType.Int8 || - this.dataType == PgDataType.Float || - this.dataType == PgDataType.Double || - this.dataType == PgDataType.Decimal || - this.dataType == PgDataType.Byte) - { - returnValue = true; - } - - return returnValue; - } - - public bool IsLong() - { - bool returnValue = false; - - if (this.dataType == PgDataType.Binary) - { - returnValue = true; - } - - return returnValue; - } - - #endregion - #region \xB7 Private Methods \xB7 private Type InferSystemType() @@ -203,6 +210,9 @@ case PgDataType.Int8: return Type.GetType("System.Int64"); + case PgDataType.Refcursor: + return typeof(DataTable); + default: return Type.GetType("System.Object"); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-05-19 09:22:42
|
Revision: 149 Author: carlosga_fb Date: 2006-05-19 02:22:36 -0700 (Fri, 19 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=149&view=rev Log Message: ----------- Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-19 09:22:07 UTC (rev 148) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-19 09:22:36 UTC (rev 149) @@ -77,6 +77,7 @@ DataTypes.Add(829 , "macaddr" , PgDataType.VarChar , 0, PgTypeFormat.Text, 6); DataTypes.Add(869 , "inet" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); DataTypes.Add(1000 , "_bool" , PgDataType.Array , 16, PgTypeFormat.Binary, 1); + DataTypes.Add(1002 , "_char" , PgDataType.Array , 18, PgTypeFormat.Binary, 0); DataTypes.Add(1005 , "_int2" , PgDataType.Array , 21, PgTypeFormat.Binary, 2); DataTypes.Add(1007 , "_int4" , PgDataType.Array , 23, PgTypeFormat.Binary, 4); DataTypes.Add(1009 , "_text" , PgDataType.Array , 25, PgTypeFormat.Binary, 0); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-19 09:22:07 UTC (rev 148) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-19 09:22:36 UTC (rev 149) @@ -473,16 +473,15 @@ public object ReadValueFromString(PgType type, int length) { + if (type.IsArray) + { + return this.ReadStringArray(type, length); + } + string stringValue = this.ReadString(length); switch (type.DataType) { - case PgDataType.Array: - return null; - - case PgDataType.Vector: - return null; - case PgDataType.Binary: return null; @@ -601,7 +600,7 @@ PgType elementType = PgDatabase.DataTypes[type.ElementType]; Array data = null; - string contents = ReadString(length); + string contents = this.ReadString(length); contents = contents.Substring(1, contents.Length - 2); string[] elements = contents.Split(','); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-19 09:22:07 UTC (rev 148) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-19 09:22:36 UTC (rev 149) @@ -103,6 +103,21 @@ } } + public bool IsArray + { + get + { + bool returnValue = false; + + if (this.dataType == PgDataType.Array) + { + returnValue = true; + } + + return returnValue; + } + } + public bool IsLong { get This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
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. |
From: <car...@us...> - 2006-05-31 18:35:31
|
Revision: 165 Author: carlosga_fb Date: 2006-05-31 11:35:17 -0700 (Wed, 31 May 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=165&view=rev Log Message: ----------- 2006-05-31 Carlos Guzman Alvarez (car...@gm...) - Committed initial support for fetching PostGIS Box2D values. Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDataType.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -28,6 +28,8 @@ Binary , Boolean , Box , + Box2D , + Box3D , Byte , Char , Circle , Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -61,14 +61,14 @@ DataTypes.Add(25 , "text" , PgDataType.Text , 0, PgTypeFormat.Text, Int32.MaxValue); DataTypes.Add(26 , "oid" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); DataTypes.Add(30 , "oidvector" , PgDataType.Vector , 26, PgTypeFormat.Binary, 4); - DataTypes.Add(600 , "point" , PgDataType.Point , 701, PgTypeFormat.Binary, 16); - DataTypes.Add(601 , "lseg" , PgDataType.LSeg , 600, PgTypeFormat.Binary, 32); - DataTypes.Add(602 , "path" , PgDataType.Path , 0, PgTypeFormat.Binary, 16); - DataTypes.Add(603 , "box" , PgDataType.Box , 600, PgTypeFormat.Binary, 32); - DataTypes.Add(604 , "polygon" , PgDataType.Polygon , 0, PgTypeFormat.Binary, 16); - DataTypes.Add(628 , "line" , PgDataType.Line , 701, PgTypeFormat.Binary, 32); + DataTypes.Add(600 , "point" , PgDataType.Point , 701, PgTypeFormat.Binary, 16, ","); + DataTypes.Add(601 , "lseg" , PgDataType.LSeg , 600, PgTypeFormat.Binary, 32, ","); + DataTypes.Add(602 , "path" , PgDataType.Path , 0, PgTypeFormat.Binary, 16, ","); + DataTypes.Add(603 , "box" , PgDataType.Box , 600, PgTypeFormat.Binary, 32, ";"); + DataTypes.Add(604 , "polygon" , PgDataType.Polygon , 0, PgTypeFormat.Binary, 16, ","); + DataTypes.Add(628 , "line" , PgDataType.Line , 701, PgTypeFormat.Binary, 32, ","); DataTypes.Add(629 , "_line" , PgDataType.Array , 628, PgTypeFormat.Binary, 32); - DataTypes.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24); + DataTypes.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24, ","); DataTypes.Add(719 , "_circle" , PgDataType.Array , 718, PgTypeFormat.Binary, 24); DataTypes.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Text, 4); DataTypes.Add(701 , "float8" , PgDataType.Double , 0, PgTypeFormat.Binary, 8); @@ -105,6 +105,10 @@ DataTypes.Add(1790 , "refcursor" , PgDataType.Refcursor , 0, PgTypeFormat.Text, 0); DataTypes.Add(2205 , "regclass" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); DataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); + + // PostGIS datatypes + DataTypes.Add(16418 , "box3d" , PgDataType.Box3D , 0, PgTypeFormat.Text, 48, ","); + DataTypes.Add(17335 , "box2d" , PgDataType.Box2D , 0, PgTypeFormat.Text, 16, ","); } public static void InitializeCharSets() Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -378,9 +378,9 @@ #endregion - #region \xB7 Common Methods \xB7 + #region \xB7 Common Methods \xB7 - public object ReadValue(PgType type, int length) + public object ReadValue(PgType type, int length) { switch (type.DataType) { @@ -560,6 +560,9 @@ case PgDataType.Path: return PgPath.Parse(stringValue); + case PgDataType.Box2D: + return PgBox2D.Parse(stringValue); + default: return this.packet.ReadBytes(length); } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -245,7 +245,7 @@ } while (!response.IsRowDescription && !response.IsNoData); - // Review if there are some parameter witha domain as a Data Type + // Review if there are some parameter with a domain as a Data Type foreach (PgParameter parameter in this.parameters) { if (parameter.DataType == null) Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -30,7 +30,8 @@ private Type systemType; private int elementType; private PgTypeFormat formatCode; - private int size; + private int size; + private string delimiter; #endregion @@ -138,21 +139,39 @@ get { return (this.DataType == PgDataType.Refcursor); } } + public string Delimiter + { + get { return this.delimiter; } + } + #endregion #region \xB7 Constructors \xB7 public PgType(int oid, string name, PgDataType dataType, int elementType, PgTypeFormat formatCode, int size) + : this(oid, name, dataType, elementType, formatCode, size, "") { - this.oid = oid; - this.name = name; - this.dataType = dataType; - this.elementType = elementType; - this.formatCode = formatCode; - this.size = size; - this.systemType = this.InferSystemType(); } + public PgType( + int oid, + string name, + PgDataType dataType, + int elementType, + PgTypeFormat formatCode, + int size, + string delimiter) + { + this.oid = oid; + this.name = name; + this.dataType = dataType; + this.elementType = elementType; + this.formatCode = formatCode; + this.size = size; + this.systemType = this.InferSystemType(); + this.delimiter = delimiter; + } + #endregion #region \xB7 Private Methods \xB7 Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs 2006-05-29 07:28:34 UTC (rev 164) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs 2006-05-31 18:35:17 UTC (rev 165) @@ -91,11 +91,29 @@ return type; } - public PgType Add(int oid, string name, PgDataType dataType, int elementType, PgTypeFormat formatCode, int size) + public PgType Add( + int oid, + string name, + PgDataType dataType, + int elementType, + PgTypeFormat formatCode, + int size) { return this.Add(new PgType(oid, name, dataType, elementType, formatCode, size)); } + public PgType Add( + int oid, + string name, + PgDataType dataType, + int elementType, + PgTypeFormat formatCode, + int size, + string delimiter) + { + return this.Add(new PgType(oid, name, dataType, elementType, formatCode, size, delimiter)); + } + #endregion #region \xB7 Private Methods \xB7 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-06-19 21:29:36
|
Revision: 172 Author: carlosga_fb Date: 2006-06-19 14:29:24 -0700 (Mon, 19 Jun 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=172&view=rev Log Message: ----------- Changes on internal data type handling ( not finished ) Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -35,80 +35,80 @@ { #region \xB7 Static Properties \xB7 - public static readonly PgTypeCollection DataTypes = new PgTypeCollection(); + //public static readonly PgTypeCollection DataTypes = InitializeDataTypes(); public static readonly PgCharactersetCollection Charactersets = new PgCharactersetCollection(); #endregion #region \xB7 Static Methods \xB7 - public static void InitializeTypes() + public static PgTypeCollection InitializeDataTypes() { - if (DataTypes.Count > 0) - { - return; - } + PgTypeCollection dataTypes = new PgTypeCollection(); - DataTypes.Add(16 , "bool" , PgDataType.Boolean , 0, PgTypeFormat.Binary, 1); - DataTypes.Add(17 , "bytea" , PgDataType.Binary , 0, PgTypeFormat.Binary, Int32.MaxValue); - DataTypes.Add(18 , "char" , PgDataType.Char , 0, PgTypeFormat.Text, 0); - DataTypes.Add(19 , "name" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - DataTypes.Add(20 , "int8" , PgDataType.Int8 , 0, PgTypeFormat.Binary, 8); - DataTypes.Add(21 , "int2" , PgDataType.Int2 , 0, PgTypeFormat.Binary, 2); - DataTypes.Add(22 , "int2vector" , PgDataType.Vector , 21, PgTypeFormat.Binary, 2); - DataTypes.Add(23 , "int4" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); - DataTypes.Add(24 , "regproc" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - DataTypes.Add(25 , "text" , PgDataType.Text , 0, PgTypeFormat.Text, Int32.MaxValue); - DataTypes.Add(26 , "oid" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); - DataTypes.Add(30 , "oidvector" , PgDataType.Vector , 26, PgTypeFormat.Binary, 4); - DataTypes.Add(600 , "point" , PgDataType.Point , 701, PgTypeFormat.Binary, 16, ","); - DataTypes.Add(601 , "lseg" , PgDataType.LSeg , 600, PgTypeFormat.Binary, 32, ","); - DataTypes.Add(602 , "path" , PgDataType.Path , 0, PgTypeFormat.Binary, 16, ","); - DataTypes.Add(603 , "box" , PgDataType.Box , 600, PgTypeFormat.Binary, 32, ";"); - DataTypes.Add(604 , "polygon" , PgDataType.Polygon , 0, PgTypeFormat.Binary, 16, ","); - DataTypes.Add(628 , "line" , PgDataType.Line , 701, PgTypeFormat.Binary, 32, ","); - DataTypes.Add(629 , "_line" , PgDataType.Array , 628, PgTypeFormat.Binary, 32); - DataTypes.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24, ","); - DataTypes.Add(719 , "_circle" , PgDataType.Array , 718, PgTypeFormat.Binary, 24); - DataTypes.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Text, 4); - DataTypes.Add(701 , "float8" , PgDataType.Double , 0, PgTypeFormat.Binary, 8); - DataTypes.Add(705 , "unknown" , PgDataType.Text , 0, PgTypeFormat.Binary, 0); - DataTypes.Add(790 , "money" , PgDataType.Currency , 0, PgTypeFormat.Binary, 4); - DataTypes.Add(829 , "macaddr" , PgDataType.VarChar , 0, PgTypeFormat.Text, 6); - DataTypes.Add(869 , "inet" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - DataTypes.Add(1000 , "_bool" , PgDataType.Array , 16, PgTypeFormat.Binary, 1); - DataTypes.Add(1002 , "_char" , PgDataType.Array , 18, PgTypeFormat.Binary, 0); - DataTypes.Add(1005 , "_int2" , PgDataType.Array , 21, PgTypeFormat.Binary, 2); - DataTypes.Add(1007 , "_int4" , PgDataType.Array , 23, PgTypeFormat.Binary, 4); - DataTypes.Add(1009 , "_text" , PgDataType.Array , 25, PgTypeFormat.Binary, 0); - DataTypes.Add(1016 , "_int8" , PgDataType.Array , 20, PgTypeFormat.Binary, 8); - DataTypes.Add(1017 , "_point" , PgDataType.Array , 600, PgTypeFormat.Binary, 16); - DataTypes.Add(1018 , "_lseg" , PgDataType.Array , 601, PgTypeFormat.Binary, 32); - DataTypes.Add(1019 , "_path" , PgDataType.Array , 602, PgTypeFormat.Binary, -1); - DataTypes.Add(1020 , "_box" , PgDataType.Array , 603, PgTypeFormat.Binary, 32); - DataTypes.Add(1021 , "_float4" , PgDataType.Array , 700, PgTypeFormat.Binary, 4); - DataTypes.Add(1027 , "_polygon" , PgDataType.Array , 604, PgTypeFormat.Binary, 16); - DataTypes.Add(1028 , "_oid" , PgDataType.Array , 26, PgTypeFormat.Binary, 4); - DataTypes.Add(1033 , "aclitem" , PgDataType.VarChar , 0, PgTypeFormat.Text, 12); - DataTypes.Add(1034 , "_aclitem" , PgDataType.Array , 1033, PgTypeFormat.Text, 0); - DataTypes.Add(1042 , "bpchar" , PgDataType.Char , 0, PgTypeFormat.Text, 0); - DataTypes.Add(1043 , "varchar" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - DataTypes.Add(1082 , "date" , PgDataType.Date , 0, PgTypeFormat.Binary, 4); - DataTypes.Add(1083 , "time" , PgDataType.Time , 0, PgTypeFormat.Text, 8); - DataTypes.Add(1114 , "timestamp" , PgDataType.Timestamp , 0, PgTypeFormat.Text, 8); - DataTypes.Add(1184 , "timestamptz" , PgDataType.TimestampWithTZ, 0, PgTypeFormat.Binary, 8); - DataTypes.Add(1186 , "interval" , PgDataType.Interval , 0, PgTypeFormat.Binary, 12); - DataTypes.Add(1266 , "timetz" , PgDataType.TimeWithTZ , 0, PgTypeFormat.Binary, 12); - DataTypes.Add(1560 , "bit" , PgDataType.Byte , 0, PgTypeFormat.Text, 1); - DataTypes.Add(1562 , "varbit" , PgDataType.Byte , 0, PgTypeFormat.Binary, 0); - DataTypes.Add(1700 , "numeric" , PgDataType.Decimal , 0, PgTypeFormat.Text, 8); - DataTypes.Add(1790 , "refcursor" , PgDataType.Refcursor , 0, PgTypeFormat.Text, 0); - DataTypes.Add(2205 , "regclass" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - DataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); + dataTypes.Add(16 , "bool" , PgDataType.Boolean , 0, PgTypeFormat.Binary, 1); + dataTypes.Add(17 , "bytea" , PgDataType.Binary , 0, PgTypeFormat.Binary, Int32.MaxValue); + dataTypes.Add(18 , "char" , PgDataType.Char , 0, PgTypeFormat.Text, 0); + dataTypes.Add(19 , "name" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + dataTypes.Add(20 , "int8" , PgDataType.Int8 , 0, PgTypeFormat.Binary, 8); + dataTypes.Add(21 , "int2" , PgDataType.Int2 , 0, PgTypeFormat.Binary, 2); + dataTypes.Add(22 , "int2vector" , PgDataType.Vector , 21, PgTypeFormat.Binary, 2); + dataTypes.Add(23 , "int4" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); + dataTypes.Add(24 , "regproc" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + dataTypes.Add(25 , "text" , PgDataType.Text , 0, PgTypeFormat.Text, Int32.MaxValue); + dataTypes.Add(26 , "oid" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); + dataTypes.Add(30 , "oidvector" , PgDataType.Vector , 26, PgTypeFormat.Binary, 4); + dataTypes.Add(600 , "point" , PgDataType.Point , 701, PgTypeFormat.Binary, 16, ","); + dataTypes.Add(601 , "lseg" , PgDataType.LSeg , 600, PgTypeFormat.Binary, 32, ","); + dataTypes.Add(602 , "path" , PgDataType.Path , 0, PgTypeFormat.Binary, 16, ","); + dataTypes.Add(603 , "box" , PgDataType.Box , 600, PgTypeFormat.Binary, 32, ";"); + dataTypes.Add(604 , "polygon" , PgDataType.Polygon , 0, PgTypeFormat.Binary, 16, ","); + dataTypes.Add(628 , "line" , PgDataType.Line , 701, PgTypeFormat.Binary, 32, ","); + dataTypes.Add(629 , "_line" , PgDataType.Array , 628, PgTypeFormat.Binary, 32); + dataTypes.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24, ","); + dataTypes.Add(719 , "_circle" , PgDataType.Array , 718, PgTypeFormat.Binary, 24); + dataTypes.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Text, 4); + dataTypes.Add(701 , "float8" , PgDataType.Double , 0, PgTypeFormat.Binary, 8); + dataTypes.Add(705 , "unknown" , PgDataType.Text , 0, PgTypeFormat.Binary, 0); + dataTypes.Add(790 , "money" , PgDataType.Currency , 0, PgTypeFormat.Binary, 4); + dataTypes.Add(829 , "macaddr" , PgDataType.VarChar , 0, PgTypeFormat.Text, 6); + dataTypes.Add(869 , "inet" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + dataTypes.Add(1000 , "_bool" , PgDataType.Array , 16, PgTypeFormat.Binary, 1); + dataTypes.Add(1002 , "_char" , PgDataType.Array , 18, PgTypeFormat.Binary, 0); + dataTypes.Add(1005 , "_int2" , PgDataType.Array , 21, PgTypeFormat.Binary, 2); + dataTypes.Add(1007 , "_int4" , PgDataType.Array , 23, PgTypeFormat.Binary, 4); + dataTypes.Add(1009 , "_text" , PgDataType.Array , 25, PgTypeFormat.Binary, 0); + dataTypes.Add(1016 , "_int8" , PgDataType.Array , 20, PgTypeFormat.Binary, 8); + dataTypes.Add(1017 , "_point" , PgDataType.Array , 600, PgTypeFormat.Binary, 16); + dataTypes.Add(1018 , "_lseg" , PgDataType.Array , 601, PgTypeFormat.Binary, 32); + dataTypes.Add(1019 , "_path" , PgDataType.Array , 602, PgTypeFormat.Binary, -1); + dataTypes.Add(1020 , "_box" , PgDataType.Array , 603, PgTypeFormat.Binary, 32); + dataTypes.Add(1021 , "_float4" , PgDataType.Array , 700, PgTypeFormat.Binary, 4); + dataTypes.Add(1027 , "_polygon" , PgDataType.Array , 604, PgTypeFormat.Binary, 16); + dataTypes.Add(1028 , "_oid" , PgDataType.Array , 26, PgTypeFormat.Binary, 4); + dataTypes.Add(1033 , "aclitem" , PgDataType.VarChar , 0, PgTypeFormat.Text, 12); + dataTypes.Add(1034 , "_aclitem" , PgDataType.Array , 1033, PgTypeFormat.Text, 0); + dataTypes.Add(1042 , "bpchar" , PgDataType.Char , 0, PgTypeFormat.Text, 0); + dataTypes.Add(1043 , "varchar" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + dataTypes.Add(1082 , "date" , PgDataType.Date , 0, PgTypeFormat.Binary, 4); + dataTypes.Add(1083 , "time" , PgDataType.Time , 0, PgTypeFormat.Text, 8); + dataTypes.Add(1114 , "timestamp" , PgDataType.Timestamp , 0, PgTypeFormat.Text, 8); + dataTypes.Add(1184 , "timestamptz" , PgDataType.TimestampWithTZ, 0, PgTypeFormat.Binary, 8); + dataTypes.Add(1186 , "interval" , PgDataType.Interval , 0, PgTypeFormat.Binary, 12); + dataTypes.Add(1266 , "timetz" , PgDataType.TimeWithTZ , 0, PgTypeFormat.Binary, 12); + dataTypes.Add(1560 , "bit" , PgDataType.Byte , 0, PgTypeFormat.Text, 1); + dataTypes.Add(1562 , "varbit" , PgDataType.Byte , 0, PgTypeFormat.Binary, 0); + dataTypes.Add(1700 , "numeric" , PgDataType.Decimal , 0, PgTypeFormat.Text, 8); + dataTypes.Add(1790 , "refcursor" , PgDataType.Refcursor , 0, PgTypeFormat.Text, 0); + dataTypes.Add(2205 , "regclass" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + dataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); // PostGIS datatypes - DataTypes.Add(16418 , "box3d" , PgDataType.Box3D , 0, PgTypeFormat.Text, 48, ","); - DataTypes.Add(17335 , "box2d" , PgDataType.Box2D , 0, PgTypeFormat.Text, 16, ","); + dataTypes.Add(17321 , "box3d" , PgDataType.Box3D , 0, PgTypeFormat.Text, 48, ",", "BOX3D"); + dataTypes.Add(17335 , "box2d" , PgDataType.Box2D , 0, PgTypeFormat.Text, 16, ",", "BOX"); + // dataTypes.Add(-1 , "polygon2d" , PgDataType.Box2D , 0, PgTypeFormat.Text, 16, ",", "POLYGON"); + + return dataTypes; } public static void InitializeCharSets() @@ -188,7 +188,8 @@ private PgConnectionOptions options; private int handle; private int secretKey; - private char transactionStatus; + private char transactionStatus; + private PgTypeCollection dataTypes; #endregion @@ -226,6 +227,19 @@ get { return this.encoding; } } + public PgTypeCollection DataTypes + { + get + { + if (this.dataTypes == null) + { + this.dataTypes = InitializeDataTypes(); + } + + return this.dataTypes; + } + } + #endregion #region \xB7 Internal Properties \xB7 @@ -270,7 +284,6 @@ { try { - PgDatabase.InitializeTypes(); PgDatabase.InitializeCharSets(); this.InitializeSocket(); @@ -299,7 +312,7 @@ this.ParameterStatus.Clear(); // Send Startup message - PgOutputPacket packet = new PgOutputPacket(this.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes, this.Encoding); packet.Write(PgCodes.PROTOCOL_VERSION3); packet.WriteNullString("user"); @@ -325,6 +338,12 @@ this.ProcessResponsePacket(response); } while (!response.IsReadyForQuery); + + // After the connection gets established we should update the Data Types collection oids + foreach (PgType type in this.DataTypes) + { +#warning "Complete this" + } } } catch (IOException ex) @@ -344,7 +363,7 @@ try { // Send packet to the server - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes); this.SendPacket(packet, PgFrontEndCodes.TERMINATE); this.Detach(); @@ -447,7 +466,7 @@ received += this.receive.Read(buffer, received, length - received); } - responsePacket = new PgResponsePacket(type, this.Encoding, buffer); + responsePacket = new PgResponsePacket(this.DataTypes, type, this.Encoding, buffer); } catch (IOException) { @@ -501,7 +520,7 @@ // Authentication response int authType = packet.ReadInt32(); - PgOutputPacket outPacket = new PgOutputPacket(this.Encoding); + PgOutputPacket outPacket = new PgOutputPacket(this.DataTypes, this.Encoding); switch (authType) { @@ -696,7 +715,7 @@ { try { - PgOutputPacket packet = new PgOutputPacket(this.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes, this.Encoding); // Send packet to the server this.SendPacket(packet, PgFrontEndCodes.FLUSH); @@ -714,7 +733,7 @@ { try { - PgOutputPacket packet = new PgOutputPacket(this.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes, this.Encoding); // Send packet to the server this.SendPacket(packet, PgFrontEndCodes.SYNC); @@ -751,7 +770,7 @@ { try { - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes); packet.Write((int)16); packet.Write(PgCodes.CANCEL_REQUEST); @@ -776,7 +795,7 @@ { try { - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.DataTypes); packet.Write(PgCodes.SSL_REQUEST); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgOutputPacket.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -30,9 +30,10 @@ { #region \xB7 Fields \xB7 - private MemoryStream stream; - private BinaryWriter packet; - private Encoding encoding; + private MemoryStream stream; + private BinaryWriter packet; + private Encoding encoding; + private PgTypeCollection dataTypes; #endregion @@ -52,16 +53,17 @@ #region \xB7 Constructors \xB7 - public PgOutputPacket() - : this(Encoding.Default) + public PgOutputPacket(PgTypeCollection dataTypes) + : this(dataTypes, Encoding.Default) { } - public PgOutputPacket(Encoding encoding) + public PgOutputPacket(PgTypeCollection dataTypes, Encoding encoding) { this.stream = new MemoryStream(); this.packet = new BinaryWriter(this.stream); this.encoding = encoding; + this.dataTypes = dataTypes; this.Write(new byte[0]); } @@ -271,11 +273,11 @@ System.Array array = (System.Array)parameter.Value; // Get array elements type info - PgType elementType = PgDatabase.DataTypes[parameter.DataType.ElementType]; + PgType elementType = this.dataTypes[parameter.DataType.ElementType]; size = elementType.Size; // Create a new packet for write array parameter information - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.dataTypes); // Write the number of dimensions packet.Write(array.Rank); @@ -318,7 +320,7 @@ public byte[] GetSimplePacketBytes() { - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.dataTypes); // Write packet contents packet.Write((int)(this.Length + 4)); @@ -329,7 +331,7 @@ public byte[] GetPacketBytes(char format) { - PgOutputPacket packet = new PgOutputPacket(); + PgOutputPacket packet = new PgOutputPacket(this.dataTypes); packet.Write((byte)format); packet.Write((int)(this.Length + 4)); @@ -378,10 +380,7 @@ case PgDataType.Char: case PgDataType.VarChar: case PgDataType.Text: - { - string paramValue = value.ToString() + PgCodes.NULL_TERMINATOR; - packet.WriteString(paramValue); - } + packet.WriteString(value.ToString()); break; case PgDataType.Int2: Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgParameter.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -57,18 +57,14 @@ } public PgParameter(int dataTypeOid) + : this(dataTypeOid, null) { - this.dataTypeOid = dataTypeOid; - - if (PgDatabase.DataTypes.Contains(dataTypeOid)) - { - this.dataType = PgDatabase.DataTypes[dataTypeOid]; - } } - public PgParameter(int dataType, object data) : this(dataType) + public PgParameter(int dataTypeOid, object data) { - this.data = data; + this.dataTypeOid = dataTypeOid; + this.data = data; } #endregion Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgResponsePacket.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -30,10 +30,11 @@ { #region \xB7 Fields \xB7 - private char message; - private Stream stream; - private BinaryReader packet; - private Encoding encoding; + private char message; + private Stream stream; + private BinaryReader packet; + private Encoding encoding; + private PgTypeCollection dataTypes; #endregion @@ -104,12 +105,13 @@ #region \xB7 Constructors \xB7 - public PgResponsePacket(char message, Encoding encoding, byte[] contents) + public PgResponsePacket(PgTypeCollection dataTypes, char message, Encoding encoding, byte[] contents) { - this.stream = new MemoryStream(contents); - this.packet = new BinaryReader(this.stream); - this.encoding = encoding; - this.message = message; + this.dataTypes = dataTypes; + this.stream = new MemoryStream(contents); + this.packet = new BinaryReader(this.stream); + this.encoding = encoding; + this.message = message; } #endregion @@ -283,7 +285,7 @@ } // Read array element type - PgType elementType = PgDatabase.DataTypes[this.ReadInt32()]; + PgType elementType = this.dataTypes[this.ReadInt32()]; // Read array lengths and lower bounds for (int i = 0; i < dimensions; i++) @@ -306,7 +308,7 @@ public Array ReadVector(PgType type, int length) { - PgType elementType = PgDatabase.DataTypes[type.ElementType]; + PgType elementType = this.dataTypes[type.ElementType]; Array data = null; data = Array.CreateInstance(elementType.SystemType, (length / elementType.Size)); @@ -563,6 +565,9 @@ case PgDataType.Box2D: return PgBox2D.Parse(stringValue); + case PgDataType.Box3D: + return PgBox3D.Parse(stringValue); + default: return this.packet.ReadBytes(length); } @@ -601,7 +606,7 @@ private Array ReadStringArray(PgType type, int length) { - PgType elementType = PgDatabase.DataTypes[type.ElementType]; + PgType elementType = this.dataTypes[type.ElementType]; Array data = null; string contents = this.ReadString(length); Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -182,7 +182,7 @@ this.rowDescriptor = new PgRowDescriptor(0); this.parameters = new PgParameter[0]; - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); packet.WriteNullString(this.ParseName); packet.WriteNullString(this.stmtText); @@ -225,7 +225,7 @@ string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); packet.Write((byte)stmtType); packet.WriteNullString(name); @@ -264,13 +264,13 @@ int baseTypeOid = Convert.ToInt32(stmt.FetchRow()[0]); - if (baseTypeOid == 0 || !PgDatabase.DataTypes.Contains(baseTypeOid)) + if (baseTypeOid == 0 || !this.db.DataTypes.Contains(baseTypeOid)) { throw new PgClientException("Unsupported data type"); } // Try to add the data type to the list of supported data types - parameter.DataType = PgDatabase.DataTypes[baseTypeOid]; + parameter.DataType = this.db.DataTypes[baseTypeOid]; } catch { @@ -301,7 +301,7 @@ // Update status this.status = PgStatementStatus.Binding; - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); // Destination portal name packet.WriteNullString(this.PortalName); @@ -355,7 +355,7 @@ // Update status this.status = PgStatementStatus.Executing; - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); packet.WriteNullString(this.PortalName); packet.Write(this.fetchSize); // Rows to retrieve ( 0 = nolimit ) @@ -413,7 +413,7 @@ // Update status this.status = PgStatementStatus.Executing; - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); // Function id packet.Write(id); @@ -471,7 +471,7 @@ // Update Status this.status = PgStatementStatus.OnQuery; - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); packet.WriteNullString(this.stmtText); @@ -576,7 +576,7 @@ { string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); - PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); packet.Write((byte)stmtType); packet.WriteNullString(String.IsNullOrEmpty(name) ? "" : name); @@ -747,7 +747,7 @@ this.rowDescriptor.Fields[i].FieldName = packet.ReadNullString(); this.rowDescriptor.Fields[i].OidTable = packet.ReadInt32(); this.rowDescriptor.Fields[i].OidNumber = packet.ReadInt16(); - this.rowDescriptor.Fields[i].DataType = PgDatabase.DataTypes[packet.ReadInt32()]; + this.rowDescriptor.Fields[i].DataType = this.db.DataTypes[packet.ReadInt32()]; this.rowDescriptor.Fields[i].DataTypeSize = packet.ReadInt16(); this.rowDescriptor.Fields[i].TypeModifier = packet.ReadInt32(); this.rowDescriptor.Fields[i].FormatCode = (PgTypeFormat)packet.ReadInt16(); @@ -760,7 +760,8 @@ for (int i = 0; i < parameters.Length; i++) { - this.parameters[i] = new PgParameter(packet.ReadInt32()); + this.parameters[i] = new PgParameter(packet.ReadInt32()); + this.parameters[i].DataType = this.db.DataTypes[this.parameters[i].DataTypeOid]; } } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -32,6 +32,7 @@ private PgTypeFormat formatCode; private int size; private string delimiter; + private string prefix; #endregion @@ -61,14 +62,12 @@ { get { - int type = elementType; + //while (PgDatabase.DataTypes[type].DataType == PgDataType.Array) + //{ + // type = PgDatabase.DataTypes[type].ElementType; + //} - while (PgDatabase.DataTypes[type].DataType == PgDataType.Array) - { - type = PgDatabase.DataTypes[type].ElementType; - } - - return type; + return this.elementType; } } @@ -144,6 +143,11 @@ get { return this.delimiter; } } + public string Prefix + { + get { return this.prefix; } + } + #endregion #region \xB7 Constructors \xB7 @@ -161,7 +165,20 @@ PgTypeFormat formatCode, int size, string delimiter) + : this(oid, name, dataType, elementType, formatCode, size, delimiter, "") { + } + + public PgType( + int oid, + string name, + PgDataType dataType, + int elementType, + PgTypeFormat formatCode, + int size, + string delimiter, + string prefix) + { this.oid = oid; this.name = name; this.dataType = dataType; @@ -170,6 +187,7 @@ this.size = size; this.systemType = this.InferSystemType(); this.delimiter = delimiter; + this.prefix = prefix; } #endregion Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs 2006-06-19 21:28:22 UTC (rev 171) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgTypeCollection.cs 2006-06-19 21:29:24 UTC (rev 172) @@ -114,6 +114,19 @@ return this.Add(new PgType(oid, name, dataType, elementType, formatCode, size, delimiter)); } + public PgType Add( + int oid, + string name, + PgDataType dataType, + int elementType, + PgTypeFormat formatCode, + int size, + string delimiter, + string prefix) + { + return this.Add(new PgType(oid, name, dataType, elementType, formatCode, size, delimiter, prefix)); + } + #endregion #region \xB7 Private Methods \xB7 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <car...@us...> - 2006-06-26 16:01:56
|
Revision: 176 Author: carlosga_fb Date: 2006-06-26 09:01:45 -0700 (Mon, 26 Jun 2006) ViewCVS: http://svn.sourceforge.net/pgsqlclient/?rev=176&view=rev Log Message: ----------- Changes on internal data type handling Modified Paths: -------------- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgConnectionOptions.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgConnectionOptions.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgConnectionOptions.cs 2006-06-26 16:00:41 UTC (rev 175) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgConnectionOptions.cs 2006-06-26 16:01:45 UTC (rev 176) @@ -25,18 +25,19 @@ { #region \xB7 Fields \xB7 - private string dataSource; - private string database; - private string userID; - private string password; - private int portNumber; - private int packetSize; - private int connectionTimeout; - private long connectionLifetime; - private int minPoolSize; - private int maxPoolSize; - private bool pooling; - private bool ssl; + private string dataSource; + private string database; + private string userID; + private string password; + private int portNumber; + private int packetSize; + private int connectionTimeout; + private long connectionLifetime; + private int minPoolSize; + private int maxPoolSize; + private bool pooling; + private bool ssl; + private bool useDatabaseOids; #endregion @@ -103,6 +104,11 @@ get { return this.ssl; } } + public bool UseDatabaseOids + { + get { return this.useDatabaseOids; } + } + #endregion #region \xB7 Constructors \xB7 @@ -135,6 +141,7 @@ this.minPoolSize = 0; this.maxPoolSize = 100; this.ssl = false; + this.useDatabaseOids = false; } private void ParseConnectionString(string connectionString) @@ -201,6 +208,10 @@ case "ssl": this.ssl = Boolean.Parse(element.Groups[2].Value.Trim()); break; + + case "use database oids": + this.useDatabaseOids = Boolean.Parse(element.Groups[2].Value.Trim()); + break; } } } Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-06-26 16:00:41 UTC (rev 175) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgDatabase.cs 2006-06-26 16:01:45 UTC (rev 176) @@ -101,7 +101,7 @@ dataTypes.Add(1700 , "numeric" , PgDataType.Decimal , 0, PgTypeFormat.Text, 8); dataTypes.Add(1790 , "refcursor" , PgDataType.Refcursor , 0, PgTypeFormat.Text, 0); dataTypes.Add(2205 , "regclass" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); - dataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); + //dataTypes.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); // PostGIS datatypes dataTypes.Add(17321 , "box3d" , PgDataType.Box3D , 0, PgTypeFormat.Text, 48, ",", "BOX3D"); @@ -338,12 +338,6 @@ this.ProcessResponsePacket(response); } while (!response.IsReadyForQuery); - - // After the connection gets established we should update the Data Types collection oids - foreach (PgType type in this.DataTypes) - { -#warning "Complete this" - } } } catch (IOException ex) Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-06-26 16:00:41 UTC (rev 175) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgStatement.cs 2006-06-26 16:01:45 UTC (rev 176) @@ -151,6 +151,8 @@ this.outParameter = new PgParameter(); this.rows = null; this.rowIndex = 0; + this.hasRows = false; + this.allRowsFetched = false; this.parseName = parseName; this.portalName = portalName; this.recordsAffected = -1; @@ -175,8 +177,10 @@ this.status = PgStatementStatus.Parsing; // Clear actual row list - this.rows = null; - this.rowIndex = 0; + this.rows = null; + this.rowIndex = 0; + this.hasRows = false; + this.allRowsFetched = false; // Initialize RowDescriptor and Parameters this.rowDescriptor = new PgRowDescriptor(0); @@ -301,6 +305,12 @@ // Update status this.status = PgStatementStatus.Binding; + // Clear actual row list + this.rows = null; + this.rowIndex = 0; + this.hasRows = false; + this.allRowsFetched = false; + PgOutputPacket packet = new PgOutputPacket(this.db.DataTypes, this.db.Encoding); // Destination portal name Modified: trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs =================================================================== --- trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-06-26 16:00:41 UTC (rev 175) +++ trunk/PostgreSqlClient/source/PostgreSql/Data/Protocol/PgType.cs 2006-06-26 16:01:45 UTC (rev 176) @@ -60,15 +60,7 @@ public int ElementType { - get - { - //while (PgDatabase.DataTypes[type].DataType == PgDataType.Array) - //{ - // type = PgDatabase.DataTypes[type].ElementType; - //} - - return this.elementType; - } + get { return this.elementType; } } public PgTypeFormat FormatCode @@ -192,9 +184,18 @@ #endregion - #region \xB7 Private Methods \xB7 + #region \xB7 Internal Methods \xB7 - private Type InferSystemType() + internal void UpdateOid(int newOid) + { + this.oid = newOid; + } + + #endregion + + #region \xB7 Private Methods \xB7 + + private Type InferSystemType() { switch (this.dataType) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |