Re: BUG #15145: date time default value issues - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #15145: date time default value issues
Date
Msg-id 1546.1523110458@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #15145: date time default value issues  ("David G. Johnston" <david.g.johnston@gmail.com>)
List pgsql-bugs
"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Friday, April 6, 2018, PG Bug reporting form <noreply@postgresql.org>
> wrote:
>> i set column "document_datenow timestamp with time zone NOT NULL DEFAULT
>> now()"
>> but the values that like this "0001-12-31 23:42:04+06:42:04 BC"

> This is so unusual I don't know really where to start.

Poking about in the tz database, I notice that +06:42:04 is the UTC offset
shown for Asia/Bangkok before 1920 (ie, before adoption of a standard time
zone offset).  So, if the database's time zone were set to Asia/Bangkok
and then you put in a time around the start of the common era:

regression=# set timezone = 'Asia/Bangkok';
SET
regression=# select '0001-12-31 17:00 UTC BC'::timestamptz;
           timestamptz           
---------------------------------
 0001-12-31 23:42:04+06:42:04 BC
(1 row)

Now this just moves the mystery to another place: how'd that value get
entered?  I'd speculate about perhaps using to_timestamp() with a wrong
format string, causing what should have been year 2001 to be read as 0001,
or something like that.  The OP hasn't shown us what he did to enter this
value, so it's all speculation.  The table definition is nigh irrelevant,
though :-(

            regards, tom lane


pgsql-bugs by date:

Previous
From: Marko Tiikkaja
Date:
Subject: Re: BUG #15145: date time default value issues
Next
From: Tom Lane
Date:
Subject: Re: BUG #14999: pg_rewind corrupts control file global/pg_control