[libpostgresql-jdbc-java] 02/09: Restore the ability for the JDBC driver to map infinite timestamp values by using special constants in PGStatement. The original implementation was removed for being arbitrary and unidirectional.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:10 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL8_0_311
in repository libpostgresql-jdbc-java.

commit 1bcec79f2577c3f10d2a062ae72a1c5b7e5070bb
Author: Kris Jurka <books at ejurka.com>
Date:   Tue Feb 15 08:32:17 2005 +0000

    Restore the ability for the JDBC driver to map infinite timestamp
    values by using special constants in PGStatement.  The original
    implementation was removed for being arbitrary and unidirectional.
    
    Oliver Siegmar
---
 org/postgresql/PGStatement.java                  |  11 +-
 org/postgresql/jdbc2/AbstractJdbc2Statement.java |  11 +-
 org/postgresql/jdbc2/TimestampUtils.java         |  68 ++++++++---
 org/postgresql/test/jdbc2/TimestampTest.java     | 138 ++++++++++++++++++++++-
 4 files changed, 206 insertions(+), 22 deletions(-)

diff --git a/org/postgresql/PGStatement.java b/org/postgresql/PGStatement.java
index 85c2e31..0a87548 100644
--- a/org/postgresql/PGStatement.java
+++ b/org/postgresql/PGStatement.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/PGStatement.java,v 1.12 2004/11/09 08:43:50 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/PGStatement.java,v 1.13 2005/01/11 08:25:43 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -18,6 +18,15 @@ import java.sql.*;
  */
 public interface PGStatement
 {
+    // We can't use Long.MAX_VALUE or Long.MIN_VALUE for java.sql.date
+    // because this would break the 'normalization contract' of the
+    // java.sql.Date API.
+    // The follow values are the nearest MAX/MIN values with hour,
+    // minute, second, millisecond set to 0 - this is used for
+    // -infinity / infinity representation in Java
+    public static final long DATE_POSITIVE_INFINITY = 9223372036825200000l;
+    public static final long DATE_NEGATIVE_INFINITY = -9223372036832400000l;
+
 
     /**
      * Returns the Last inserted/updated oid.
diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 844f049..0869f27 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.67 2005/01/27 11:30:41 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.68 2005/02/01 07:27:54 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -21,6 +21,7 @@ import java.util.Calendar;
 import java.util.GregorianCalendar;
 
 import org.postgresql.Driver;
+import org.postgresql.PGStatement;
 import org.postgresql.largeobject.*;
 import org.postgresql.core.*;
 import org.postgresql.util.PSQLException;
@@ -2840,6 +2841,14 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
     static java.util.Calendar changeTime(java.util.Date t, java.util.Calendar cal, boolean Add)
     {
         long millis = t.getTime();
+
+        if (millis == PGStatement.DATE_POSITIVE_INFINITY ||
+            millis == PGStatement.DATE_NEGATIVE_INFINITY)
+        {
+            cal.setTimeInMillis(millis);
+            return cal;
+        }
+
         int localoffset = t.getTimezoneOffset() * 60 * 1000 * -1;
         int caloffset = cal.getTimeZone().getRawOffset();
         if (cal.getTimeZone().inDaylightTime(t))
diff --git a/org/postgresql/jdbc2/TimestampUtils.java b/org/postgresql/jdbc2/TimestampUtils.java
index c9ca313..94df030 100644
--- a/org/postgresql/jdbc2/TimestampUtils.java
+++ b/org/postgresql/jdbc2/TimestampUtils.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2003-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TimestampUtils.java,v 1.11 2005/01/11 08:25:46 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/TimestampUtils.java,v 1.12 2005/01/14 01:20:20 oliver Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -16,6 +16,7 @@ import java.util.GregorianCalendar;
 import java.util.TimeZone;
 import java.util.SimpleTimeZone;
 
+import org.postgresql.PGStatement;
 import org.postgresql.util.GT;
 import org.postgresql.util.PSQLState;
 import org.postgresql.util.PSQLException;
@@ -26,7 +27,6 @@ import org.postgresql.util.PSQLException;
  */
 public class TimestampUtils {
 
-
     /**
      * Load date/time information into the provided calendar
      * returning the fractional seconds.
@@ -34,13 +34,6 @@ public class TimestampUtils {
     private static int loadCalendar(GregorianCalendar cal, String s, String type) throws SQLException {
         int slen = s.length();
 
-        // java doesn't have a concept of postgres's infinity
-        // so there's not much we can do here.
-        if ((slen == 8 && s.equals("infinity")) || (slen == 9 && s.equals("-infinity"))) {
-            throw new PSQLException(GT.tr("Infinite value found for timestamp.  Java has no corresponding representation."),
-                                    PSQLState.DATETIME_OVERFLOW);
-        }
-
         // Zero out all the fields.
         cal.setTime(new java.util.Date(0));
 
@@ -179,6 +172,17 @@ public class TimestampUtils {
         if (s == null)
             return null;
 
+        int slen = s.length();
+
+        // convert postgres's infinity values to internal infinity magic value
+        if (slen == 8 && s.equals("infinity")) {
+            return new Timestamp(PGStatement.DATE_POSITIVE_INFINITY);
+        }
+
+        if (slen == 9 && s.equals("-infinity")) {
+            return new Timestamp(PGStatement.DATE_NEGATIVE_INFINITY);
+        }
+
         synchronized(cal) {
             cal.set(Calendar.ZONE_OFFSET, 0);
             cal.set(Calendar.DST_OFFSET, 0);
@@ -195,6 +199,15 @@ public class TimestampUtils {
         if (s == null)
             return null;
 
+        int slen = s.length();
+
+        // infinity cannot be represented as Time
+        // so there's not much we can do here.
+        if ((slen == 8 && s.equals("infinity")) || (slen == 9 && s.equals("-infinity"))) {
+            throw new PSQLException(GT.tr("Infinite value found for timestamp/date. This cannot be represented as time."),
+                                    PSQLState.DATETIME_OVERFLOW);
+        }
+
         synchronized(cal) {
             cal.set(Calendar.ZONE_OFFSET, 0);
             cal.set(Calendar.DST_OFFSET, 0);
@@ -215,6 +228,17 @@ public class TimestampUtils {
         if (s == null)
             return null;
 
+        int slen = s.length();
+
+        // convert postgres's infinity values to internal infinity magic value
+        if (slen == 8 && s.equals("infinity")) {
+            return new Date(PGStatement.DATE_POSITIVE_INFINITY);
+        }
+
+        if (slen == 9 && s.equals("-infinity")) {
+            return new Date(PGStatement.DATE_NEGATIVE_INFINITY);
+        }
+
         synchronized(cal) {
             cal.set(Calendar.ZONE_OFFSET, 0);
             cal.set(Calendar.DST_OFFSET, 0);
@@ -236,11 +260,17 @@ public class TimestampUtils {
                 cal.setTime(x);
                 sbuf.setLength(0);
 
-                appendDate(sbuf, cal);
-                sbuf.append(' ');
-                appendTime(sbuf, cal, x.getNanos());
-                appendTimeZone(sbuf, x);
-                appendEra(sbuf, cal);
+                if (x.getTime() == PGStatement.DATE_POSITIVE_INFINITY) {
+                    sbuf.append("infinity");
+                } else if (x.getTime() == PGStatement.DATE_NEGATIVE_INFINITY) {
+                    sbuf.append("-infinity");
+                } else {
+                    appendDate(sbuf, cal);
+                    sbuf.append(' ');
+                    appendTime(sbuf, cal, x.getNanos());
+                    appendTimeZone(sbuf, x);
+                    appendEra(sbuf, cal);
+                }
                 return sbuf.toString();
             }
         }
@@ -252,8 +282,14 @@ public class TimestampUtils {
                 cal.setTime(x);
                 sbuf.setLength(0);
 
-                appendDate(sbuf, cal);
-                appendEra(sbuf, cal);
+                if (x.getTime() == PGStatement.DATE_POSITIVE_INFINITY) {
+                    sbuf.append("infinity");
+                } else if (x.getTime() == PGStatement.DATE_NEGATIVE_INFINITY) {
+                    sbuf.append("-infinity");
+                } else {
+                    appendDate(sbuf, cal);
+                    appendEra(sbuf, cal);
+                }
                 return sbuf.toString();
             }
         }
diff --git a/org/postgresql/test/jdbc2/TimestampTest.java b/org/postgresql/test/jdbc2/TimestampTest.java
index 3b51a78..7b9dab5 100644
--- a/org/postgresql/test/jdbc2/TimestampTest.java
+++ b/org/postgresql/test/jdbc2/TimestampTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/TimestampTest.java,v 1.16 2004/11/09 08:55:15 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/TimestampTest.java,v 1.17 2005/01/11 08:25:48 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -11,7 +11,13 @@ package org.postgresql.test.jdbc2;
 
 import org.postgresql.test.TestUtil;
 import junit.framework.TestCase;
+
 import java.sql.*;
+import java.util.TimeZone;
+import java.util.GregorianCalendar;
+
+import org.postgresql.PGStatement;
+import org.postgresql.jdbc2.TimestampUtils;
 
 /*
  * Test get/setTimestamp for both timestamp with time zone and
@@ -42,6 +48,59 @@ public class TimestampTest extends TestCase
         TestUtil.closeDB(con);
     }
 
+    public void testInfinity() throws SQLException
+    {
+        runInfinityTests(TSWTZ_TABLE, PGStatement.DATE_POSITIVE_INFINITY);
+        runInfinityTests(TSWTZ_TABLE, PGStatement.DATE_NEGATIVE_INFINITY);
+        runInfinityTests(TSWOTZ_TABLE, PGStatement.DATE_POSITIVE_INFINITY);
+        runInfinityTests(TSWOTZ_TABLE, PGStatement.DATE_NEGATIVE_INFINITY);
+    }
+
+    private void runInfinityTests(String table, long value) throws SQLException
+    {
+        GregorianCalendar cal = new GregorianCalendar();
+        // Pick some random timezone that is hopefully different than ours
+        // and exists in this JVM.
+        cal.setTimeZone(TimeZone.getTimeZone("Europe/Warsaw"));
+
+        String strValue;
+        if (value == PGStatement.DATE_POSITIVE_INFINITY) {
+            strValue = "infinity";
+        } else {
+            strValue = "-infinity";
+        }
+
+        Statement stmt = con.createStatement();
+        stmt.executeUpdate(TestUtil.insertSQL(table, "'" + strValue + "'"));
+        stmt.close();
+
+        PreparedStatement ps = con.prepareStatement(TestUtil.insertSQL(table, "?"));
+        ps.setTimestamp(1, new Timestamp(value));
+        ps.executeUpdate();
+        ps.setTimestamp(1, new Timestamp(value), cal);
+        ps.executeUpdate();
+        ps.close();
+
+        stmt = con.createStatement();
+        ResultSet rs = stmt.executeQuery("select ts from " + table);
+        while (rs.next()) {
+            assertEquals(strValue, rs.getString(1));
+
+            Timestamp ts = rs.getTimestamp(1);
+            assertEquals(value, ts.getTime());
+
+            Date d = rs.getDate(1);
+            assertEquals(value, d.getTime());
+
+            Timestamp tscal = rs.getTimestamp(1, cal);
+            assertEquals(value, tscal.getTime());
+        }
+        rs.close();
+
+        assertEquals(3, stmt.executeUpdate("DELETE FROM " + table));
+        stmt.close();
+    }
+
     /*
      * Tests the timestamp methods in ResultSet on timestamp with time zone
       * we insert a known string value (don't use setTimestamp) then see that 
@@ -167,27 +226,37 @@ public class TimestampTest extends TestCase
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS2WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS3WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS4WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS5WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS6WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS1WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS2WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS3WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS4WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS5WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS6WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS1WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS2WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS3WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS4WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS5WOTZ_PGFORMAT + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TS6WOTZ_PGFORMAT + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpDate1WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpDate2WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpDate3WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpDate4WOTZ.getTime()) + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TimestampUtils.toString(new StringBuffer(), new GregorianCalendar(), new java.sql.Timestamp(tmpDate5WOTZ.getTime())) + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TimestampUtils.toString(new StringBuffer(), new GregorianCalendar(), new java.sql.Timestamp(tmpDate6WOTZ.getTime())) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpTime1WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpTime2WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpTime3WOTZ.getTime()) + "'")));
         assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + new java.sql.Timestamp(tmpTime4WOTZ.getTime()) + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TimestampUtils.toString(new StringBuffer(), new GregorianCalendar(), new java.sql.Timestamp(tmpTime5WOTZ.getTime())) + "'")));
+        assertEquals(1, stmt.executeUpdate(TestUtil.insertSQL(TSWOTZ_TABLE, "'" + TimestampUtils.toString(new StringBuffer(), new GregorianCalendar(), new java.sql.Timestamp(tmpTime6WOTZ.getTime())) + "'")));
 
         // Fall through helper
         timestampTestWOTZ();
 
-        assertEquals(20, stmt.executeUpdate("DELETE FROM " + TSWOTZ_TABLE));
+        assertEquals(30, stmt.executeUpdate("DELETE FROM " + TSWOTZ_TABLE));
 
         stmt.close();
     }
@@ -215,6 +284,11 @@ public class TimestampTest extends TestCase
         pstmt.setTimestamp(1, TS4WOTZ);
         assertEquals(1, pstmt.executeUpdate());
 
+        pstmt.setTimestamp(1, TS5WOTZ);
+        assertEquals(1, pstmt.executeUpdate());
+
+        pstmt.setTimestamp(1, TS6WOTZ);
+        assertEquals(1, pstmt.executeUpdate());
 
         // With java.sql.Timestamp
         pstmt.setObject(1, TS1WOTZ, java.sql.Types.TIMESTAMP);
@@ -225,6 +299,10 @@ public class TimestampTest extends TestCase
         assertEquals(1, pstmt.executeUpdate());
         pstmt.setObject(1, TS4WOTZ, java.sql.Types.TIMESTAMP);
         assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, TS5WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, TS6WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
 
         // With Strings
         pstmt.setObject(1, TS1WOTZ_PGFORMAT, java.sql.Types.TIMESTAMP);
@@ -235,6 +313,10 @@ public class TimestampTest extends TestCase
         assertEquals(1, pstmt.executeUpdate());
         pstmt.setObject(1, TS4WOTZ_PGFORMAT, java.sql.Types.TIMESTAMP);
         assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, TS5WOTZ_PGFORMAT, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, TS6WOTZ_PGFORMAT, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
 
         // With java.sql.Date
         pstmt.setObject(1, tmpDate1WOTZ, java.sql.Types.TIMESTAMP);
@@ -245,6 +327,10 @@ public class TimestampTest extends TestCase
         assertEquals(1, pstmt.executeUpdate());
         pstmt.setObject(1, tmpDate4WOTZ, java.sql.Types.TIMESTAMP);
         assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, tmpDate5WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, tmpDate6WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
 
         // With java.sql.Time
         pstmt.setObject(1, tmpTime1WOTZ, java.sql.Types.TIMESTAMP);
@@ -255,10 +341,14 @@ public class TimestampTest extends TestCase
         assertEquals(1, pstmt.executeUpdate());
         pstmt.setObject(1, tmpTime4WOTZ, java.sql.Types.TIMESTAMP);
         assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, tmpTime5WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
+        pstmt.setObject(1, tmpTime6WOTZ, java.sql.Types.TIMESTAMP);
+        assertEquals(1, pstmt.executeUpdate());
         // Fall through helper
         timestampTestWOTZ();
 
-        assertEquals(20, stmt.executeUpdate("DELETE FROM " + TSWOTZ_TABLE));
+        assertEquals(30, stmt.executeUpdate("DELETE FROM " + TSWOTZ_TABLE));
 
         pstmt.close();
         stmt.close();
@@ -380,6 +470,16 @@ public class TimestampTest extends TestCase
             t = rs.getTimestamp(1);
             assertNotNull(t);
             assertTrue(t.equals(TS4WOTZ));
+
+            assertTrue(rs.next());
+            t = rs.getTimestamp(1);
+            assertNotNull(t);
+            assertTrue(t.equals(TS5WOTZ));
+
+            assertTrue(rs.next());
+            t = rs.getTimestamp(1);
+            assertNotNull(t);
+            assertTrue(t.equals(TS6WOTZ));
         }
 
         // Testing for Date
@@ -403,6 +503,16 @@ public class TimestampTest extends TestCase
         assertNotNull(t);
         assertEquals(tmpDate4WOTZ.getTime(), t.getTime());
 
+        assertTrue(rs.next());
+        t = rs.getTimestamp(1);
+        assertNotNull(t);
+        assertEquals(tmpDate5WOTZ.getTime(), t.getTime());
+
+        assertTrue(rs.next());
+        t = rs.getTimestamp(1);
+        assertNotNull(t);
+        assertEquals(tmpDate6WOTZ.getTime(), t.getTime());
+
         // Testing for Time
         assertTrue(rs.next());
         t = rs.getTimestamp(1);
@@ -424,6 +534,16 @@ public class TimestampTest extends TestCase
         assertNotNull(t);
         assertEquals(tmpTime4WOTZ.getTime(), t.getTime());
 
+        assertTrue(rs.next());
+        t = rs.getTimestamp(1);
+        assertNotNull(t);
+        assertEquals(tmpTime5WOTZ.getTime(), t.getTime());
+
+        assertTrue(rs.next());
+        t = rs.getTimestamp(1);
+        assertNotNull(t);
+        assertEquals(tmpTime6WOTZ.getTime(), t.getTime());
+        
         assertTrue(! rs.next()); // end of table. Fail if more entries exist.
 
         rs.close();
@@ -463,7 +583,7 @@ public class TimestampTest extends TestCase
         }
         return l_return;
     }
-
+    
     private static final java.sql.Timestamp TS1WTZ = getTimestamp(1950, 2, 7, 15, 0, 0, 100000000, "PST");
     private static final String TS1WTZ_PGFORMAT = "1950-02-07 15:00:00.1-08";
 
@@ -489,6 +609,12 @@ public class TimestampTest extends TestCase
     private static final java.sql.Timestamp TS4WOTZ = getTimestamp(2000, 7, 7, 15, 0, 0, 123456000, null);
     private static final String TS4WOTZ_PGFORMAT = "2000-07-07 15:00:00.123456";
 
+    private static final java.sql.Timestamp TS5WOTZ = new Timestamp(PGStatement.DATE_NEGATIVE_INFINITY);
+    private static final String TS5WOTZ_PGFORMAT = "-infinity";
+
+    private static final java.sql.Timestamp TS6WOTZ = new Timestamp(PGStatement.DATE_POSITIVE_INFINITY);
+    private static final String TS6WOTZ_PGFORMAT = "infinity";
+
     private static final String TSWTZ_TABLE = "testtimestampwtz";
     private static final String TSWOTZ_TABLE = "testtimestampwotz";
 
@@ -509,6 +635,10 @@ public class TimestampTest extends TestCase
     private static final java.sql.Time tmpTime3WOTZ = new java.sql.Time(TS3WOTZ.getTime());
     private static final java.sql.Date tmpDate4WOTZ = new java.sql.Date(TS4WOTZ.getTime());
     private static final java.sql.Time tmpTime4WOTZ = new java.sql.Time(TS4WOTZ.getTime());
+    private static final java.sql.Date tmpDate5WOTZ = new java.sql.Date(TS5WOTZ.getTime());
+    private static final java.sql.Date tmpTime5WOTZ = new java.sql.Date(TS5WOTZ.getTime());
+    private static final java.sql.Date tmpDate6WOTZ = new java.sql.Date(TS6WOTZ.getTime());
+    private static final java.sql.Date tmpTime6WOTZ = new java.sql.Date(TS6WOTZ.getTime());
 
 
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list