Re: Patch for jdbc ResultSet.getTimestamp()

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Barry Lind <barry(at)xythos(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: Patch for jdbc ResultSet.getTimestamp()
Date: 2001-05-17 04:09:17
Message-ID: 200105170409.f4H49HE08629@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


Patch applied, and backpatched to jdbc1. Can't apply to 7.1.X. That
jdbc code is pretty much frozen. We have had too much breakage of jdbc
code to apply this to 7.1.X.

However, we are working on patching the CVS and should have jar files
available for people to use soon.

>
> Included is a patch that fixes a bug introduced in the lastest version
> (1.22) of interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java. That
> change removed a line that set the variable s to the value of the
> stringbuffer. This fix changes the following if checks to check the
> length of the stringbuffer instead of s, since s no longer contains the
> string the if conditions are expecting.
>
> The bug manifests itself in getTimestamp() loosing the timezone
> information of timestamps selected from the database, thereby causing
> the time to be incorrect.
>
> If possible this patch should be patched into 7.1 for the upcoming 7.1.2
> patch.
>
> thanks,
> --Barry

> *** ./interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java.orig Tue May 15 21:59:46 2001
> --- ./interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java Tue May 15 22:06:43 2001
> ***************
> *** 499,511 ****
> // could optimize this a tad to remove too many object creations...
> SimpleDateFormat df = null;
>
> ! if (s.length()>23 && subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSzzzzzzzzz");
> ! } else if (s.length()>23 && !subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
> ! } else if (s.length()>10 && subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
> ! } else if (s.length()>10 && !subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> } else {
> df = new SimpleDateFormat("yyyy-MM-dd");
> --- 499,511 ----
> // could optimize this a tad to remove too many object creations...
> SimpleDateFormat df = null;
>
> ! if (sbuf.length()>23 && subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSzzzzzzzzz");
> ! } else if (sbuf.length()>23 && !subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
> ! } else if (sbuf.length()>10 && subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
> ! } else if (sbuf.length()>10 && !subsecond) {
> df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
> } else {
> df = new SimpleDateFormat("yyyy-MM-dd");

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Thomas Lockhart 2001-05-17 04:09:32 Re: Patch for jdbc ResultSet.getTimestamp()
Previous Message Bruce Momjian 2001-05-17 03:22:26 Fix for ANT ane 'make clean'