Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id 75FD7632DED for ; Tue, 10 Mar 2009 14:35:45 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 07558-08 for ; Tue, 10 Mar 2009 14:35:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail63.csoft.net (mail63.csoft.net [205.205.214.4]) by mail.postgresql.org (Postfix) with ESMTP id 2948862FEFB for ; Tue, 10 Mar 2009 14:35:41 -0300 (ADT) Received: from [192.168.1.141] (adsl-71-128-101-241.dsl.irvnca.pacbell.net [71.128.101.241]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail63.csoft.net (Postfix) with ESMTP id 99E3F2840C; Tue, 10 Mar 2009 13:35:39 -0400 (EDT) Message-ID: <49B6A4EA.5060905@ejurka.com> Date: Tue, 10 Mar 2009 10:35:38 -0700 From: Kris Jurka User-Agent: Mozilla-Thunderbird 2.0.0.19 (X11/20090103) MIME-Version: 1.0 To: Pawel Pastula CC: pgsql-jdbc@postgresql.org Subject: Re: a possible bug in postgresql jdbc driver References: <4a11ebd30903100515s5928f841led26cff1def2c81f@mail.gmail.com> In-Reply-To: <4a11ebd30903100515s5928f841led26cff1def2c81f@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200903/54 X-Sequence-Number: 19384 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