From: Carlos G. Á. <car...@us...> - 2005-09-11 19:46:31
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3208/PostgreSql/Data/Protocol Modified Files: PgCharSetCollection.cs PgDbClient.cs PgStatement.cs PgTypeCollection.cs Log Message: Updated sources Index: PgDbClient.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol/PgDbClient.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgDbClient.cs 11 Sep 2005 13:29:16 -0000 1.4 --- PgDbClient.cs 11 Sep 2005 19:46:23 -0000 1.5 *************** *** 40,43 **** --- 40,48 ---- public static void InitializeTypes() { + if (DataTypes.Count > 0) + { + return; + } + DataTypes.Add(16 , "bool" , PgDataType.Boolean , 0, PgTypeFormat.Binary, 1); DataTypes.Add(17 , "bytea" , PgDataType.Binary , 0, PgTypeFormat.Binary, 0); *************** *** 97,100 **** --- 102,110 ---- public static void InitializeCharSets() { + if (Charactersets.Count > 0) + { + return; + } + Charactersets.Add("SQL_ASCII" , "ascii"); // ASCII Charactersets.Add("EUC_JP" , "euc-jp"); // Japanese EUC *************** *** 146,149 **** --- 156,160 ---- private BinaryWriter send; private PgConnectionOptions options; + private Encoding encoding; private char transactionStatus; *************** *** 155,159 **** { get { return this.handle; } - set { this.handle = value; } } --- 166,169 ---- *************** *** 161,171 **** { get { return this.secretKey; } - set { this.secretKey = value; } } public Hashtable ParameterStatus { ! get { return this.parameterStatus; } ! set { this.parameterStatus = value; } } --- 171,186 ---- { get { return this.secretKey; } } public Hashtable ParameterStatus { ! get ! { ! if (this.parameterStatus == null) ! { ! this.parameterStatus = Hashtable.Synchronized(new Hashtable()); ! } ! return this.parameterStatus; ! } } *************** *** 173,177 **** { get { return this.options; } ! set { this.options = value; } } --- 188,196 ---- { get { return this.options; } ! } ! ! public Encoding Encoding ! { ! get { return this.encoding; } } *************** *** 199,211 **** #region · Constructors · ! public PgDbClient() ! : this(null) { } ! public PgDbClient(PgConnectionOptions settings) { ! this.parameterStatus = new Hashtable(); ! this.options = settings; GC.SuppressFinalize(this); --- 218,230 ---- #region · Constructors · ! public PgDbClient(string connectionString) ! : this(new PgConnectionOptions(connectionString)) { } ! public PgDbClient(PgConnectionOptions options) { ! this.options = options; ! this.encoding = Encoding.UTF8; GC.SuppressFinalize(this); *************** *** 230,240 **** { // Send SSL request message ! this.SSLRequest(); ! ! if (this.options.SSL) { this.secureStream = new SslStream(this.networkStream, false); ! this.SecureStream.AuthenticateAsClient(this.options.ServerName); this.receive = new BinaryReader(this.SecureStream); --- 249,257 ---- { // Send SSL request message ! if (this.SslRequest()) { this.secureStream = new SslStream(this.networkStream, false); ! this.SecureStream.AuthenticateAsClient(this.options.DataSource); this.receive = new BinaryReader(this.SecureStream); *************** *** 244,252 **** // Send Startup message ! PgOutputPacket packet = new PgOutputPacket(this.options.Encoding); packet.Write(PgCodes.PROTOCOL_VERSION3); packet.WriteNullString("user"); ! packet.WriteNullString(this.options.UserName); if (this.options.Database != null && this.options.Database.Length > 0) --- 261,269 ---- // Send Startup message ! PgOutputPacket packet = new PgOutputPacket(this.Encoding); packet.Write(PgCodes.PROTOCOL_VERSION3); packet.WriteNullString("user"); ! packet.WriteNullString(this.options.UserID); if (this.options.Database != null && this.options.Database.Length > 0) *************** *** 393,397 **** } ! responsePacket = new PgResponsePacket(type, this.options.Encoding, buffer); } catch (IOException) --- 410,414 ---- } ! responsePacket = new PgResponsePacket(type, this.Encoding, buffer); } catch (IOException) *************** *** 421,426 **** case PgBackendCodes.BACKEND_KEY_DATA: // BackendKeyData ! this.Handle = packet.ReadInt32(); ! this.SecretKey = packet.ReadInt32(); break; } --- 438,443 ---- case PgBackendCodes.BACKEND_KEY_DATA: // BackendKeyData ! this.handle = packet.ReadInt32(); ! this.secretKey = packet.ReadInt32(); break; } *************** *** 437,441 **** { case "client_encoding": ! this.options.Encoding = Charactersets[parameterValue].Encoding; break; } --- 454,458 ---- { case "client_encoding": ! this.encoding = Charactersets[parameterValue].Encoding; break; } *************** *** 447,451 **** int authType = packet.ReadInt32(); ! PgOutputPacket outPacket = new PgOutputPacket(this.options.Encoding); switch (authType) --- 464,468 ---- int authType = packet.ReadInt32(); ! PgOutputPacket outPacket = new PgOutputPacket(this.Encoding); switch (authType) *************** *** 465,469 **** case PgCodes.AUTH_CLEARTEXT_PASSWORD: // Cleartext password is required ! outPacket.WriteNullString(this.options.UserPassword); break; --- 482,486 ---- case PgCodes.AUTH_CLEARTEXT_PASSWORD: // Cleartext password is required ! outPacket.WriteNullString(this.options.Password); break; *************** *** 480,484 **** // Second calculate md5 of password + user string userHash = MD5Authentication.GetMD5Hash( ! this.options.Encoding.GetBytes(this.options.UserName), this.options.UserPassword); // Third calculate real MD5 hash --- 497,501 ---- // Second calculate md5 of password + user string userHash = MD5Authentication.GetMD5Hash( ! this.Encoding.GetBytes(this.options.UserID), this.options.Password); // Third calculate real MD5 hash *************** *** 641,645 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.options.Encoding); // Send packet to the server --- 658,662 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.Encoding); // Send packet to the server *************** *** 659,663 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.options.Encoding); // Send packet to the server --- 676,680 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.Encoding); // Send packet to the server *************** *** 713,722 **** } ! public void SSLRequest() { lock (this) { - this.options.SSL = false; - try { --- 730,739 ---- } ! public bool SslRequest() { + bool sslAvailable = false; + lock (this) { try { *************** *** 729,750 **** // Receive server response ! char sslSupport = Convert.ToChar(this.networkStream.ReadByte()); ! ! switch (sslSupport) { case 'S': ! this.options.SSL = true; break; default: ! this.options.SSL = false; break; } } ! catch (Exception) { throw; } } } --- 746,767 ---- // Receive server response ! switch (Convert.ToChar(this.networkStream.ReadByte())) { case 'S': ! sslAvailable = true; break; default: ! sslAvailable = false; break; } } ! catch { throw; } } + + return sslAvailable; } *************** *** 787,791 **** private void InitializeSocket() { ! IPAddress hostadd = Dns.GetHostEntry(this.options.ServerName).AddressList[0]; this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); --- 804,808 ---- private void InitializeSocket() { ! IPAddress hostadd = Dns.GetHostEntry(this.options.DataSource).AddressList[0]; this.socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); *************** *** 801,805 **** // Make the socket to connect to the Server ! this.socket.Connect(new IPEndPoint(hostadd, this.options.ServerPort)); this.networkStream = new NetworkStream(socket, true); --- 818,822 ---- // Make the socket to connect to the Server ! this.socket.Connect(new IPEndPoint(hostadd, this.options.PortNumber)); this.networkStream = new NetworkStream(socket, true); Index: PgTypeCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol/PgTypeCollection.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PgTypeCollection.cs 11 Sep 2005 12:12:31 -0000 1.2 --- PgTypeCollection.cs 11 Sep 2005 19:46:23 -0000 1.3 *************** *** 23,46 **** namespace PostgreSql.Data.Protocol { ! internal class PgTypeCollection : ArrayList { #region · Properties · ! public new PgType this[int oid] { ! get { return (PgType)base[IndexOf(oid)]; } ! set { base[IndexOf(oid)] = (PgType)value; } } public PgType this[string name] { ! get { return (PgType)this[IndexOf(name)]; } ! set { this[IndexOf(name)] = (PgType)value; } ! } ! ! public PgType this[DbType systemType] ! { ! get { return (PgType)this[IndexOf(systemType)]; } ! set { this[IndexOf(systemType)] = (PgType)value; } } --- 23,40 ---- namespace PostgreSql.Data.Protocol { ! internal class PgTypeCollection : CollectionBase { #region · Properties · ! public PgType this[int oid] { ! get { return (PgType)this.List[this.IndexOf(oid)]; } ! set { this.List[this.IndexOf(oid)] = (PgType)value; } } public PgType this[string name] { ! get { return (PgType)this.List[this.IndexOf(name)]; } ! set { this.List[this.IndexOf(name)] = (PgType)value; } } *************** *** 74,78 **** int index = 0; ! foreach(PgType item in this) { if (this.CultureAwareCompare(item.Name, name)) --- 68,72 ---- int index = 0; ! foreach (PgType item in this) { if (this.CultureAwareCompare(item.Name, name)) *************** *** 88,97 **** public void RemoveAt(string typeName) { ! this.RemoveAt(IndexOf(typeName)); } public PgType Add(PgType type) { ! base.Add(type); return type; --- 82,91 ---- public void RemoveAt(string typeName) { ! this.List.RemoveAt(this.IndexOf(typeName)); } public PgType Add(PgType type) { ! this.List.Add(type); return type; *************** *** 100,108 **** 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); ! ! base.Add(type); ! ! return type; } --- 94,98 ---- 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)); } Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol/PgStatement.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgStatement.cs 11 Sep 2005 13:29:16 -0000 1.4 --- PgStatement.cs 11 Sep 2005 19:46:23 -0000 1.5 *************** *** 178,182 **** this.parameters = new PgParameter[0]; ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); packet.WriteNullString(this.ParseName); --- 178,182 ---- this.parameters = new PgParameter[0]; ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.WriteNullString(this.ParseName); *************** *** 218,222 **** string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); packet.Write((byte)stmtType); --- 218,222 ---- string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.Write((byte)stmtType); *************** *** 257,261 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); // Destination portal name --- 257,261 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); // Destination portal name *************** *** 308,312 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); packet.WriteNullString(this.PortalName); --- 308,312 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.WriteNullString(this.PortalName); *************** *** 363,367 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); // Function id --- 363,367 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); // Function id *************** *** 418,422 **** try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); packet.WriteNullString(this.stmtText); --- 418,422 ---- try { ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.WriteNullString(this.stmtText); *************** *** 528,532 **** string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); ! PgOutputPacket packet = new PgOutputPacket(this.db.Options.Encoding); packet.Write((byte)stmtType); --- 528,532 ---- string name = ((stmtType == 'S') ? this.ParseName : this.PortalName); ! PgOutputPacket packet = new PgOutputPacket(this.db.Encoding); packet.Write((byte)stmtType); Index: PgCharSetCollection.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/source/PostgreSql/Data/Protocol/PgCharSetCollection.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PgCharSetCollection.cs 11 Sep 2005 13:29:16 -0000 1.3 --- PgCharSetCollection.cs 11 Sep 2005 19:46:23 -0000 1.4 *************** *** 25,40 **** internal sealed class PgCharactersetCollection : CollectionBase { - #region · Fields · - - private ArrayList charactersets; - - #endregion - #region · Properties · public PgCharacterSet this[int index] { ! get { return (PgCharacterSet)this.charactersets[index]; } ! set { this.charactersets[index] = (PgCharacterSet)value; } } --- 25,34 ---- internal sealed class PgCharactersetCollection : CollectionBase { #region · Properties · public PgCharacterSet this[int index] { ! get { return (PgCharacterSet)this.List[index]; } ! set { this.List[index] = (PgCharacterSet)value; } } *************** *** 51,55 **** public bool Contains(string characterset) { ! return (-1 != this.charactersets.IndexOf(characterset)); } --- 45,49 ---- public bool Contains(string characterset) { ! return (-1 != this.List.IndexOf(characterset)); } *************** *** 73,82 **** public void RemoveAt(string charset) { ! this.charactersets.RemoveAt(this.IndexOf(charset)); } public PgCharacterSet Add(PgCharacterSet charset) { ! this.charactersets.Add(charset); return charset; --- 67,76 ---- public void RemoveAt(string charset) { ! this.List.RemoveAt(this.IndexOf(charset)); } public PgCharacterSet Add(PgCharacterSet charset) { ! this.List.Add(charset); return charset; |