From: Kris Jurka <books@ejurka.com>
To: Pawel Pastula <pawelp76@gmail.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: a possible bug in postgresql jdbc driver
Date: Tue, 10 Mar 2009 10:35:38 -0700
Message-ID: <49B6A4EA.5060905@ejurka.com> (raw)
In-Reply-To: <4a11ebd30903100515s5928f841led26cff1def2c81f@mail.gmail.com>
References: <4a11ebd30903100515s5928f841led26cff1def2c81f@mail.gmail.com>
Pawel Pastula wrote:
> Hi Kris
>
Please send general questions to the pgsql-jdbc@postgresql.org mailing
list rather than to individual developers.
> I think I've found a bug in jdbc driver.
> I need to execute a query which is actually a list of queries and some
> of them drop tables, other update tables and one of them queries data
> with select.
> Imagine the following query (report):
>
> drop table if exists test_table;
> select * into test_table from other_table;
> select * from test_table;
>
> Of course it looks very simple but it's only for testing purposes. My
> queries are more demanding with lots of select * into temp table etc.
> I figured out that in order to get data from test_table I need to
> actually call getResultSet() 3 times. Therefore I wrote some simple
> 'result set walker' to get the latest result set returned by the query.
> And it's fine.
>
> However in case of this report stmt.executeQuery() would be more
> convenient since we expect to receive some data.
> And this is the place where the problem is. It throws exception just
> because after the query is executed there is a check whether result set
> is not null.
> And the problem is, that only the first result set is taken into
> account. The rest is ignored. And in my case the first query has no
> result set, it only has update count, the same with the second query.
> Only the third one has a result set.
> Therefore the check shouldn't be done whether there is a result set and
> whether it's not null for the first subquery but whether there is a
> result set for any subquery in this query.
See the javadoc for Statement.executeQuery, it says it should throw a
SQLException if, "the given SQL statement produces anything other than a
single ResultSet object." As you've noted it has produced other results
(update counts) and therefore it must throw the exception.
Kris Jurka
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: books@ejurka.com, pawelp76@gmail.com
Subject: Re: a possible bug in postgresql jdbc driver
In-Reply-To: <49B6A4EA.5060905@ejurka.com>
References: <4a11ebd30903100515s5928f841led26cff1def2c81f@mail.gmail.com> <49B6A4EA.5060905@ejurka.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox