Re: PreparedStatement.setDate() behavior with OVERLAPS

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Christopher BROWN <brown(at)reflexe(dot)fr>, List <pgsql-jdbc(at)postgresql(dot)org>
Subject: Re: PreparedStatement.setDate() behavior with OVERLAPS
Date: 2015-08-11 14:52:12
Message-ID: CADK3HHKZcCOQkbtwiRGfOK0nKRX5DzPnzM_DaOL+B8RM8mjh5A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Here are the comments in the code.

// We must use UNSPECIFIED here, or inserting a Date-with-timezone into a

// timestamptz field does an unexpected rotation by the server's
TimeZone:

//

// We want to interpret 2005/01/01 with calendar +0100 as

// "local midnight in +0100", but if we go via date it interprets it

// as local midnight in the server's timezone:

// template1=# select '2005-01-01+0100'::timestamptz;

// timestamptz

// ------------------------

// 2005-01-01 02:00:00+03

// (1 row)

// template1=# select '2005-01-01+0100'::date::timestamptz;

// timestamptz

// ------------------------

// 2005-01-01 00:00:00+03

// (1 row)

Apparently while dates don't store timezone information we do accept
timezone info in date literals ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 11 August 2015 at 10:49, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:

> It strikes me that maybe the root problem is that Christopher is doing
> things in such an order that the server is asked to parse the SQL string
> before the setDate() is done. Don't know enough details about JDBC to
> translate that idea into code, though.
>
> regards, tom lane
>

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Tom Lane 2015-08-11 15:00:09 Re: PreparedStatement.setDate() behavior with OVERLAPS
Previous Message Tom Lane 2015-08-11 14:49:27 Re: PreparedStatement.setDate() behavior with OVERLAPS