Question about inscrutable cast syntax

Started by Kevin Murphyover 17 years ago2 messagesgeneral
Jump to latest
#1Kevin Murphy
murphy@genome.chop.edu

Two versions of an application differ in the way a particular column is
defined.

OLD:

lastupdated timestamp without time zone DEFAULT
('now'::text)::timestamp(6) with time zone NOT NULL

NEW:

lastupdated timestamp without time zone DEFAULT now() NOT NULL

I believe these are both the result of an automatic mysql-to-postgresql
conversion process rather than hand-coded.

For my personal edification, I'd like to understand what's going on with
that first one! Note that the column type is timestamp without time
zone, so I'm also curious about the 'with time zone' modifier in the
first example.

Thanks,
Kevin Murphy

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Kevin Murphy (#1)
Re: Question about inscrutable cast syntax

Kevin Murphy <murphy@genome.chop.edu> writes:

lastupdated timestamp without time zone DEFAULT
('now'::text)::timestamp(6) with time zone NOT NULL

For my personal edification, I'd like to understand what's going on with
that first one!

It's what the PG grammar converts CURRENT_TIMESTAMP(6) into.

(We really ought to do a better job of hiding that from the user...)

regards, tom lane