pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy
4+ messages / 2 participants
[nested] [flat]

* 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy
@ 2005-12-19 18:57 j.random.programmer <javadesigner@yahoo.com>
  2005-12-19 23:28 ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 4+ messages in thread

From: j.random.programmer @ 2005-12-19 18:57 UTC (permalink / raw)
  To: pgsql-jdbc

Hi:

There seems to be a bug with the 8.2dev-500
driver, running against a postgres 8.1 database.

If I have a PreparedStatement, then when I say:

System.out.println(ps)

the the prepared statement that is printed is
*missing* single quotes around data/time AND
character/string values. This means that I 
cannot copy that preparedstatment and paste
it directly into a psql session etc.

For example, this is what a ps.toString() looks like:
--------------------------------------
 INSERT into alltypes (smallint_val, int_val,
bigint_val, float_val, double_val, numeric_val,
char_val, varchar_val, timestamp_val, bit_val,
varbinary_val) values (5, 6, 7000, 3.14, 3.141, 11.32,
foo2, bar2, 2005-12-19 09:55:23.464000 -0500, 1,
<stream of 5 bytes>)
-------------------------------------

Note, this is not valid sql since no quotes around
'foo2', 'bar2', '2005...' etc (which are
respectively char and date types).

This is definitely a regression, this did not happen
with earlier drivers. 

Best regards,

--j

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString()
  2005-12-19 18:57 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
@ 2005-12-19 23:28 ` Oliver Jowett <oliver@opencloud.com>
  2005-12-19 23:36   ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Oliver Jowett @ 2005-12-19 23:28 UTC (permalink / raw)
  To: j.random.programmer <javadesigner@yahoo.com>; +Cc: pgsql-jdbc

j.random.programmer wrote:

> There seems to be a bug with the 8.2dev-500
> driver, running against a postgres 8.1 database.
> 
> If I have a PreparedStatement, then when I say:
> 
> System.out.println(ps)
> 
> the the prepared statement that is printed is
> *missing* single quotes around data/time AND
> character/string values. This means that I 
> cannot copy that preparedstatment and paste
> it directly into a psql session etc.

I don't think the driver or the spec has ever claimed that toString() 
gives you a valid SQL statement.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy
  2005-12-19 18:57 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
  2005-12-19 23:28 ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>
@ 2005-12-19 23:36   ` j.random.programmer <javadesigner@yahoo.com>
  2005-12-20 07:05     ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 4+ messages in thread

From: j.random.programmer @ 2005-12-19 23:36 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: pgsql-jdbc

Oliver:

> I don't think the driver or the spec has ever
> claimed that toString() 
> gives you a valid SQL statement.

True :-)

However, note that it *used* to do so. This is a
regression from the past driver. And it would
be nice to have anyway, won't it ?

Also note in the past, booleans would get 
converted to '1' and stored in BIT columns.
With the latest driver, java booleans are sent as 
the number 1 (no quotes) and thus cannot be 
stored in a BIT column, in direct contradiction to 
the JDBC spec. (that's a different issue, see my
other post but I have a feeling it may somehow
be related).

Best regards,
--j

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString()
  2005-12-19 18:57 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
  2005-12-19 23:28 ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>
  2005-12-19 23:36   ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
@ 2005-12-20 07:05     ` Oliver Jowett <oliver@opencloud.com>
  0 siblings, 0 replies; 4+ messages in thread

From: Oliver Jowett @ 2005-12-20 07:05 UTC (permalink / raw)
  To: j.random.programmer <javadesigner@yahoo.com>; +Cc: pgsql-jdbc

j.random.programmer wrote:
> Oliver:
> 
> 
>>I don't think the driver or the spec has ever
>>claimed that toString() 
>>gives you a valid SQL statement.
> 
> 
> True :-)
> 
> However, note that it *used* to do so. This is a
> regression from the past driver. And it would
> be nice to have anyway, won't it ?

Perhaps, but there are some implementation hurdles that mean it's not 
really worth it (for example: what if a parameter is actually a binary 
stream, and we're not reading it ahead of time?)

If you have a patch to do this, though, we can certainly look at 
applying it.

-O



^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-12-20 07:05 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-12-19 18:57 8.2dev-500.jdbc3 driver: PreparedStatement.toString() is buggy j.random.programmer <javadesigner@yahoo.com>
2005-12-19 23:28 ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>
2005-12-19 23:36   ` j.random.programmer <javadesigner@yahoo.com>
2005-12-20 07:05     ` Re: 8.2dev-500.jdbc3 driver: PreparedStatement.toString() Oliver Jowett <oliver@opencloud.com>

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