[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgCodes.cs,1.3,1.
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos G. Á. <car...@us...> - 2004-07-20 18:41:54
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31634 Modified Files: PgCodes.cs PgDbClient.cs PgFieldDescriptor.cs PgOutputPacket.cs PgResponsePacket.cs PgStatement.cs PgType.cs PgTypeCollection.cs Log Message: Prepare for beta 7 Index: PgResponsePacket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgResponsePacket.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PgResponsePacket.cs 3 Jun 2004 16:37:20 -0000 1.26 --- PgResponsePacket.cs 20 Jul 2004 18:41:43 -0000 1.27 *************** *** 139,143 **** } ! public override string ReadString() { int length = this.ReadInt(); --- 139,143 ---- } ! public new string ReadString() { int length = this.ReadInt(); *************** *** 175,185 **** { return BitConverter.ToSingle(BitConverter.GetBytes(this.ReadInt()), 0); - - /* - FloatLayout floatValue = new FloatLayout(); - floatValue.i0 = IPAddress.HostToNetworkOrder(base.ReadInt32()); - - return floatValue.f; - */ } --- 175,178 ---- *************** *** 193,212 **** public override double ReadDouble() { ! return BitConverter.ToDouble(BitConverter.GetBytes(this.ReadLong()), 0); ! ! /* ! DoubleLayout doubleValue = new DoubleLayout(); ! int temp; ! ! doubleValue.d = base.ReadDouble(); ! doubleValue.i0 = IPAddress.HostToNetworkOrder(doubleValue.i0); ! doubleValue.i4 = IPAddress.HostToNetworkOrder(doubleValue.i4); ! ! temp = doubleValue.i0; ! doubleValue.i0 = doubleValue.i4; ! doubleValue.i4 = temp; ! ! return doubleValue.d; ! */ } --- 186,192 ---- public override double ReadDouble() { ! byte[] buffer = BitConverter.GetBytes(this.ReadLong()); ! ! return BitConverter.ToDouble(buffer, 0); } *************** *** 234,294 **** } ! public DateTime ReadTime() { ! double seconds = this.ReadDouble(); ! ! return PgCodes.BASE_DATE.AddSeconds(seconds); } ! public DateTime ReadTimeWithTZ() { ! DateTime time = this.ReadTime(); ! int timezone = (-1)*(this.ReadInt()/3600); ! ! string sbFormat = "{0:D2}{1}{2:D2}{3}{4:D2}{5:D2}"; ! ! if (timezone >= 0) ! { ! sbFormat = "{0:D2}{1}{2:D2}{3}{4:D2}+{5:D2}"; ! } ! ! StringBuilder timeWithTZ = new StringBuilder(); ! timeWithTZ.AppendFormat( ! sbFormat, ! time.Hour, ! CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator, ! time.Minute, ! CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator, ! time.Second, ! timezone); ! ! StringBuilder format = new StringBuilder(); ! format.AppendFormat( ! "{0}{1}{2}{3}{4}{5}", ! "HH", ! CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator, ! "mm", ! CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator, ! "ss", ! "zz"); ! ! return DateTime.ParseExact( ! timeWithTZ.ToString(), ! format.ToString(), ! CultureInfo.CurrentCulture.DateTimeFormat, ! DateTimeStyles.NoCurrentDateDefault | ! DateTimeStyles.AllowWhiteSpaces); } ! public DateTime ReadTimestamp() ! { ! double seconds = this.ReadDouble(); ! ! return PgCodes.BASE_DATE.AddSeconds(seconds); } ! public DateTime ReadTimestampWithTZ() ! { ! return this.ReadTimestamp(); } --- 214,235 ---- } ! public DateTime ReadTime(int length) { ! return DateTime.Parse(this.ReadString(length)); } ! public DateTime ReadTimeWithTZ(int length) { ! return DateTime.Parse(this.ReadString(length)); } ! public DateTime ReadTimestamp(int length) ! { ! return DateTime.Parse(this.ReadString(length)); } ! public DateTime ReadTimestampWithTZ(int length) ! { ! return DateTime.Parse(this.ReadString(length)); } *************** *** 476,494 **** case PgDataType.Date: ! return this.ReadDate(); case PgDataType.Time: ! return this.ReadTime(); case PgDataType.TimeWithTZ: ! return this.ReadTimeWithTZ(); ! case PgDataType.Timestamp: ! return this.ReadTimestamp(); ! case PgDataType.TimestampWithTZ: ! return this.ReadTimestampWithTZ(); ! case PgDataType.Point: return this.ReadPoint(); --- 417,435 ---- case PgDataType.Date: ! return this.ReadDate(); case PgDataType.Time: ! return this.ReadTime(length); case PgDataType.TimeWithTZ: ! return this.ReadTimeWithTZ(length); ! case PgDataType.Timestamp: ! return this.ReadTimestamp(length); ! case PgDataType.TimestampWithTZ: ! return this.ReadTimestampWithTZ(length); ! case PgDataType.Point: return this.ReadPoint(); Index: PgTypeCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgTypeCollection.cs,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PgTypeCollection.cs 10 Apr 2004 20:16:07 -0000 1.10 --- PgTypeCollection.cs 20 Jul 2004 18:41:43 -0000 1.11 *************** *** 99,103 **** } ! public PgType Add(int oid, string name, PgDataType dataType, int elementType, short formatCode, int size) { PgType type = new PgType(oid, name, dataType, elementType, formatCode, size); --- 99,103 ---- } ! public PgType Add(int oid, string name, PgDataType dataType, int elementType, PgTypeFormat formatCode, int size) { PgType type = new PgType(oid, name, dataType, elementType, formatCode, size); Index: PgType.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgType.cs,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PgType.cs 10 Apr 2004 20:16:07 -0000 1.12 --- PgType.cs 20 Jul 2004 18:41:43 -0000 1.13 *************** *** 22,36 **** namespace PostgreSql.Data.NPgClient { internal class PgType { #region Fields ! private int oid; ! private string name; ! private PgDataType dataType; ! private Type systemType; ! private int elementType; ! private short formatCode; ! private int size; #endregion --- 22,42 ---- namespace PostgreSql.Data.NPgClient { + internal enum PgTypeFormat : short + { + Text = 0, + Binary = 1 + } + internal class PgType { #region Fields ! private int oid; ! private string name; ! private PgDataType dataType; ! private Type systemType; ! private int elementType; ! private PgTypeFormat formatCode; ! private int size; #endregion *************** *** 73,77 **** } ! public short FormatCode { get { return this.formatCode; } --- 79,83 ---- } ! public PgTypeFormat FormatCode { get { return this.formatCode; } *************** *** 87,91 **** #region Constructors ! public PgType(int oid, string name, PgDataType dataType, int elementType, short formatCode, int size) { this.oid = oid; --- 93,97 ---- #region Constructors ! public PgType(int oid, string name, PgDataType dataType, int elementType, PgTypeFormat formatCode, int size) { this.oid = oid; Index: PgFieldDescriptor.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgFieldDescriptor.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgFieldDescriptor.cs 10 Apr 2004 20:16:07 -0000 1.4 --- PgFieldDescriptor.cs 20 Jul 2004 18:41:43 -0000 1.5 *************** *** 25,35 **** #region Fields ! private string fieldName; ! private int oidTable; ! private short oidNumber; ! private PgType dataType; ! private short dataTypeSize; ! private int typeModifier; ! private short formatCode; #endregion --- 25,35 ---- #region Fields ! private string fieldName; ! private int oidTable; ! private short oidNumber; ! private PgType dataType; ! private short dataTypeSize; ! private int typeModifier; ! private PgTypeFormat formatCode; #endregion *************** *** 73,77 **** } ! public short FormatCode { get { return this.formatCode; } --- 73,77 ---- } ! public PgTypeFormat FormatCode { get { return this.formatCode; } Index: PgDbClient.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** PgDbClient.cs 31 May 2004 17:19:55 -0000 1.49 --- PgDbClient.cs 20 Jul 2004 18:41:43 -0000 1.50 *************** *** 23,29 **** using System.Text; using System.Net; using System.Net.Sockets; ! using Tls=Mono.Security.Protocol.Tls; using Mono.Security.Protocol.Tls; --- 23,30 ---- using System.Text; using System.Net; + using System.Net.Security; using System.Net.Sockets; ! using Mono.Security.Cryptography; using Mono.Security.Protocol.Tls; *************** *** 167,170 **** --- 168,287 ---- #endregion + #region Static Methods + + public static void InitializeTypes() + { + if (types != null) + { + return; + } + + types = new PgTypeCollection(); + + types.Add(16 , "bool" , PgDataType.Boolean , 0, PgTypeFormat.Binary, 1); + types.Add(17 , "bytea" , PgDataType.Binary , 0, PgTypeFormat.Binary, 0); + types.Add(18 , "char" , PgDataType.Char , 0, PgTypeFormat.Text, 0); + types.Add(19 , "name" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(20 , "int8" , PgDataType.Int8 , 0, PgTypeFormat.Binary, 8); + types.Add(21 , "int2" , PgDataType.Int2 , 0, PgTypeFormat.Binary, 2); + types.Add(22 , "int2vector" , PgDataType.Vector , 21, PgTypeFormat.Binary, 2); + types.Add(23 , "int4" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); + types.Add(24 , "regproc" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(25 , "text" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(26 , "oid" , PgDataType.Int4 , 0, PgTypeFormat.Binary, 4); + types.Add(30 , "oidvector" , PgDataType.Vector , 26, PgTypeFormat.Binary, 4); + types.Add(600 , "point" , PgDataType.Point , 701, PgTypeFormat.Binary, 16); + types.Add(601 , "lseg" , PgDataType.LSeg , 600, PgTypeFormat.Binary, 32); + types.Add(602 , "path" , PgDataType.Path , 0, PgTypeFormat.Binary, 16); + types.Add(603 , "box" , PgDataType.Box , 600, PgTypeFormat.Binary, 32); + types.Add(604 , "polygon" , PgDataType.Polygon , 0, PgTypeFormat.Binary, 16); + types.Add(628 , "line" , PgDataType.Line , 701, PgTypeFormat.Binary, 32); + types.Add(629 , "_line" , PgDataType.Array , 628, PgTypeFormat.Binary, 32); + types.Add(718 , "circle" , PgDataType.Circle , 0, PgTypeFormat.Binary, 24); + types.Add(719 , "_circle" , PgDataType.Array , 718, PgTypeFormat.Binary, 24); + types.Add(700 , "float4" , PgDataType.Float , 0, PgTypeFormat.Binary, 4); + types.Add(701 , "float8" , PgDataType.Double , 0, PgTypeFormat.Binary, 8); + types.Add(705 , "unknown" , PgDataType.Binary , 0, PgTypeFormat.Binary, 0); + types.Add(790 , "money" , PgDataType.Currency , 0, PgTypeFormat.Binary, 4); + types.Add(829 , "macaddr" , PgDataType.VarChar , 0, PgTypeFormat.Text, 6); + types.Add(869 , "inet" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(1000 , "_bool" , PgDataType.Array , 16, PgTypeFormat.Binary, 1); + types.Add(1005 , "_int2" , PgDataType.Array , 21, PgTypeFormat.Binary, 2); + types.Add(1007 , "_int4" , PgDataType.Array , 23, PgTypeFormat.Binary, 4); + types.Add(1009 , "_text" , PgDataType.Array , 25, PgTypeFormat.Binary, 0); + types.Add(1016 , "_int8" , PgDataType.Array , 20, PgTypeFormat.Binary, 8); + types.Add(1017 , "_point" , PgDataType.Array , 600, PgTypeFormat.Binary, 16); + types.Add(1018 , "_lseg" , PgDataType.Array , 601, PgTypeFormat.Binary, 32); + types.Add(1019 , "_path" , PgDataType.Array , 602, PgTypeFormat.Binary, -1); + types.Add(1020 , "_box" , PgDataType.Array , 603, PgTypeFormat.Binary, 32); + types.Add(1021 , "_float4" , PgDataType.Array , 700, PgTypeFormat.Binary, 4); + types.Add(1027 , "_polygon" , PgDataType.Array , 604, PgTypeFormat.Binary, 16); + types.Add(1033 , "aclitem" , PgDataType.VarChar , 0, PgTypeFormat.Text, 12); + types.Add(1034 , "_aclitem" , PgDataType.Array , 1033, PgTypeFormat.Text, 0); + types.Add(1042 , "bpchar" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(1043 , "varchar" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(1082 , "date" , PgDataType.Date , 0, PgTypeFormat.Binary, 4); + types.Add(1083 , "time" , PgDataType.Time , 0, PgTypeFormat.Text, 8); + types.Add(1114 , "timestamp" , PgDataType.Timestamp , 0, PgTypeFormat.Text, 8); + types.Add(1184 , "timestamptz" , PgDataType.TimestampWithTZ, 0, PgTypeFormat.Binary, 8); + types.Add(1186 , "interval" , PgDataType.Interval , 0, PgTypeFormat.Binary, 12); + types.Add(1266 , "timetz" , PgDataType.TimeWithTZ , 0, PgTypeFormat.Binary, 12); + types.Add(1560 , "bit" , PgDataType.Byte , 0, PgTypeFormat.Text, 1); + types.Add(1562 , "varbit" , PgDataType.Byte , 0, PgTypeFormat.Binary, 0); + types.Add(1700 , "numeric" , PgDataType.Decimal , 0, PgTypeFormat.Text, 8); + types.Add(1790 , "refcursor" , PgDataType.VarChar , 0, PgTypeFormat.Text, 0); + types.Add(2277 , "anyarray" , PgDataType.Array , 0, PgTypeFormat.Binary, 8); + } + + public static void InitializeCharSets() + { + if (charSets != null) + { + return; + } + + charSets = new PgCharSetCollection(); + + PgDbClient.addCharset("SQL_ASCII" , "ascii"); // ASCII + PgDbClient.addCharset("EUC_JP" , "euc-jp"); // Japanese EUC + PgDbClient.addCharset("EUC_CN" , "euc-cn"); // Chinese EUC + PgDbClient.addCharset("UNICODE" , "UTF-8"); // Unicode (UTF-8) + PgDbClient.addCharset("LATIN1" , "iso-8859-1"); // ISO 8859-1/ECMA 94 (Latin alphabet no.1) + PgDbClient.addCharset("LATIN2" , "iso-8859-2"); // ISO 8859-2/ECMA 94 (Latin alphabet no.2) + PgDbClient.addCharset("LATIN4" , 1257); // ISO 8859-4/ECMA 94 (Latin alphabet no.4) + PgDbClient.addCharset("ISO_8859_7" , 1253); // ISO 8859-7/ECMA 118 (Latin/Greek) + PgDbClient.addCharset("LATIN9" , "iso-8859-15"); // ISO 8859-15 (Latin alphabet no.9) + PgDbClient.addCharset("KOI8" , "koi8-r"); // KOI8-R(U) + PgDbClient.addCharset("WIN" , "windows-1251"); // Windows CP1251 + PgDbClient.addCharset("WIN1256" , "windows-1256"); // Windows CP1256 (Arabic) + PgDbClient.addCharset("WIN1256" , "windows-1256"); // Windows CP1256 (Arabic) + PgDbClient.addCharset("WIN1256" , "windows-1258"); // TCVN-5712/Windows CP1258 (Vietnamese) + PgDbClient.addCharset("WIN1256" , "windows-874"); // Windows CP874 (Thai) + } + + private static void addCharset(string charset, string systemCharset) + { + try + { + charSets.Add(charset, systemCharset); + } + catch (Exception) + { + } + } + + private static void addCharset(string charset, int cp) + { + try + { + charSets.Add(charset, cp); + } + catch (Exception) + { + } + } + + #endregion + #region Database Methods *************** *** 189,201 **** this.sslStream = new SslClientStream( this.networkStream, ! this.settings.ServerName, ! true, ! Tls.SecurityProtocolType.Tls| ! Tls.SecurityProtocolType.Ssl3); ! this.receive = new BinaryReader(this.sslStream); this.send = new BinaryWriter(this.sslStream); ! if (this.SslConnection != null) { this.SslConnection(); --- 306,318 ---- this.sslStream = new SslClientStream( this.networkStream, ! this.settings.ServerName, ! false, ! Mono.Security.Protocol.Tls.SecurityProtocolType.Tls| ! Mono.Security.Protocol.Tls.SecurityProtocolType.Ssl3); ! this.receive = new BinaryReader(this.sslStream); this.send = new BinaryWriter(this.sslStream); ! if (this.SslConnection != null) { this.SslConnection(); *************** *** 208,219 **** packet.WriteInt(PgCodes.PROTOCOL_VERSION3); ! packet.WriteString("user"); ! packet.WriteString(this.settings.UserName); if (settings.Database != null && this.settings.Database.Length > 0) { ! packet.WriteString("database"); ! packet.WriteString(this.settings.Database); } packet.Write((byte)0); // Terminator --- 325,338 ---- packet.WriteInt(PgCodes.PROTOCOL_VERSION3); ! packet.WriteNullString("user"); ! packet.WriteNullString(this.settings.UserName); if (settings.Database != null && this.settings.Database.Length > 0) { ! packet.WriteNullString("database"); ! packet.WriteNullString(this.settings.Database); } + packet.WriteNullString("DateStyle"); + packet.WriteNullString(PgCodes.DATE_STYLE); packet.Write((byte)0); // Terminator *************** *** 416,424 **** case PgCodes.AUTH_KERBEROS_V5: // Kerberos V5 authentication is required ! break; case PgCodes.AUTH_CLEARTEXT_PASSWORD: // Cleartext password is required ! outPacket.WriteString(settings.UserPassword); break; --- 535,543 ---- case PgCodes.AUTH_KERBEROS_V5: // Kerberos V5 authentication is required ! break; case PgCodes.AUTH_CLEARTEXT_PASSWORD: // Cleartext password is required ! outPacket.WriteNullString(settings.UserPassword); break; *************** *** 442,446 **** // Finally write the md5 hash to the packet ! outPacket.WriteString(PgCodes.MD5_PREFIX + hash); break; --- 561,565 ---- // Finally write the md5 hash to the packet ! outPacket.WriteNullString(PgCodes.MD5_PREFIX + hash); break; *************** *** 703,822 **** #endregion - #region Static Methods - - public static void InitializeTypes() - { - if (types != null) - { - return; - } - - types = new PgTypeCollection(); - - types.Add(16 , "bool" , PgDataType.Boolean , 0, 1, 1); - types.Add(17 , "bytea" , PgDataType.Binary , 0, 1, 0); - types.Add(18 , "char" , PgDataType.Char , 0, 0, 0); - types.Add(19 , "name" , PgDataType.VarChar , 0, 0, 0); - types.Add(20 , "int8" , PgDataType.Int8 , 0, 1, 8); - types.Add(21 , "int2" , PgDataType.Int2 , 0, 1, 2); - types.Add(22 , "int2vector" , PgDataType.Vector , 21, 1, 2); - types.Add(23 , "int4" , PgDataType.Int4 , 0, 1, 4); - types.Add(24 , "regproc" , PgDataType.VarChar , 0, 0, 0); - types.Add(25 , "text" , PgDataType.VarChar , 0, 0, 0); - types.Add(26 , "oid" , PgDataType.Int4 , 0, 1, 4); - types.Add(30 , "oidvector" , PgDataType.Vector , 26, 1, 4); - types.Add(600 , "point" , PgDataType.Point , 701, 1, 16); - types.Add(601 , "lseg" , PgDataType.LSeg , 600, 1, 32); - types.Add(602 , "path" , PgDataType.Path , 0, 1, 16); - types.Add(603 , "box" , PgDataType.Box , 600, 1, 32); - types.Add(604 , "polygon" , PgDataType.Polygon , 0, 1, 16); - types.Add(628 , "line" , PgDataType.Line , 701, 1, 32); - types.Add(629 , "_line" , PgDataType.Array , 628, 1, 32); - types.Add(718 , "circle" , PgDataType.Circle , 0, 1, 24); - types.Add(719 , "_circle" , PgDataType.Array , 718, 1, 24); - types.Add(700 , "float4" , PgDataType.Float , 0, 1, 4); - types.Add(701 , "float8" , PgDataType.Double , 0, 1, 8); - types.Add(705 , "unknown" , PgDataType.Binary , 0, 1, 0); - types.Add(790 , "money" , PgDataType.Currency , 0, 1, 4); - types.Add(829 , "macaddr" , PgDataType.VarChar , 0, 0, 6); - types.Add(869 , "inet" , PgDataType.VarChar , 0, 0, 0); - types.Add(1000 , "_bool" , PgDataType.Array , 16, 1, 1); - types.Add(1005 , "_int2" , PgDataType.Array , 21, 1, 2); - types.Add(1007 , "_int4" , PgDataType.Array , 23, 1, 4); - types.Add(1009 , "_text" , PgDataType.Array , 25, 1, 0); - types.Add(1016 , "_int8" , PgDataType.Array , 20, 1, 8); - types.Add(1017 , "_point" , PgDataType.Array , 600, 1, 16); - types.Add(1018 , "_lseg" , PgDataType.Array , 601, 1, 32); - types.Add(1019 , "_path" , PgDataType.Array , 602, 1, -1); - types.Add(1020 , "_box" , PgDataType.Array , 603, 1, 32); - types.Add(1021 , "_float4" , PgDataType.Array , 700, 1, 4); - types.Add(1027 , "_polygon" , PgDataType.Array , 604, 1, 16); - types.Add(1033 , "aclitem" , PgDataType.VarChar , 0, 0, 12); - types.Add(1034 , "_aclitem" , PgDataType.Array , 1033, 0, 0); - types.Add(1042 , "bpchar" , PgDataType.VarChar , 0, 0, 0); - types.Add(1043 , "varchar" , PgDataType.VarChar , 0, 0, 0); - types.Add(1082 , "date" , PgDataType.Date , 0, 1, 4); - types.Add(1083 , "time" , PgDataType.Time , 0, 1, 8); - types.Add(1114 , "timestamp" , PgDataType.Timestamp , 0, 1, 8); - types.Add(1184 , "timestamptz" , PgDataType.TimestampWithTZ, 0, 1, 8); - types.Add(1186 , "interval" , PgDataType.Interval , 0, 1, 12); - types.Add(1266 , "timetz" , PgDataType.TimeWithTZ , 0, 1, 12); - types.Add(1560 , "bit" , PgDataType.Byte , 0, 0, 1); - types.Add(1562 , "varbit" , PgDataType.Byte , 0, 1, 0); - types.Add(1700 , "numeric" , PgDataType.Decimal , 0, 0, 8); - types.Add(1790 , "refcursor" , PgDataType.VarChar , 0, 0, 0); - types.Add(2277 , "anyarray" , PgDataType.Array , 0, 1, 8); - } - - public static void InitializeCharSets() - { - if (charSets != null) - { - return; - } - - charSets = new PgCharSetCollection(); - - PgDbClient.addCharset("SQL_ASCII" , "ascii"); // ASCII - PgDbClient.addCharset("EUC_JP" , "euc-jp"); // Japanese EUC - PgDbClient.addCharset("EUC_CN" , "euc-cn"); // Chinese EUC - PgDbClient.addCharset("UNICODE" , "UTF-8"); // Unicode (UTF-8) - PgDbClient.addCharset("LATIN1" , "iso-8859-1"); // ISO 8859-1/ECMA 94 (Latin alphabet no.1) - PgDbClient.addCharset("LATIN2" , "iso-8859-2"); // ISO 8859-2/ECMA 94 (Latin alphabet no.2) - PgDbClient.addCharset("LATIN4" , 1257); // ISO 8859-4/ECMA 94 (Latin alphabet no.4) - PgDbClient.addCharset("ISO_8859_7" , 1253); // ISO 8859-7/ECMA 118 (Latin/Greek) - PgDbClient.addCharset("LATIN9" , "iso-8859-15"); // ISO 8859-15 (Latin alphabet no.9) - PgDbClient.addCharset("KOI8" , "koi8-r"); // KOI8-R(U) - PgDbClient.addCharset("WIN" , "windows-1251"); // Windows CP1251 - PgDbClient.addCharset("WIN1256" , "windows-1256"); // Windows CP1256 (Arabic) - PgDbClient.addCharset("WIN1256" , "windows-1256"); // Windows CP1256 (Arabic) - PgDbClient.addCharset("WIN1256" , "windows-1258"); // TCVN-5712/Windows CP1258 (Vietnamese) - PgDbClient.addCharset("WIN1256" , "windows-874"); // Windows CP874 (Thai) - } - - private static void addCharset(string charset, string systemCharset) - { - try - { - charSets.Add(charset, systemCharset); - } - catch (Exception) - { - } - } - - private static void addCharset(string charset, int cp) - { - try - { - charSets.Add(charset, cp); - } - catch (Exception) - { - } - } - - #endregion - #region Methods --- 822,825 ---- Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** PgStatement.cs 10 Apr 2004 20:16:07 -0000 1.24 --- PgStatement.cs 20 Jul 2004 18:41:43 -0000 1.25 *************** *** 198,203 **** PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteString(this.ParseName); ! packet.WriteString(this.stmtText); packet.WriteShort(0); --- 198,203 ---- PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteNullString(this.ParseName); ! packet.WriteNullString(this.stmtText); packet.WriteShort(0); *************** *** 239,243 **** packet.Write((byte)stmtType); ! packet.WriteString(name); // Send packet to the server --- 239,243 ---- packet.Write((byte)stmtType); ! packet.WriteNullString(name); // Send packet to the server *************** *** 278,284 **** // Destination portal name ! packet.WriteString(this.PortalName); // Prepared statement name ! packet.WriteString(this.ParseName); // Send parameters format code. --- 278,284 ---- // Destination portal name ! packet.WriteNullString(this.PortalName); // Prepared statement name ! packet.WriteNullString(this.ParseName); // Send parameters format code. *************** *** 286,290 **** for (int i = 0; i < parameters.Length; i++) { ! packet.WriteShort(this.parameters[i].DataType.FormatCode); } --- 286,290 ---- for (int i = 0; i < parameters.Length; i++) { ! packet.WriteShort((short)this.parameters[i].DataType.FormatCode); } *************** *** 300,304 **** for (int i = 0; i < this.rowDescriptor.Fields.Length; i++) { ! packet.WriteShort(this.rowDescriptor.Fields[i].DataType.FormatCode); } --- 300,304 ---- for (int i = 0; i < this.rowDescriptor.Fields.Length; i++) { ! packet.WriteShort((short)this.rowDescriptor.Fields[i].DataType.FormatCode); } *************** *** 327,331 **** PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteString(this.PortalName); packet.WriteInt(this.fetchSize); // Rows to retrieve ( 0 = nolimit ) --- 327,331 ---- PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteNullString(this.PortalName); packet.WriteInt(this.fetchSize); // Rows to retrieve ( 0 = nolimit ) *************** *** 393,397 **** for (int i = 0; i < this.parameters.Length; i++) { ! packet.WriteShort(this.parameters[i].DataType.FormatCode); } --- 393,397 ---- for (int i = 0; i < this.parameters.Length; i++) { ! packet.WriteShort((short)this.parameters[i].DataType.FormatCode); } *************** *** 440,444 **** PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteString(this.stmtText); // Send packet to the server --- 440,444 ---- PgOutputPacket packet = new PgOutputPacket(this.db.Settings.Encoding); ! packet.WriteNullString(this.stmtText); // Send packet to the server *************** *** 549,553 **** packet.Write((byte)stmtType); ! packet.WriteString(name); // Send packet to the server --- 549,553 ---- packet.Write((byte)stmtType); ! packet.WriteNullString(name); // Send packet to the server *************** *** 718,722 **** this.rowDescriptor.Fields[i].DataTypeSize = packet.ReadShort(); this.rowDescriptor.Fields[i].TypeModifier = packet.ReadInt(); ! this.rowDescriptor.Fields[i].FormatCode = packet.ReadShort(); } } --- 718,722 ---- this.rowDescriptor.Fields[i].DataTypeSize = packet.ReadShort(); this.rowDescriptor.Fields[i].TypeModifier = packet.ReadInt(); ! this.rowDescriptor.Fields[i].FormatCode = (PgTypeFormat)packet.ReadShort(); } } *************** *** 742,746 **** this.rowIndex = 0; } ! for (int i = 0; i < values.Length; i++) { --- 742,746 ---- this.rowIndex = 0; } ! for (int i = 0; i < values.Length; i++) { Index: PgOutputPacket.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgOutputPacket.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PgOutputPacket.cs 3 Jun 2004 16:37:20 -0000 1.26 --- PgOutputPacket.cs 20 Jul 2004 18:41:43 -0000 1.27 *************** *** 68,72 **** #region String Types ! public void WriteString(string data) { if (!data.EndsWith(PgCodes.NULL_TERMINATOR.ToString())) --- 68,72 ---- #region String Types ! public void WriteNullString(string data) { if (!data.EndsWith(PgCodes.NULL_TERMINATOR.ToString())) *************** *** 78,81 **** --- 78,87 ---- } + public void WriteString(string data) + { + this.WriteInt(data.Length); + this.Write(this.encoding.GetBytes(data)); + } + #endregion *************** *** 133,176 **** public void WriteTime(DateTime time) { ! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year, ! PgCodes.BASE_DATE.Month, ! PgCodes.BASE_DATE.Day, ! time.Hour, ! time.Minute, ! time.Second, ! time.Millisecond); ! ! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE); ! ! this.WriteDouble(seconds.TotalSeconds); ! } public void WriteTimeWithTZ(DateTime time) { ! DateTime realTime = new DateTime(PgCodes.BASE_DATE.Year, ! PgCodes.BASE_DATE.Month, ! PgCodes.BASE_DATE.Day, ! time.Hour, ! time.Minute, ! time.Second, ! time.Millisecond); ! ! TimeSpan seconds = realTime.Subtract(PgCodes.BASE_DATE); ! ! this.WriteDouble(seconds.TotalSeconds); ! this.WriteInt((-1)*Int32.Parse(time.ToString("zz"))*3600); ! } public void WriteTimestamp(DateTime timestamp) { ! TimeSpan days = timestamp.Subtract(PgCodes.BASE_DATE); ! ! this.WriteDouble(days.TotalSeconds); ! } public void WriteTimestampWithTZ(DateTime timestamp) { ! this.WriteTimestamp(timestamp); ! } #endregion --- 139,159 ---- public void WriteTime(DateTime time) { ! this.WriteString(time.ToString("HH:mm:ss.fff")); ! } public void WriteTimeWithTZ(DateTime time) { ! this.WriteString(time.ToString("HH:mm:ss.fff zz")); ! } public void WriteTimestamp(DateTime timestamp) { ! this.WriteString(timestamp.ToString("yyyy/MM/dd HH:mm:ss.fff")); ! } public void WriteTimestampWithTZ(DateTime timestamp) { ! this.WriteString(timestamp.ToString("yyyy/MM/dd HH:mm:ss.fff zz")); ! } #endregion *************** *** 359,378 **** case PgDataType.Time: ! packet.WriteInt(size); packet.WriteTime(Convert.ToDateTime(value)); break; case PgDataType.TimeWithTZ: ! packet.WriteInt(size); packet.WriteTimeWithTZ(Convert.ToDateTime(value)); break; case PgDataType.Timestamp: ! packet.WriteInt(size); packet.WriteTimestamp(Convert.ToDateTime(value)); break; case PgDataType.TimestampWithTZ: ! packet.WriteInt(size); packet.WriteTimestampWithTZ(Convert.ToDateTime(value)); break; --- 342,361 ---- case PgDataType.Time: ! // packet.WriteInt(size); packet.WriteTime(Convert.ToDateTime(value)); break; case PgDataType.TimeWithTZ: ! // packet.WriteInt(size); packet.WriteTimeWithTZ(Convert.ToDateTime(value)); break; case PgDataType.Timestamp: ! // packet.WriteInt(size); packet.WriteTimestamp(Convert.ToDateTime(value)); break; case PgDataType.TimestampWithTZ: ! // packet.WriteInt(size); packet.WriteTimestampWithTZ(Convert.ToDateTime(value)); break; *************** *** 382,386 **** { string paramValue = value.ToString() + PgCodes.NULL_TERMINATOR; - packet.WriteInt(encoding.GetByteCount(paramValue)); packet.WriteString(paramValue); } --- 365,368 ---- Index: PgCodes.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgCodes.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PgCodes.cs 9 Feb 2004 14:20:45 -0000 1.3 --- PgCodes.cs 20 Jul 2004 18:41:43 -0000 1.4 *************** *** 128,131 **** --- 128,134 ---- public const int BINARY_FORMAT = 1; + // Date & Time codes + public const string DATE_STYLE = "ISO"; + // Numeric data type public const int NUMERIC_SIGN_MASK = 0xC000; |