Re: Query preparation

From: Kris Jurka <books(at)ejurka(dot)com>
To: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>
Cc: Oliver Jowett <oliver(at)opencloud(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, John Lister <john(dot)lister-ps(at)kickstone(dot)com>, pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Query preparation
Date: 2009-04-20 21:51:27
Message-ID: Pine.BSO.4.64.0904201744220.12014@leary.csoft.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message j.random.programmer 2009-04-21 06:15:58 Bug with duplicate column names via JDBC MetaData (ORDINAL_POSITION)
Previous Message John Lister 2009-04-20 08:47:55 Re: Unit tests and ordering