Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eDTyz-0004rL-BI for pgsql-general@arkaria.postgresql.org; Sat, 11 Nov 2017 11:29:53 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eDTyy-0000Ob-U2 for pgsql-general@arkaria.postgresql.org; Sat, 11 Nov 2017 11:29:52 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eDTyy-0000OG-7o for pgsql-general@postgresql.org; Sat, 11 Nov 2017 11:29:52 +0000 Received: from [195.159.176.226] (helo=blaine.gmane.org) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1eDTyt-0008SV-Ly for pgsql-general@postgresql.org; Sat, 11 Nov 2017 11:29:51 +0000 Received: from list by blaine.gmane.org with local (Exim 4.84_2) (envelope-from ) id 1eDTyi-000805-L1 for pgsql-general@postgresql.org; Sat, 11 Nov 2017 12:29:36 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-general@postgresql.org From: Lele Gaifax Subject: Difference between CAST(v AS t) and v::t Date: Sat, 11 Nov 2017 12:29:37 +0100 Organization: Nautilus Entertainments Lines: 37 Message-ID: <87k1yx3vfi.fsf@metapensiero.it> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: usenet@blaine.gmane.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux) Cancel-Lock: sha1:zkGfj03PgpFivR2uvr4hBDstnXc= X-Host-Lookup-Failed: Reverse DNS lookup failed for 195.159.176.226 (failed) 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 Hi all, 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 CREATE TABLE contracts ( ... company_id uuid NOT NULL, validity daterange NOT NULL, EXCLUDE USING gist (CAST(company_id AS text) WITH =, validity WITH &&) ) works, the following CREATE TABLE contracts ( ... company_id uuid NOT NULL, validity daterange NOT NULL, EXCLUDE USING gist (company_id::text WITH =, validity WITH &&) ) is rejected with the message "syntax error at or near "::"". Am I misreading the documentation, or is it missing some special case? Thanks in advance for any explanation, ciao, lele. [1] https://github.com/lelit/pg_query [2] https://www.postgresql.org/docs/10/static/sql-expressions.html#SQL-SYNTAX-TYPE-CASTS -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general