OSDN Git Service

Included is a patch that fixes a bug introduced in the lastest version
authorBruce Momjian <bruce@momjian.us>
Thu, 17 May 2001 04:10:02 +0000 (04:10 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 17 May 2001 04:10:02 +0000 (04:10 +0000)
(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.

Barry Lind

src/interfaces/jdbc/org/postgresql/jdbc1/ResultSet.java
src/interfaces/jdbc/org/postgresql/jdbc2/ResultSet.java

index aae8cf6..467476f 100644 (file)
@@ -488,13 +488,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
 
     SimpleDateFormat df = null;
 
-    if (s.length()>23 && subsecond) {
+    if (sbuf.length()>23 && subsecond) {
       df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSzzzzzzzzz");
-    } else if (s.length()>23 && !subsecond) {
+    } else if (sbuf.length()>23 && !subsecond) {
       df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
-    } else if (s.length()>10 && subsecond) {
+    } else if (sbuf.length()>10 && subsecond) {
       df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-    } else if (s.length()>10 && !subsecond) {
+    } else if (sbuf.length()>10 && !subsecond) {
       df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
     } else {
       df = new SimpleDateFormat("yyyy-MM-dd");
index 54865d8..7aebd95 100644 (file)
@@ -499,13 +499,13 @@ public class ResultSet extends org.postgresql.ResultSet implements java.sql.Resu
       // could optimize this a tad to remove too many object creations...
       SimpleDateFormat df = null;
 
-      if (s.length()>23 && subsecond) {
+      if (sbuf.length()>23 && subsecond) {
         df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSzzzzzzzzz");
-      } else if (s.length()>23 && !subsecond) {
+      } else if (sbuf.length()>23 && !subsecond) {
         df = new SimpleDateFormat("yyyy-MM-dd HH:mm:sszzzzzzzzz");
-      } else if (s.length()>10 && subsecond) {
+      } else if (sbuf.length()>10 && subsecond) {
         df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
-      } else if (s.length()>10 && !subsecond) {
+      } else if (sbuf.length()>10 && !subsecond) {
         df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
       } else {
         df = new SimpleDateFormat("yyyy-MM-dd");