From: Tom Lane <tgl@sss.pgh.pa.us>
To: Gunnar \"Nick\" Bluth <gunnar.bluth@pro-open.de>
Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: SELECT of pseudo hex value gives unexpected result
Date: Tue, 29 Jan 2019 11:39:29 -0500
Message-ID: <7563.1548779969@sss.pgh.pa.us> (raw)
In-Reply-To: <3edb0e31-8fea-3cf7-477c-7554ea25975e@pro-open.de>
References: <3edb0e31-8fea-3cf7-477c-7554ea25975e@pro-open.de>
"Gunnar \"Nick\" Bluth" <gunnar.bluth@pro-open.de> 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
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, gunnar.bluth@pro-open.de
Subject: Re: SELECT of pseudo hex value gives unexpected result
In-Reply-To: <7563.1548779969@sss.pgh.pa.us>
References: <3edb0e31-8fea-3cf7-477c-7554ea25975e@pro-open.de> <7563.1548779969@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