Re: Change of format of returned flat value after prepareThreshold - Mailing list pgsql-jdbc

From Vladimir Sitnikov
Subject Re: Change of format of returned flat value after prepareThreshold
Date
Msg-id CAB=Je-F5k+wDDU3V4YE+pSyVK7rDOMmucoQy8wnPK7gFEJeh1g@mail.gmail.com
Whole thread Raw
In response to Re: Change of format of returned flat value after prepareThreshold  (Michał Niklas <michal.niklas@heuthes.pl>)
Responses Re: Change of format of returned flat value after prepareThreshold
Re: Change of format of returned flat value after prepareThreshold
List pgsql-jdbc
> I changed those codes to use System.currentTimeMillis().

>why JDBC or database backend changes format of returned value
>after my use count reaches prepareThreshold parameter.

We JDBC driver cannot ensure stable string representation of non-string data.
That might change as database improves. That might change as JDBC
driver improves.

>If I set prepareThreshold=5 then I get float in normal
>notation up to 5th try, and then from 6th try I get this
>value in scientific notation.

Well, that is thanks to usage of server-prepared statement.
In that mode, pgjdbc can use binary format of data transfer. It does
use binary mode for types it knows as it is more efficient to transfer
and parse.


>I do not observe this with JDBC drivers in version 9.3,

The thing is older versions did not manage to use server-prepared
statements for prepareStatement(); .call();
Recently pgjdbc learned to use server-prepared statement even in case
application does not care to reuse PreparedStatements:

http://stackoverflow.com/questions/32297503/whats-the-life-span-of-a-postgresql-server-side-prepared-statement/32300222#32300222

>then I simplified code that now
>is even more portable (as we work with other databases)

Can you share the code?

>but getString() simply works.

That is more or less similar to "sun.misc.Unsafe" API.
You want string, you get it. I believe there is no specification on
what .getString() should look like.

Vladimir


pgsql-jdbc by date:

Previous
From: Mark Rotteveel
Date:
Subject: Re: Release 1204 released
Next
From: Dave Cramer
Date:
Subject: Re: Release 1204 released