Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goWQC-0006f1-91 for pgsql-general@arkaria.postgresql.org; Tue, 29 Jan 2019 16:39:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1goWQA-00055w-RM for pgsql-general@arkaria.postgresql.org; Tue, 29 Jan 2019 16:39:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goWQA-00055j-ES for pgsql-general@lists.postgresql.org; Tue, 29 Jan 2019 16:39:34 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1goWQ7-0007Zm-R1 for pgsql-general@lists.postgresql.org; Tue, 29 Jan 2019 16:39:33 +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 x0TGdTl6007564; Tue, 29 Jan 2019 11:39:29 -0500 From: Tom Lane To: "Gunnar \"Nick\" Bluth" cc: "pgsql-general@lists.postgresql.org" Subject: Re: SELECT of pseudo hex value gives unexpected result In-reply-to: <3edb0e31-8fea-3cf7-477c-7554ea25975e@pro-open.de> References: <3edb0e31-8fea-3cf7-477c-7554ea25975e@pro-open.de> Comments: In-reply-to "Gunnar \"Nick\" Bluth" message dated "Tue, 29 Jan 2019 17:18:07 +0100" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <7562.1548779969.1@sss.pgh.pa.us> Date: Tue, 29 Jan 2019 11:39:29 -0500 Message-ID: <7563.1548779969@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk "Gunnar \"Nick\" Bluth" writes: > Tried > SELECT 0x5e73266725; > and received: > -[ RECORD 1 ]-- > x5e73266725 | 0 > That was not what I expected... is this expected/documented behaviour? Well, there are no hex literals in (PG's notion of) SQL, so that isn't a valid token. But it's the concatenation of two valid tokens. So what you wrote is the same as SELECT 0 x5e73266725; which is an abbreviation for SELECT 0 AS x5e73266725; and that's the result you got. I think that the SQL standard considers adjacent tokens to be invalid unless one of them is punctuation (e.g. 1+2), but our lexer is a bit less rigid about that. regards, tom lane