pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #15145: date time default value issues
5+ messages / 4 participants
[nested] [flat]

* BUG #15145: date time default value issues
@ 2018-04-07 04:22 PG Bug reporting form <noreply@postgresql.org>
  2018-04-07 05:29 ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 5+ messages in thread

From: PG Bug reporting form @ 2018-04-07 04:22 UTC (permalink / raw)
  To: pgsql-bugs@lists.postgresql.org; +Cc: dibxyooj96@gmail.com

The following bug has been logged on the website:

Bug reference:      15145
Logged by:          Paj Dib Xyooj
Email address:      dibxyooj96@gmail.com
PostgreSQL version: 9.4.5
Operating system:   (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
Description:        

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"



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15145: date time default value issues
  2018-04-07 04:22 BUG #15145: date time default value issues PG Bug reporting form <noreply@postgresql.org>
@ 2018-04-07 05:29 ` David G. Johnston <david.g.johnston@gmail.com>
  2018-04-07 09:35   ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
  2018-04-07 14:14   ` Re: BUG #15145: date time default value issues Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 5+ messages in thread

From: David G. Johnston @ 2018-04-07 05:29 UTC (permalink / raw)
  To: dibxyooj96@gmail.com <dibxyooj96@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Friday, April 6, 2018, PG Bug reporting form <noreply@postgresql.org>
wrote:

> The following bug has been logged on the website:
>
> Bug reference:      15145
> Logged by:          Paj Dib Xyooj
> Email address:      dibxyooj96@gmail.com
> PostgreSQL version: 9.4.5
> Operating system:   (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
> Description:
>
> 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"
>

What does typing "date" at your o/s command line show?

This is so unusual I don't know really where to start.  But 9.4.5 is an
unsupported minor release and your O/S version seems older as well.  If
this isn't a production machine you need to diagnose I'd suggest installing
recent O/S and PostgreSQL, possibly from packages, and save yourself some
grief.  Otherwise, after upgrading to 9.4.17 (though I would backup the
existing binaries just in case) you probably should volunteer considerably
more detail about your environment and what you were doing to it before you
discovered this behavior.  Providing a self-contained script and output
transcript would be good too.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15145: date time default value issues
  2018-04-07 04:22 BUG #15145: date time default value issues PG Bug reporting form <noreply@postgresql.org>
  2018-04-07 05:29 ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
@ 2018-04-07 09:35   ` David G. Johnston <david.g.johnston@gmail.com>
  2018-04-07 10:08     ` Re: BUG #15145: date time default value issues Marko Tiikkaja <marko@joh.to>
  1 sibling, 1 reply; 5+ messages in thread

From: David G. Johnston @ 2018-04-07 09:35 UTC (permalink / raw)
  To: dibxyooj96@gmail.com <dibxyooj96@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Friday, April 6, 2018, David G. Johnston <david.g.johnston@gmail.com>
wrote:

> On Friday, April 6, 2018, PG Bug reporting form <noreply@postgresql.org>
> wrote:
>
>> The following bug has been logged on the website:
>>
>> Bug reference:      15145
>> Logged by:          Paj Dib Xyooj
>> Email address:      dibxyooj96@gmail.com
>> PostgreSQL version: 9.4.5
>> Operating system:   (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
>> Description:
>>
>> 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"
>>
>
> What does typing "date" at your o/s command line show?
>
>
So, that a constant time is used is not unusual, it's documented.  Now() is
a function that gets resolved at default creation.  You need to use
"current_timestamp" literal special value if you want insertion time
defaults.   But since you didn't create the table in BC with an odd time
zone offset either you gave bad example or there is still something wrong
in your environment.

David J.

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15145: date time default value issues
  2018-04-07 04:22 BUG #15145: date time default value issues PG Bug reporting form <noreply@postgresql.org>
  2018-04-07 05:29 ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
  2018-04-07 09:35   ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
@ 2018-04-07 10:08     ` Marko Tiikkaja <marko@joh.to>
  0 siblings, 0 replies; 5+ messages in thread

From: Marko Tiikkaja @ 2018-04-07 10:08 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: dibxyooj96@gmail.com <dibxyooj96@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

On Sat, Apr 7, 2018 at 12:35 PM, David G. Johnston <
david.g.johnston@gmail.com> wrote:

> On Friday, April 6, 2018, David G. Johnston <david.g.johnston@gmail.com>
> wrote:
>
>> On Friday, April 6, 2018, PG Bug reporting form <noreply@postgresql.org>
>> wrote:
>>
>>> The following bug has been logged on the website:
>>>
>>> Bug reference:      15145
>>> Logged by:          Paj Dib Xyooj
>>> Email address:      dibxyooj96@gmail.com
>>> PostgreSQL version: 9.4.5
>>> Operating system:   (Ubuntu 4.8.2-19ubuntu1) 4.8.2, 64-bit
>>> Description:
>>>
>>> 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"
>>>
>>
>> What does typing "date" at your o/s command line show?
>>
>>
> So, that a constant time is used is not unusual, it's documented.  Now()
> is a function that gets resolved at default creation.
>

That's not correct.  You're thinking of  DEFAULT 'now'.  DEFAULT now()
works just fine.


.m

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #15145: date time default value issues
  2018-04-07 04:22 BUG #15145: date time default value issues PG Bug reporting form <noreply@postgresql.org>
  2018-04-07 05:29 ` Re: BUG #15145: date time default value issues David G. Johnston <david.g.johnston@gmail.com>
@ 2018-04-07 14:14   ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Tom Lane @ 2018-04-07 14:14 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: dibxyooj96@gmail.com <dibxyooj96@gmail.com>; pgsql-bugs@lists.postgresql.org <pgsql-bugs@lists.postgresql.org>

"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




^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2018-04-07 14:14 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-04-07 04:22 BUG #15145: date time default value issues PG Bug reporting form <noreply@postgresql.org>
2018-04-07 05:29 ` David G. Johnston <david.g.johnston@gmail.com>
2018-04-07 09:35   ` David G. Johnston <david.g.johnston@gmail.com>
2018-04-07 10:08     ` Marko Tiikkaja <marko@joh.to>
2018-04-07 14:14   ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox