Re: Change of format of returned flat value after prepareThreshold

From: Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>
To: Michał Niklas <michal(dot)niklas(at)heuthes(dot)pl>
Cc: List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: Change of format of returned flat value after prepareThreshold
Date: 2015-10-16 10:15:23
Message-ID: CAB=Je-F5k+wDDU3V4YE+pSyVK7rDOMmucoQy8wnPK7gFEJeh1g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Dave Cramer 2015-10-16 10:43:54 Re: Release 1204 released
Previous Message Mark Rotteveel 2015-10-16 07:01:26 Re: Release 1204 released