Tom Lane wrote:
> Barry Lind <blind(at)xythos(dot)com> writes:
>>My final question is more of an implementation question than comments on
>>the protocol itself. Since the jdbc driver needs to be backwardly
>>compatible with 7.3 and earlier servers that will speak the 2.0
>>protocol, what is the recomended way to write the client so that it can
>>'detect' which protocol to use.
>
> I'd do it the other way: send a 3.0 connection request and then, if you
> get a "bad protocol" error response, send a 2.0 connection request.
> You do have to be a little careful about parsing the connection response
> since if it's 'E' it might be either 2.0 or 3.0 layout, but that can be
> handled without too much difficulty I think. (Look at the
> already-committed code in libpq's fe-connect.c.)
>
OK. So this is what I plan to do:
First try a 3.0 connection.
If an error response is received from the connection attempt then check
if the error is in a 3.0 format, if yes then report the error, else if
not 3.0 format then try a 2.0 connection, if that returns an error then
report it.
thanks,
--Barry