Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDYuo-0000ux-0j for pgsql-general@arkaria.postgresql.org; Sat, 11 Nov 2017 16:45:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eDYun-0000o4-JJ for pgsql-general@arkaria.postgresql.org; Sat, 11 Nov 2017 16:45:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eDYsH-0004C4-3D for pgsql-general@postgresql.org; Sat, 11 Nov 2017 16:43:17 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eDYsE-0000F9-2S for pgsql-general@postgresql.org; Sat, 11 Nov 2017 16:43:16 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vABGh866001042; Sat, 11 Nov 2017 11:43:08 -0500 From: Tom Lane To: Lele Gaifax cc: pgsql-general@postgresql.org Subject: Re: Difference between CAST(v AS t) and v::t In-reply-to: <87k1yx3vfi.fsf@metapensiero.it> References: <87k1yx3vfi.fsf@metapensiero.it> Comments: In-reply-to Lele Gaifax message dated "Sat, 11 Nov 2017 12:29:37 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1040.1510418588.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Sat, 11 Nov 2017 11:43:08 -0500 Message-ID: <1041.1510418588@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-general Precedence: bulk Sender: pgsql-general-owner@postgresql.org Lele Gaifax 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 =3D, validity WITH = &&) > works, the following > EXCLUDE USING gist (company_id::text WITH =3D, 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 --=20 Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general