Re: 9.2 timestamp function syntax error

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Guy Rouillier <guy(dot)rouillier(at)gmail(dot)com>
Cc: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>, Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: 9.2 timestamp function syntax error
Date: 2013-03-05 18:27:03
Message-ID: 11816.1362508023@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Guy Rouillier <guy(dot)rouillier(at)gmail(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Maciek Sakrejda 2013-03-05 18:36:05 Re: [HACKERS] Floating point error
Previous Message Tom Lane 2013-03-05 18:23:12 Re: [HACKERS] Floating point error