pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Craig Ringer <craig@postnewspapers.com.au>
To: Joseph Shraibman <jks@selectacast.net>
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #5058: [jdbc] Silent failure with executeUpdate()
Date: Wed, 16 Sep 2009 10:10:35 +0800
Message-ID: <1253067035.19140.24.camel@wallace.localnet> (raw)
In-Reply-To: <200909151926.n8FJQpDB027963@wwwmaster.postgresql.org>
References: <200909151926.n8FJQpDB027963@wwwmaster.postgresql.org>

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@selectacast.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





view thread (5+ messages)  latest in thread

Message-ID: <1253067035.19140.24.camel@wallace.localnet>
Permalink:  ../1253067035.19140.24.camel@wallace.localnet/
Also on:    postgresql.org/message-id/1253067035.19140.24.camel@wallace.localnet

 · 

reply

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: craig@postnewspapers.com.au, jks@selectacast.net, pgsql-bugs@postgresql.org
  Subject: Re: BUG #5058: [jdbc] Silent failure with executeUpdate()
  In-Reply-To: <1253067035.19140.24.camel@wallace.localnet>
  References: <200909151926.n8FJQpDB027963@wwwmaster.postgresql.org> <1253067035.19140.24.camel@wallace.localnet>

* 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