pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Lele Gaifax <lele@metapensiero.it>
Cc: pgsql-general@postgresql.org
Subject: Re: Difference between CAST(v AS t) and v::t
Date: Sat, 11 Nov 2017 11:43:08 -0500
Message-ID: <1041.1510418588@sss.pgh.pa.us> (raw)
In-Reply-To: <87k1yx3vfi.fsf@metapensiero.it>
References: <87k1yx3vfi.fsf@metapensiero.it>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-general>

Lele Gaifax <lele@metapensiero.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


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



view thread (3+ messages)  latest in thread

Message-ID: <1041.1510418588@sss.pgh.pa.us>
Permalink:  ../1041.1510418588@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/1041.1510418588@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, lele@metapensiero.it
  Subject: Re: Difference between CAST(v AS t) and v::t
  In-Reply-To: <1041.1510418588@sss.pgh.pa.us>
  References: <87k1yx3vfi.fsf@metapensiero.it> <1041.1510418588@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox