Re: cross-database time extract? - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: cross-database time extract?
Date
Msg-id 20091229141459.GD4569@alvh.no-ip.org
Whole thread Raw
In response to Re: cross-database time extract?  (Osvaldo Kussama <osvaldo.kussama@gmail.com>)
List pgsql-general
Osvaldo Kussama escribió:

> bdteste=# SELECT "time"(CURRENT_TIMESTAMP);
>       time
> -----------------
>  10:55:20.679684
> (1 registro)
>
> bdteste=# SELECT $$time$$(CURRENT_TIMESTAMP);
> ERRO:  erro de sintaxe em ou próximo a "("
> LINE 1: SELECT $$time$$(CURRENT_TIMESTAMP);
>                        ^

Note that the reason the second query doesn't work is that $$ is a way
to replace quoting for string literals, i.e. what ' (single quote) does
normally.  " (double quote) is used to quote identifiers, not literals.
Different thing.

When you write "time" you are invoking the function because it's parsed
as an identifier.  When you write time (no quotes) you are invoking the
reserved keyword.  The double quotes strip the "reservedness" and it's
treated like an ordinary keyword.  When you write pg_catalog.time this
is parsed as an identifier too because keywords cannot be
schema-qualified.

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

pgsql-general by date:

Previous
From: Adrian Klaver
Date:
Subject: Re: cross-database time extract?
Next
From: Adrian Klaver
Date:
Subject: Re: cross-database time extract?