Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 76BFF6342A7; Sat, 26 Sep 2009 11:32:29 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 55974-04-2; Sat, 26 Sep 2009 14:32:21 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from leary.csoft.net (leary.csoft.net [205.205.214.5]) by mail.postgresql.org (Postfix) with ESMTP id CFF0C634133; Sat, 26 Sep 2009 11:32:21 -0300 (ADT) Received: by leary.csoft.net (Postfix, from userid 1112) id EE8F3A30D; Sat, 26 Sep 2009 10:32:19 -0400 (EDT) Date: Sat, 26 Sep 2009 10:32:19 -0400 (EDT) From: Kris Jurka X-X-Sender: books@leary.csoft.net To: Joseph Shraibman cc: pgsql-bugs@postgresql.org, pgsql-jdbc@postgresql.org, Craig Ringer Subject: Re: [JDBC] BUG #5058: [jdbc] Silent failure with executeUpdate() In-Reply-To: <4AB27F88.9060202@selectacast.net> Message-ID: References: <200909151926.n8FJQpDB027963@wwwmaster.postgresql.org> <1253067035.19140.24.camel@wallace.localnet> <4AB27F88.9060202@selectacast.net> User-Agent: Alpine 2.00 (BSO 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200909/388 X-Sequence-Number: 24571 On Thu, 17 Sep 2009, Joseph Shraibman wrote: > [when passing a multi-statement sql string to executeUpdate, if a > statement after the first is a select, it is silently not fully > executed.] Running queries in executeUpdate is not allowed. If you pass a plain select to executeUpdate it complains: stmt.executeUpdate("SELECT 1"); org.postgresql.util.PSQLException: A result was returned when none was expected. The problem here is that we don't complain if it's not the first part of a multi-part statement. stmt.executeUpdate("/* */; SELECT 1") does not produce an error, but should, which I believe is the bug in this case. Since the JDBC driver knows it's going to complain if it sees a query result during executeUpdate, it wants to avoid the possibility of the user issuing a query which returns a giant dataset and having to process that just to error out anyway. So it passes the statements to the server with an additional instruction to say, "I just want the first row back at this time". That way if it is a big query result we'll only get one row instead of the whole thing. The server can implement this by either holding the whole resultset on the server or, as in this case, partially executing the query and returning control to the driver to see if it wants to continue executing it. So your select is only partially executed, getting run for only one row of the "joa" table rather than the whole thing as you are expecting. I intend to change the driver to error out in this case. Kris Jurka