From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Lele Gaifax <lele(at)metapensiero(dot)it> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Difference between CAST(v AS t) and v::t |
Date: | 2017-11-11 16:43:08 |
Message-ID: | 1041.1510418588@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Lele Gaifax <lele(at)metapensiero(dot)it> writes:
> while writing test cases for my SQL pretty printer tool[1], I found what seems
> a discrepancy in the "Type Casts" documentation[2]: it states that the two
> syntaxes are equivalent, but while
They are functionally equivalent ...
> EXCLUDE USING gist (CAST(company_id AS text) WITH =, validity WITH &&)
> works, the following
> EXCLUDE USING gist (company_id::text WITH =, validity WITH &&)
> is rejected with the message "syntax error at or near "::"".
... but expression-index syntax has the restriction that you need
parentheses around an expression unless it is, or at least looks like,
a function call. CAST() looks enough like a function call for this
purpose, v::t does not.
I think there is relevant documentation for this near CREATE INDEX;
it doesn't seem like the province of the typecast docs to explain
the weirdnesses of index syntax.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Adam Brusselback | 2017-11-11 16:49:30 | Re: Postgres 10.1 fails to start: server did not start in time |
Previous Message | Jan Claeys | 2017-11-11 16:40:59 | Re: pg on Debian servers |