Re: BUG #5058: [jdbc] Silent failure with executeUpdate()

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: Joseph Shraibman <jks(at)selectacast(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #5058: [jdbc] Silent failure with executeUpdate()
Date: 2009-09-16 02:10:35
Message-ID: 1253067035.19140.24.camel@wallace.localnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-jdbc

On Tue, 2009-09-15 at 19:26 +0000, Joseph Shraibman wrote:
> The following bug has been logged online:
>
> Bug reference: 5058
> Logged by: Joseph Shraibman
> Email address: jks(at)selectacast(dot)net
> PostgreSQL version: 8.2.14
> Operating system: Linux
> Description: [jdbc] Silent failure with executeUpdate()
> Details:
>
> I was trying to figure out why I was getting different results with sql I
> was running through jdbc and running through psql. I was able to fix the
> bug by changing an executeUpdate() to an execute(). See attached code.
>

While the test case is appreciated, it's not really that clear what's
expected to happen vs what happens, at what point things go wrong and
under what circumstances, etc. Looking at your code and your post, I
can't tell:

- If the code you've attached is before or after the change described
- Where the change is/was made
- Why
- What it actually does

There are also a couple of randomly commented-out bits of code that seem
odd, some code seems like unnecessary wrapper code in such a simple
example ( eg getStatement(...) ) and some of the code is downright
hairy. In particular:

private static StringBuilder toString(Object o, StringBuilder sb)

cries out "use parameterized queries!". You're making life unnecessarily
hard for yourself, increasing SQL injection risk dramatically, and
giving yourself more to debug than you need by building queries as
strings including all parameters.

Perhaps you could pare down the code to that required to demonstrate the
issue and document the issue a little? Cut out unnecessary or duplicate
code (why are there two doQuery() implementations with mostly the same
code), drop any result-printing code etc if it doesn't help demonstrate
the bug you're reporting, remove commented out code and empty blocks,
and generally tidy things up so that the reader can read it to follow
your problem report, not puzzle out why your code does things how it
does.

Above all else, make sure to provide an explanation of where the problem
you are reporting arises, what actually happens, what you expect to
happen instead, and what exactly you change to "fix" it.

It might help to turn detailed error logging on in the server and
capture the server error log for your "silent" query failure, too.

--
Craig Ringer

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kenaniah Cerny 2009-09-16 03:35:07 BUG #5059: Planner ignores estimates when planning an IN () subquery
Previous Message Tom Lane 2009-09-16 01:50:45 Re: BUG #5055: Invalid page header error

Browse pgsql-jdbc by date

  From Date Subject
Next Message Angelo Nicolosi 2009-09-16 13:26:36 OOM on large SELECT
Previous Message Robert Haas 2009-09-16 00:54:41 Re: BUG #5058: [jdbc] Silent failure with executeUpdate()