[pgsqlclient-checkins] pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient PgCodes.cs,1.4,1.
Status: Inactive
Brought to you by:
carlosga_fb
From: Carlos G. Á. <car...@us...> - 2004-09-29 12:11:05
|
Update of /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16289 Modified Files: PgCodes.cs PgConnectionParams.cs PgDbClient.cs PgStatement.cs Log Message: Mayor update of the PgSqlClient sources Index: PgConnectionParams.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgConnectionParams.cs,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PgConnectionParams.cs 10 Apr 2004 20:16:07 -0000 1.6 --- PgConnectionParams.cs 29 Sep 2004 12:10:53 -0000 1.7 *************** *** 33,36 **** --- 33,39 ---- private int packetSize; private int timeout; + private int connectionLifetime; + private int minPoolSize; + private int maxPoolSize; private bool pooling; private Encoding encoding; *************** *** 89,92 **** --- 92,113 ---- } + public int ConnectionLifeTime + { + get { return this.connectionLifetime; } + set { this.connectionLifetime = value; } + } + + public int MinPoolSize + { + get { return this.minPoolSize; } + set { this.minPoolSize = value; } + } + + public int MaxPoolSize + { + get { return this.maxPoolSize; } + set { this.maxPoolSize = value; } + } + public bool Pooling { *************** *** 114,117 **** --- 135,141 ---- this.pooling = true; this.timeout = 15; + this.connectionLifetime = 0; + this.minPoolSize = 0; + this.maxPoolSize = 100; this.encoding = Encoding.Default; } Index: PgDbClient.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgDbClient.cs,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** PgDbClient.cs 22 Jul 2004 10:58:58 -0000 1.52 --- PgDbClient.cs 29 Sep 2004 12:10:53 -0000 1.53 *************** *** 154,166 **** #region Constructors ! public PgDbClient() { - this.parameterStatus = new Hashtable(); - this.buffer = new PgResponsePacket(); } ! public PgDbClient(PgConnectionParams settings) : this() { ! this.settings = settings; } --- 154,168 ---- #region Constructors ! public PgDbClient() : this(null) { } ! public PgDbClient(PgConnectionParams settings) { ! this.parameterStatus = new Hashtable(); ! this.buffer = new PgResponsePacket(); ! this.settings = settings; ! ! GC.SuppressFinalize(this); } *************** *** 326,331 **** packet.WriteNullString("user"); packet.WriteNullString(this.settings.UserName); ! if (settings.Database != null && ! this.settings.Database.Length > 0) { packet.WriteNullString("database"); --- 328,332 ---- packet.WriteNullString("user"); packet.WriteNullString(this.settings.UserName); ! if (settings.Database != null && this.settings.Database.Length > 0) { packet.WriteNullString("database"); *************** *** 345,349 **** { response = this.ReceiveResponsePacket(); ! this.processResponsePacket(response); } } --- 346,350 ---- { response = this.ReceiveResponsePacket(); ! this.ProcessResponsePacket(response); } } *************** *** 387,405 **** internal void SendPacket(PgOutputPacket packet, char type) { ! try ! { ! this.send.Write(packet.GetPacketBytes(type)); ! } ! catch (IOException ex) ! { ! throw ex; ! } } internal void SendSimplePacket(PgOutputPacket packet) { try { ! this.send.Write(packet.GetSimplePacketBytes()); } catch (IOException ex) --- 388,410 ---- internal void SendPacket(PgOutputPacket packet, char type) { ! this.Write(packet.GetPacketBytes(type)); } internal void SendSimplePacket(PgOutputPacket packet) { + this.Write(packet.GetSimplePacketBytes()); + } + + private void Write(byte[] buffer) + { + this.Write(buffer, 0, buffer.Length); + } + + private void Write(byte[] buffer, int index, int count) + { try { ! this.send.Write(buffer, index, count); ! this.send.Flush(); } catch (IOException ex) *************** *** 419,423 **** lock (this) { ! responsePacket = this.receiveStandardPacket(); switch (responsePacket.Message) --- 424,428 ---- lock (this) { ! responsePacket = this.ReceiveStandardPacket(); switch (responsePacket.Message) *************** *** 425,429 **** case PgBackendCodes.ERROR_RESPONSE: // Read the error message and trow the exception ! PgClientException ex = processErrorPacket(responsePacket); // Perform a sync --- 430,434 ---- case PgBackendCodes.ERROR_RESPONSE: // Read the error message and trow the exception ! PgClientException ex = this.ProcessErrorPacket(responsePacket); // Perform a sync *************** *** 435,443 **** case PgBackendCodes.NOTICE_RESPONSE: // Read the notice message and raise an InfoMessage event ! this.InfoMessage(processErrorPacket(responsePacket)); break; case PgBackendCodes.NOTIFICATION_RESPONSE: ! this.processNotificationResponse(responsePacket); break; } --- 440,448 ---- case PgBackendCodes.NOTICE_RESPONSE: // Read the notice message and raise an InfoMessage event ! this.InfoMessage(this.ProcessErrorPacket(responsePacket)); break; case PgBackendCodes.NOTIFICATION_RESPONSE: ! this.ProcessNotificationResponse(responsePacket); break; } *************** *** 447,451 **** } ! private PgResponsePacket receiveStandardPacket() { PgResponsePacket responsePacket = null; --- 452,456 ---- } ! private PgResponsePacket ReceiveStandardPacket() { PgResponsePacket responsePacket = null; *************** *** 476,489 **** } ! private void processResponsePacket(PgResponsePacket packet) { switch (packet.Message) { case PgBackendCodes.AUTHENTICATION: ! this.processAuthPacket(packet); break; case PgBackendCodes.PARAMETER_STATUS: ! this.processParameterStatus(packet); break; --- 481,494 ---- } ! private void ProcessResponsePacket(PgResponsePacket packet) { switch (packet.Message) { case PgBackendCodes.AUTHENTICATION: ! this.ProcessAuthPacket(packet); break; case PgBackendCodes.PARAMETER_STATUS: ! this.ProcessParameterStatus(packet); break; *************** *** 500,507 **** } ! private void processParameterStatus(PgResponsePacket packet) { ! string parameterName = packet.ReadNullString(); ! string parameterValue = packet.ReadNullString(); parameterStatus.Add(parameterName, parameterValue); --- 505,512 ---- } ! private void ProcessParameterStatus(PgResponsePacket packet) { ! string parameterName = packet.ReadNullString(); ! string parameterValue = packet.ReadNullString(); parameterStatus.Add(parameterName, parameterValue); *************** *** 515,519 **** } ! private void processAuthPacket(PgResponsePacket packet) { // Authentication response --- 520,524 ---- } ! private void ProcessAuthPacket(PgResponsePacket packet) { // Authentication response *************** *** 572,576 **** } ! private PgClientException processErrorPacket(PgResponsePacket packet) { char type = ' '; --- 577,581 ---- } ! private PgClientException ProcessErrorPacket(PgResponsePacket packet) { char type = ' '; *************** *** 631,635 **** } ! private void processNotificationResponse(PgResponsePacket packet) { int processID = packet.ReadInt(); --- 636,640 ---- } ! private void ProcessNotificationResponse(PgResponsePacket packet) { int processID = packet.ReadInt(); *************** *** 743,747 **** { response = this.ReceiveResponsePacket(); ! this.processResponsePacket(response); } } --- 748,752 ---- { response = this.ReceiveResponsePacket(); ! this.ProcessResponsePacket(response); } } *************** *** 752,756 **** { response = this.ReceiveResponsePacket(); ! this.processResponsePacket(response); } --- 757,761 ---- { response = this.ReceiveResponsePacket(); ! this.ProcessResponsePacket(response); } *************** *** 860,866 **** IPEndPoint EPhost = new IPEndPoint(hostadd, settings.ServerPort); ! this.socket = new Socket(AddressFamily.InterNetwork, ! SocketType.Stream, ! ProtocolType.IP); // Set Receive Buffer size. --- 865,869 ---- IPEndPoint EPhost = new IPEndPoint(hostadd, settings.ServerPort); ! this.socket = new Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.IP); // Set Receive Buffer size. *************** *** 887,892 **** // Create objects for read & write ! this.receive = new BinaryReader(this.networkStream); ! this.send = new BinaryWriter(this.networkStream); } --- 890,901 ---- // Create objects for read & write ! this.receive = new BinaryReader(new BufferedStream(this.networkStream)); ! this.send = new BinaryWriter(new BufferedStream(this.networkStream)); ! ! // The socket and stream shouldn't be automatically collected by the GC ! GC.SuppressFinalize(this.socket); ! GC.SuppressFinalize(this.networkStream); ! GC.SuppressFinalize(this.receive); ! GC.SuppressFinalize(this.send); } Index: PgStatement.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgStatement.cs,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PgStatement.cs 22 Jul 2004 10:58:58 -0000 1.26 --- PgStatement.cs 29 Sep 2004 12:10:53 -0000 1.27 *************** *** 140,179 **** #region Constructors ! public PgStatement() { - this.outParameter = new PgParameter(); - this.rows = null; - this.rowIndex = 0; - this.parseName = String.Empty; - this.portalName = String.Empty; - this.recordsAffected = -1; - this.status = PgStatementStatus.Initial; - this.fetchSize = 200; } ! public PgStatement(PgDbClient db) : this() { - this.db = db; } ! public PgStatement(PgDbClient db, string parseName, string portalName) : this(parseName, portalName) { - this.db = db; } ! public PgStatement(PgDbClient db, string parseName, string portalName, string stmtText) : this(db, parseName, portalName) { - this.stmtText = stmtText; } ! public PgStatement(PgDbClient db, string stmtText) : this(db) { - this.stmtText = stmtText; } ! public PgStatement(string parseName, string portalName) : this() { ! this.parseName = parseName; ! this.portalName = portalName; } --- 140,177 ---- #region Constructors ! public PgStatement() : this(null) { } ! public PgStatement(PgDbClient db) : this(db, null, null) { } ! public PgStatement(PgDbClient db, string parseName, string portalName) : this(db, parseName, portalName, null) { } ! public PgStatement(PgDbClient db, string stmtText) : this(db, null, null, stmtText) { } ! public PgStatement(string parseName, string portalName) : this(null, parseName, portalName, null) { } ! public PgStatement(PgDbClient db, string parseName, string portalName, string stmtText) { ! this.db = db; ! this.outParameter = new PgParameter(); ! this.rows = null; ! this.rowIndex = 0; ! this.parseName = String.Empty; ! this.portalName = String.Empty; ! this.recordsAffected = -1; ! this.status = PgStatementStatus.Initial; ! this.fetchSize = 200; ! this.stmtText = stmtText; ! ! GC.SuppressFinalize(this); } *************** *** 220,232 **** public void Describe() { ! this.describe('S'); } public void DescribePortal() { ! this.describe('P'); } ! private void describe(char stmtType) { lock (this.db) --- 218,230 ---- public void Describe() { ! this.Describe('S'); } public void DescribePortal() { ! this.Describe('P'); } ! private void Describe(char stmtType) { lock (this.db) *************** *** 279,282 **** --- 277,281 ---- // Destination portal name packet.WriteNullString(this.PortalName); + // Prepared statement name packet.WriteNullString(this.ParseName); *************** *** 530,542 **** public void Close() { ! this.close('S'); } public void ClosePortal() { ! this.close('P'); } ! private void close(char stmtType) { lock (this.db) --- 529,541 ---- public void Close() { ! this.Close('S'); } public void ClosePortal() { ! this.Close('P'); } ! private void Close(char stmtType) { lock (this.db) Index: PgCodes.cs =================================================================== RCS file: /cvsroot/pgsqlclient/pgsqlclient_10/PostgreSql.Data.PgSqlClient/source/NPgClient/PgCodes.cs,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PgCodes.cs 20 Jul 2004 18:41:43 -0000 1.4 --- PgCodes.cs 29 Sep 2004 12:10:53 -0000 1.5 *************** *** 119,123 **** // ! public static readonly DateTime BASE_DATE = new DateTime(2000, 1, 1); // MD5 prefix --- 119,123 ---- // ! public static readonly DateTime BASE_DATE = new DateTime(2000, 1, 1); // MD5 prefix *************** *** 129,133 **** // Date & Time codes ! public const string DATE_STYLE = "ISO"; // Numeric data type --- 129,133 ---- // Date & Time codes ! public const string DATE_STYLE = "ISO"; // Numeric data type |