[pgsqlclient-checkins] SF.net SVN: pgsqlclient: [172] trunk/PostgreSqlClient/source/PostgreSql/Data
Status: Inactive
Brought to you by:
carlosga_fb
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. |