pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Potential inconsistency in handling of timestamps
6+ messages / 3 participants
[nested] [flat]

* Potential inconsistency in handling of timestamps
@ 2007-10-25 22:00 Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
  2007-10-25 22:18 ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Vaibhav Nivargi @ 2007-10-25 22:00 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,
  I am using PG-jdbc-8.2-506 to connect to a Postgres DB with a table
containing a timestamp column. Some entries for this are null. When I
try to retrieve the entries, I get a Bad Value PSQLException for rows
which have the timestamp set to null. I was able to trace it to
org/postgresql/jdbc2/Timestamputils.java: loadCalender() which
explicitly checks whether the timestamp has either a date or time
value, else throws an exception.

OTOH, setting a timestamp to null through jdbc (Update stmt) works
without error. This seems like inconsistent behavior.

Am I missing something? Any special settings for handling null
timestamp/date values?

Thanks in advance,
Vaibhav



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

* Re: Potential inconsistency in handling of timestamps
  2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
@ 2007-10-25 22:18 ` Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:23   ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Oliver Jowett @ 2007-10-25 22:18 UTC (permalink / raw)
  To: Vaibhav Nivargi <vaibhav.nivargi@gmail.com>; +Cc: pgsql-jdbc

Vaibhav Nivargi wrote:
> Hi,
>   I am using PG-jdbc-8.2-506 to connect to a Postgres DB with a table
> containing a timestamp column. Some entries for this are null. When I
> try to retrieve the entries, I get a Bad Value PSQLException for rows
> which have the timestamp set to null. I was able to trace it to
> org/postgresql/jdbc2/Timestamputils.java: loadCalender() which
> explicitly checks whether the timestamp has either a date or time
> value, else throws an exception.
> 
> OTOH, setting a timestamp to null through jdbc (Update stmt) works
> without error. This seems like inconsistent behavior.
> 
> Am I missing something? Any special settings for handling null
> timestamp/date values?

Null values should in theory get handled and returned well before 
TimestampUtils ever gets invoked (see 
AbstractJdbc2ResultSet.getTimestamp()). Can you supply a testcase 
demonstrating the problem?

-O



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

* Re: Potential inconsistency in handling of timestamps
  2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
  2007-10-25 22:18 ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
@ 2007-10-25 22:23   ` Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:30     ` Re: Potential inconsistency in handling of timestamps Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Oliver Jowett @ 2007-10-25 22:23 UTC (permalink / raw)
  To: Vaibhav Nivargi <vaibhav.nivargi@gmail.com>; +Cc: pgsql-jdbc

Oliver Jowett wrote:

> Null values should in theory get handled and returned well before 
> TimestampUtils ever gets invoked (see 
> AbstractJdbc2ResultSet.getTimestamp()). Can you supply a testcase 
> demonstrating the problem?

Actually, it looks like this was fixed in AbstractJdbc2ResultSet r1.95 
(I was looking at CVS HEAD) but not on the 8.2 branch.

Try the 8.3-dev driver or a CVS build?

-O



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

* Re: Potential inconsistency in handling of timestamps
  2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
  2007-10-25 22:18 ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:23   ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
@ 2007-10-25 22:30     ` Kris Jurka <books@ejurka.com>
  2007-10-25 22:37       ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Kris Jurka @ 2007-10-25 22:30 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Vaibhav Nivargi <vaibhav.nivargi@gmail.com>; pgsql-jdbc



On Fri, 26 Oct 2007, Oliver Jowett wrote:

>> Null values should in theory get handled and returned well before 
>> TimestampUtils ever gets invoked (see 
>> AbstractJdbc2ResultSet.getTimestamp()). Can you supply a testcase 
>> demonstrating the problem?
>
> Actually, it looks like this was fixed in AbstractJdbc2ResultSet r1.95 
> (I was looking at CVS HEAD) but not on the 8.2 branch.
>

I don't follow.  The commit you mention was unify the handling of the 
RS.wasNull flag, not changing the handling of null values.  That should be 
caught in TimestampUtils.toTimestamp and friends.

Kris Jurka



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

* Re: Potential inconsistency in handling of timestamps
  2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
  2007-10-25 22:18 ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:23   ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:30     ` Re: Potential inconsistency in handling of timestamps Kris Jurka <books@ejurka.com>
@ 2007-10-25 22:37       ` Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:43         ` Re: Potential inconsistency in handling of timestamps Kris Jurka <books@ejurka.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Oliver Jowett @ 2007-10-25 22:37 UTC (permalink / raw)
  To: Kris Jurka <books@ejurka.com>; +Cc: Vaibhav Nivargi <vaibhav.nivargi@gmail.com>; pgsql-jdbc

Kris Jurka wrote:
> 
> 
> On Fri, 26 Oct 2007, Oliver Jowett wrote:
> 
>>> Null values should in theory get handled and returned well before 
>>> TimestampUtils ever gets invoked (see 
>>> AbstractJdbc2ResultSet.getTimestamp()). Can you supply a testcase 
>>> demonstrating the problem?
>>
>> Actually, it looks like this was fixed in AbstractJdbc2ResultSet r1.95 
>> (I was looking at CVS HEAD) but not on the 8.2 branch.
>>
> 
> I don't follow.  The commit you mention was unify the handling of the 
> RS.wasNull flag, not changing the handling of null values.  That should 
> be caught in TimestampUtils.toTimestamp and friends.

Well, it did change getTimestamp() so it returns null sooner:

http://gborg.postgresql.org/cgi-bin/cvsweb.cgi/pgjdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.ja...

@@ -419,7 +425,9 @@ public abstract class AbstractJdbc2Resul

      public Timestamp getTimestamp(int i, java.util.Calendar cal) 
throws SQLException
      {
-        this.checkResultSet(i);
+        checkResultSet(i);
+        if (wasNullFlag)
+            return null;

          if (cal != null)
              cal = (Calendar)cal.clone();

You're right though, null should be caught by 
TimestampUtils.toTimestamp() too.

Back to looking for a testcase?

-O



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

* Re: Potential inconsistency in handling of timestamps
  2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
  2007-10-25 22:18 ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:23   ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
  2007-10-25 22:30     ` Re: Potential inconsistency in handling of timestamps Kris Jurka <books@ejurka.com>
  2007-10-25 22:37       ` Re: Potential inconsistency in handling of timestamps Oliver Jowett <oliver@opencloud.com>
@ 2007-10-25 22:43         ` Kris Jurka <books@ejurka.com>
  0 siblings, 0 replies; 6+ messages in thread

From: Kris Jurka @ 2007-10-25 22:43 UTC (permalink / raw)
  To: Oliver Jowett <oliver@opencloud.com>; +Cc: Vaibhav Nivargi <vaibhav.nivargi@gmail.com>; pgsql-jdbc



On Fri, 26 Oct 2007, Oliver Jowett wrote:

> You're right though, null should be caught by TimestampUtils.toTimestamp() 
> too.
>
> Back to looking for a testcase?
>

Indeed.  Personally I suspect he doesn't have a timestamp column, but 
something textual and is confused over the difference between NULL and ''. 
Even without a testcase, the complete error message and stack trace should 
include the value he's actualy dealing with and where the driver had 
trouble with it.

Kris Jurka



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


end of thread, other threads:[~2007-10-25 22:43 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2007-10-25 22:00 Potential inconsistency in handling of timestamps Vaibhav Nivargi <vaibhav.nivargi@gmail.com>
2007-10-25 22:18 ` Oliver Jowett <oliver@opencloud.com>
2007-10-25 22:23   ` Oliver Jowett <oliver@opencloud.com>
2007-10-25 22:30     ` Kris Jurka <books@ejurka.com>
2007-10-25 22:37       ` Oliver Jowett <oliver@opencloud.com>
2007-10-25 22:43         ` Kris Jurka <books@ejurka.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