Re: Query preparation - Mailing list pgsql-jdbc

From Kris Jurka
Subject Re: Query preparation
Date
Msg-id Pine.BSO.4.64.0904201744220.12014@leary.csoft.net
Whole thread Raw
In response to Re: Query preparation  (Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>)
List pgsql-jdbc

On Thu, 16 Apr 2009, Heikki Linnakangas wrote:

> Here's the patch. Describe message is only sent in the first invocation
> of a query. The Field[] array constructed from the RowDescription
> message is saved in the SimpleQuery object for reuse.
>

Applied with minor revisions.  When sending a Describe Statement message
you'll also get a Row Description message back, so we need to add the
query to the pendingDescribePortalQueue there as well.  Doing this always
avoids some of the other special casing you tried to put in to handle
describe statement (which didn't work if you see the new unit test I
added).

While looking at this code it reminded me that we're also sending Describe
Statement too often and I've fixed that to only do it when necessary.
Previously the following code would describe the statement for every
execution.

PreparedStatement ps = conn.prepareStatement("SELECT ?::int");
for (int i=0; i<100; i++) {
     ps.setObject(1, new Integer(i), Types.OTHER);
     ResultSet rs = ps.executeQuery();
}

Also the JDBC coding style guidelines require four space indentation
rather than tabs, so you'll see some additional changes from that.

Kris Jurka

pgsql-jdbc by date:

Previous
From: "John Lister"
Date:
Subject: Re: Unit tests and ordering
Next
From: "j.random.programmer"
Date:
Subject: Bug with duplicate column names via JDBC MetaData (ORDINAL_POSITION)