X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3E6A052A65 for ; Fri, 6 May 2005 06:34:10 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 76220-09 for ; Fri, 6 May 2005 09:34:00 +0000 (GMT) Received: from smtp.nildram.co.uk (smtp.nildram.co.uk [195.112.4.54]) by svr1.postgresql.org (Postfix) with ESMTP id ADD6952A4E for ; Fri, 6 May 2005 06:33:57 -0300 (ADT) Received: from demolish1 (82-133-112-14.dyn.gotadsl.co.uk [82.133.112.14]) by smtp.nildram.co.uk (Postfix) with SMTP id 5874B253D03 for ; Fri, 6 May 2005 10:33:56 +0100 (BST) Message-ID: <011101c5521e$ba952440$0264a8c0@demolish1> From: "Donald Fraser" To: "[JDBC]" References: <008001c55151$ccc99150$0264a8c0@demolish1> <00a501c5516f$689f3090$0264a8c0@demolish1> <427A9EF0.7090609@opencloud.com> Subject: Re: Infinity and beyond Date: Fri, 6 May 2005 10:33:57 +0100 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_010E_01C55227.1BB053F0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.281 tagged_above=0 required=5 tests=AWL, HTML_20_30, HTML_MESSAGE X-Spam-Level: X-Archive-Number: 200505/34 X-Sequence-Number: 12865 This is a multi-part message in MIME format. ------=_NextPart_000_010E_01C55227.1BB053F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable > Donald Fraser wrote: >=20 > > As for being familiar with the 8.0.x driver - I'm always one driver = version > > behind as I have a number of more significant modifications to the = driver > > that require patching and unless there are major enhancements I = usually > > leave it a while, time permitting and all that... Hence I am only = familiar > > with the 7.4 and earlier versions of the driver. I will endeavour to = take a > > look at what changes have been made sometime soon. >=20 > Are any of your local changes things that you'd like to see rolled = into > the main driver? >=20 I'd like all the changes in the main driver - but them I'm not driving = the project so it'll be up to whoever's in charge... First I'd need to check on the latest driver and see what new and what's = not. Second some of the changes were made due to lack of features that date = back to the 7.2 version of the driver and now I could probably get = around some of these problems as of the 7.4 version or more correctly = the PostgreSQL version 3 communication protocol. What's probably easier, is if I outline a list of features that I've = added and I'll let you decide whether they're worth looking at, in case = they aren't already implemented in the latest driver. I'll give a brief = explanation as to why I found it necessary to make these changes so that = in the case I missed something that was already available via a = different approach you can point out my stupidity....;-) In any case please don't think that I'm complaining in any way about the = quality of the drivers - I'm grateful that they exist in the first = place! 1) Exceptions: are a big part of programming especially when dealing = with mediums outside the control of your software. What was missing in = the early version of the driver was the ability to detect a loss of = connection. Whilst the PGSQLException class clearly reported that a = connection was lost, it was difficult for client software to determine = this, especially for the case of unattended automatic recovery. The = reason it was difficult was that the driver was maintaining = compatibility across all three versions of the JDBC API and therefore = not utilising enhancements available in later JVMs. For example being = able to set the cause of an exception was introduced in the Java 1.4 VM, = yet this feature was not utilised at all in the JDBC 3.0 API of the = driver simply because it was difficult to maintain all three APIs when = this feature wasn't available in earlier JVMs. I'm sure that there were = other solutions to capturing connection losses, but setting the cause of = the exception had other gains that I also found necessary. For example I = didn't like the full stack trace being added to the exception message on = IO exceptions. End users want simple messages - not a technical report = useful only to programmers. For this reason I also cleaned up the = exception class to give cleaner messages and whilst I was at it I added = a driver option to allow formatting of the exception messages with or = without HTML. In summary:=20 i) Added exception cause to PGSQLException ii) Cleaner exception messages. iii) Driver option to format exception messages in HTML. Side effects: Driver is broken in terms of compatibility across all = three of the JDBC APIs, hence these changes only apply to the JDBC 3.0 = API. 2) Notifications: I didn't like having to poll the driver or the = database for PostgreSQL asynchronous NOTIFY messages. I therefore = modified the driver to use java listeners to notify clients = automatically when a NOTIFY was received - no polling required. The = initial modification to the driver was very simple and used a worker = thread to effectively poll the PGStream object for incoming messages. = Unfortunately this implementation didn't work on ssl sockets due to = implementation incompatibilities produced by SUN between an ssl socket = and a non-ssl socket (I claim it to be an implementation bug by SUN but = they disputed it). I therefore had to go for the more efficient approach = of completely blocking on the input stream object until data is = received. Because of this approach, sending and receiving data requires = a two stage object synchronization mechanism before you can start = sending or receiving data, where as before you only needed to = synchronize on one object. This is all technical stuff hidden from the = client. 3) Encoding: At first I didn't like the fact that the driver would = through an exception when translating characters into Unicode that = clearly weren't Unicode. The main problem is that I don't use Unicode. = Just because we have a nice language that supports Unicode doesn't mean = that we should be forced into using Unicode. As of version 7.3, the = driver forced the encoding to be Unicode which meant that my java = clients could easily save Unicode characters into the database which was = a big no no as not all clients of the database have Unicode - hence the = reverse problem in translating characters into Unicode on the java = platform. To overcome this problem I simply added a couple of methods to = the driver connection to set and get the encoding.=20 A very simple modification. 4) Multiple result sets: Don't get excited - I didn't implement multiple = result sets... The problem that arose here was that our database is = built heavily around the use of views. Views (and tables for that = matter) can have one or more rules which each return in their own right = a result set. Therefore executing update or insert statements on a view = with multiple rules will return multiple result sets. None of the = drivers have ever supported this, as soon a second result set was = detected the driver would through an exception informing you that it = didn't support multiple result sets. What I had to do here was silently = ignore previous results sets. Again a very simple modification. 5) CipherSuite: Added the ability to retrieve the cipher suite used on = ssl connections. Yet again another simple modification. All of these modification have been in production for well over a year = now and most have been in pre-production use for nearly three years. As you can see some of these modification are debatable as to their = necessity, therefore if you think any of them are useful let me know and = I'll work out a means of patching them to the latest driver. Regards Donald Fraser ------=_NextPart_000_010E_01C55227.1BB053F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
 
> Donald Fraser wrote:
> =
> > As=20 for being familiar with the 8.0.x driver - I'm always one driver = version
>=20 > behind as I have a number of more significant modifications to the=20 driver
> > that require patching and unless there are major=20 enhancements I usually
> > leave it a while, time permitting = and all=20 that... Hence I am only familiar
> > with the 7.4 and earlier = versions=20 of the driver. I will endeavour to take a
> > look at what = changes have=20 been made sometime soon.
>
> Are any of your local changes = things=20 that you'd like to see rolled into
> the main driver?
>=20
I'd like all the changes in the main = driver - but=20 them I'm not driving the project so it'll be up to whoever's in=20 charge...
First I'd need to check on the latest = driver and=20 see what new and what's not.
Second some of the changes were made = due to lack of=20 features that date back to the 7.2 version of the driver and now I could = probably get around some of these problems as of the 7.4 version or more = correctly the PostgreSQL version 3 communication protocol.
What's probably easier, is if I outline = a list=20 of features that I've added and I'll let you decide whether they're = worth=20 looking at, in case they aren't already implemented in the = latest=20 driver. I'll give a brief explanation as to why I found it necessary to = make=20 these changes so that in the case I missed something that was already = available=20 via a different approach you can point out my = stupidity....;-)
In any case please don't think that I'm = complaining=20 in any way about the quality of the drivers - I'm grateful that they = exist in=20 the first place!
 
1) Exceptions: are a big part of = programming=20 especially when dealing with mediums outside the control of your = software. What=20 was missing in the early version of the driver was the ability to detect = a loss=20 of connection. Whilst the PGSQLException class clearly reported that a=20 connection was lost, it was difficult for client software to determine = this,=20 especially for the case of unattended automatic recovery. The = reason it was=20 difficult was that the driver was maintaining compatibility across all = three=20 versions of the JDBC API and therefore not utilising enhancements = available=20 in later JVMs. For example being able to set the cause of an exception = was=20 introduced in the Java 1.4 VM, yet this feature was not utilised at = all in=20 the JDBC 3.0 API of the driver simply because it was difficult = to=20 maintain all three APIs when this feature wasn't available in = earlier=20 JVMs. I'm sure that there were other solutions to capturing = connection=20 losses, but setting the cause of the exception had other gains that I = also found=20 necessary. For example I didn't like the full stack trace being added to = the=20 exception message on IO exceptions. End users want simple messages - not = a=20 technical report useful only to programmers. For this reason I also = cleaned up=20 the exception class to give cleaner messages and whilst I was at it I = added a=20 driver option to allow formatting of the exception messages with or = without=20 HTML.
In summary:
i) Added exception cause to=20 PGSQLException
ii) Cleaner exception = messages.
iii) Driver option to format exception = messages in=20 HTML.
 
Side effects: Driver is broken in = terms of=20 compatibility across all three of the JDBC APIs, hence these changes = only apply=20 to the JDBC 3.0 API.
 
2) Notifications: I didn't like having = to poll the=20 driver or the database for PostgreSQL asynchronous NOTIFY messages. I = therefore=20 modified the driver to use java listeners to notify clients = automatically when a=20 NOTIFY was received - no polling required. The initial modification to = the=20 driver was very simple and used a worker thread to effectively poll the = PGStream=20 object for incoming messages. Unfortunately this implementation didn't = work on=20 ssl sockets due to implementation incompatibilities produced by SUN = between an=20 ssl socket and a non-ssl socket (I claim it to be an implementation bug = by SUN=20 but they disputed it). I therefore had to go for the more efficient = approach of=20 completely blocking on the input stream object until data is received. = Because=20 of this approach, sending and receiving data requires a two stage object = synchronization mechanism before you can start sending or receiving = data, where=20 as before you only needed to synchronize on one object. This is all = technical=20 stuff hidden from the client.
 
3) Encoding: At first I didn't like the = fact that=20 the driver would through an exception when translating characters into = Unicode=20 that clearly weren't Unicode. The main problem is that I don't use = Unicode. Just=20 because we have a nice language that supports Unicode doesn't mean that = we=20 should be forced into using Unicode. As of version 7.3, the driver = forced=20 the encoding to be Unicode which meant that my java clients could easily = save=20 Unicode characters into the database which was a big no no as not all = clients of=20 the database have Unicode - hence the reverse problem in translating = characters=20 into Unicode on the java platform. To = overcome=20 this problem I simply added a couple of methods to the driver connection = to set=20 and get the encoding.
A very simple = modification.
 
4) Multiple result sets: Don't get = excited - I=20 didn't implement multiple result sets... The problem that arose here was = that=20 our database is built heavily around the use of views. Views (and tables = for=20 that matter) can have one or more rules which each return in their own = right a=20 result set. Therefore executing update or insert statements on a view = with=20 multiple rules will return multiple result sets. None of the drivers = have ever=20 supported this, as soon a second result set was detected the driver = would=20 through an exception informing you that it didn't support multiple = result sets.=20 What I had to do here was silently ignore previous results = sets.
Again a very=20 simple modification.
 
5) CipherSuite: Added the ability to = retrieve the=20 cipher suite used on ssl connections.
Yet again another simple = modification.
 
All of these modification have been in = production=20 for well over a year now and most have been in pre-production use for = nearly=20 three years.
As you can see some of these = modification are=20 debatable as to their necessity, therefore if you think any of them are = useful=20 let me know and I'll work out a means of patching them to the latest=20 driver.
 
Regards
Donald Fraser
 
 
------=_NextPart_000_010E_01C55227.1BB053F0--