Re: Bug #605: timestamp(timestamp('a timestamp)) no longer works

From: Andrew McMillan <andrew(at)catalyst(dot)net(dot)nz>
To: lockhart(at)fourpalms(dot)org
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #605: timestamp(timestamp('a timestamp)) no longer works
Date: 2002-03-01 23:56:22
Message-ID: 1015026982.19662.2824.camel@kant.mcmillan.net.nz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

On Sat, 2002-03-02 at 04:16, Thomas Lockhart wrote:
> > timestamp(timestamp('a timestamp)) no longer works
> > I do this reasonably often in my code by way of being paranoid
> > that I might have a date, or a time, where I for sure _really_
> > want it to be a timestamp...
> > pcnz=# select timestamp('2002-03-01'::timestamp);
> > ERROR: parser: parse error at or near "'"
>
> You *can* coerce timestamps to be timestamps, but in 7.2 non-standard
> syntax no longer works to do this. The reason is that "timestamp(p)" now
> follows the SQL9x usage of defining a timestamp type with precision "p".
> So trying to call a function "timestamp()" no longer works as it did.
>
> You can use SQL9x syntax for the type coersion:
>
> select cast('2002-03-01'::timestamp as timestamp);
>
> or (not recommended) you can cheat and force the call to the function by
> surrounding it in double-quotes:
>
> select "timestamp"('2002-03-01'::timestamp);

Thanks Thomas,

I wasn't aware of that SQL9x timestamp precision, which was why it
seemed like a strange change to me.

Sorry to have not read the migration issues before filing this - I
thought from following these mailing lists that I knew them already :-)

Cheers,
Andrew.
--
--------------------------------------------------------------------
Andrew @ Catalyst .Net.NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
Are you enrolled at http://schoolreunions.co.nz/ yet?

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Steven N=?ISO-8859-1?B?+vE=?=ez 2002-03-02 04:02:49 Gmake check problem
Previous Message Tom Lane 2002-03-01 21:03:43 Re: SELECT statement causing terminating the backend

Browse pgsql-hackers by date

  From Date Subject
Next Message Tatsuo Ishii 2002-03-02 02:29:53 Re: timestamp_part() bug?
Previous Message Greg Copeland 2002-03-01 23:06:20 Re: Database Caching