Received: from localhost (maia-2.hub.org [200.46.204.187]) by postgresql.org (Postfix) with ESMTP id 91A369FB491 for ; Mon, 16 Apr 2007 11:22:31 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.187]) (amavisd-maia, port 10024) with ESMTP id 25867-10 for ; Mon, 16 Apr 2007 11:22:18 -0300 (ADT) X-Greylist: delayed 00:06:39.36113 by SQLgrey-1.7.4 Received: from avoltus.com (avoltus.com [83.145.232.56]) by postgresql.org (Postfix) with SMTP id 971359FA38A for ; Mon, 16 Apr 2007 11:22:24 -0300 (ADT) Received: (qmail 25306 invoked by uid 1000); 16 Apr 2007 14:15:41 -0000 Date: Mon, 16 Apr 2007 17:15:41 +0300 From: villeja@avoltus.com To: pgsql-jdbc@postgresql.org Subject: Bug in timezone-parsing? Message-ID: <20070416141541.GA25077@mail> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.9i X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/47 X-Sequence-Number: 16896 Hi! I found a problem with the parsing of timezone-offsets in the current PG-driver. It seems something weird happened between 1921 and 1922, as the offset changes from hour-precision to second-precision: postgres=> select '1921-01-01'::timestamptz, '1922-01-01'::timestamptz; timestamptz | timestamptz ------------------------------+------------------------ 1921-01-01 00:00:00+01:39:52 | 1922-01-01 00:00:00+02 Trying to read a value like this will throw an exception, although the older drivers were able to parse it just fine. Here's the full bugreport: * Timezone: EEST (GMT+2, @DST GMT+3) * JDBC driver build number: - works: pg74.216.jdbc3.jar - works: postgresql-8.0-318.jdbc3.jar - fails: postgresql-8.1-408.jdbc3.jar - fails: postgresql-8.2-504.jdbc3.jar - fails: CVS 07. April 2007 13:32 * Server version: - PostgreSQL 8.2.3 (vanilla from postgresql.org) * Java version (Linux 2.6.8/x86): - fails: Sun 1.4.2_09-b05 - fails: Sun 1.5.0_06-b05 - fails: Sun 1.6.0-b105 * Exact error message and stacktrace: Exception in thread "main" org.postgresql.util.PSQLException: Bad value for type timestamp : 1921-01-01 00:00:00+01:39:52 at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:232) at org.postgresql.jdbc2.TimestampUtils.toTimestamp(TimestampUtils.java:307) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getTimestamp(AbstractJdbc2ResultSet.java:419) at org.postgresql.jdbc2.AbstractJdbc2ResultSet.getTimestamp(AbstractJdbc2ResultSet.java:2352) at Offset.main(Offset.java:22) Caused by: java.lang.NumberFormatException: Trailing junk on timestamp: '' at org.postgresql.jdbc2.TimestampUtils.loadCalendar(TimestampUtils.java:226) ... * What you were doing, ideally in code form: import java.sql.*; public final class Offset { public final static void main(String argv[]) throws Exception { // configure before running! String url = "jdbc:postgresql://localhost:5432/postgres"; String user = ""; String pass = ""; String query = "select '1921-01-01'::timestamptz as ts"; Class.forName("org.postgresql.Driver").newInstance(); Connection connection = null; Statement statement = null; ResultSet rs = null; try { connection = DriverManager.getConnection(url, user, pass); statement = connection.createStatement(); rs = statement.executeQuery(query); while (rs.next()) System.out.println(rs.getTimestamp(1)); } finally { if (rs != null) rs.close(); if (statement != null) statement.close(); if (connection != null) connection.close(); } } }; -Ville