Re: 9.2 timestamp function syntax error - Mailing list pgsql-general

From Tom Lane
Subject Re: 9.2 timestamp function syntax error
Date
Msg-id 11816.1362508023@sss.pgh.pa.us
Whole thread Raw
In response to Re: 9.2 timestamp function syntax error  (Guy Rouillier <guy.rouillier@gmail.com>)
List pgsql-general
Guy Rouillier <guy.rouillier@gmail.com> writes:
> Ugh, I just noticed the quotation marks around the timestamp function.
> This works:

> select "timestamp"(now()::timestamptz); => timestamp without time zone

> This is a subtlety bound to be lost on most.  Why is there both a
> function and a type name with the same name?

All cast functions are named after the target type, by convention.

> I suppose I could define a
> synonym to make the function name distinct, but this seems like
> something that should be addressed.

Really the right way to address it is to use cast notation.  The
function notation is sometimes convenient, but you have to worry
about gotchas like this one, not to mention that some built-in
types have multiple aliases.

            regards, tom lane


pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: [HACKERS] Floating point error
Next
From: Maciek Sakrejda
Date:
Subject: Re: [HACKERS] Floating point error