Skip site navigation (1) Skip section navigation (2)

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

From: Thomas Lockhart <lockhart(at)fourpalms(dot)org>
To: andrew(at)catalyst(dot)net(dot)nz, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Bug #605: timestamp(timestamp('a timestamp)) no longer works
Date: 2002-03-01 15:16:23
Message-ID: 3C7F9B47.184FAE8@fourpalms.org (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
> 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);

hth

                      - Thomas

In response to

Responses

pgsql-hackers by date

Next:From: Jan WieckDate: 2002-03-01 15:17:57
Subject: Re: Database Caching
Previous:From: Bruce MomjianDate: 2002-03-01 15:15:29
Subject: Re: elog() patch

pgsql-bugs by date

Next:From: Thomas LockhartDate: 2002-03-01 15:21:01
Subject: Re: Bug #605: timestamp(timestamp('a timestamp)) no longer works
Previous:From: Tom LaneDate: 2002-03-01 15:03:41
Subject: Re: Bug #605: timestamp(timestamp('a timestamp)) no longer works

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group