Re: SELECT of pseudo hex value gives unexpected result - Mailing list pgsql-general

From Tom Lane
Subject Re: SELECT of pseudo hex value gives unexpected result
Date
Msg-id 7563.1548779969@sss.pgh.pa.us
Whole thread Raw
In response to SELECT of pseudo hex value gives unexpected result  ("Gunnar \"Nick\" Bluth" <gunnar.bluth@pro-open.de>)
Responses Re: SELECT of pseudo hex value gives unexpected result
List pgsql-general
"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


pgsql-general by date:

Previous
From: "Gunnar \"Nick\" Bluth"
Date:
Subject: SELECT of pseudo hex value gives unexpected result
Next
From: Laurenz Albe
Date:
Subject: Re: SELECT of pseudo hex value gives unexpected result