Re: libpq and prepared statements progress for 8.0 - Mailing list pgsql-hackers

From Oliver Jowett
Subject Re: libpq and prepared statements progress for 8.0
Date
Msg-id 4148B23E.7020009@opencloud.com
Whole thread Raw
In response to Re: libpq and prepared statements progress for 8.0  (Greg Stark <gsstark@mit.edu>)
Responses Re: libpq and prepared statements progress for 8.0  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark wrote:

> I was pretty shocked when I heard that JDBC implements the low level protocol
> itself. It seems like a dead-end strategy to me. Any new protocol innovations
> need to be implemented in every driver. Every implementation gets the chance
> to reimplement the same bugs and same inefficiencies over and over again.

There *are* benefits to implementing the protocol directly. First on my 
personal list is that our Java application would not be able to use 
postgresql at all if the driver required JNI/libpq.

There are also some things in the JDBC API that seem hard to map to the 
current libpq API, e.g. streaming parameter data from a Java stream 
without taking an intermediate copy.

The protocol implementation is not really all that complex. The 
implementation for both V2 and V3 weighs in at ~6k lines of Java out of 
~38k total, and much of that is connection-state juggling that we'd have 
to do anyway if using libpq (working out when to send BEGIN, breaking up 
multiple-statement queries into individual statements and matching the 
results up, managing portal state, etc).

-O


pgsql-hackers by date:

Previous
From: Gaetano Mendola
Date:
Subject: Re: x86_64 configure problem
Next
From: "Simon Riggs"
Date:
Subject: Re: 'TID index'