Re: Lexical Structure - String Constants - Mailing list pgsql-docs

From Tom Lane
Subject Re: Lexical Structure - String Constants
Date
Msg-id 814.1402978354@sss.pgh.pa.us
Whole thread Raw
In response to Lexical Structure - String Constants  (Sérgio Saquetim <sergiosaquetim@gmail.com>)
Responses Re: Lexical Structure - String Constants  (Sérgio Saquetim <sergiosaquetim@gmail.com>)
List pgsql-docs
=?UTF-8?Q?S=C3=A9rgio_Saquetim?= <sergiosaquetim@gmail.com> writes:
> So line style comments (--) are accepted between segments but not C style
> block comments (/* */). Do you think this difference in behavior should me
> mentioned in the docs?

Hm, interesting.  It looks to me like modern versions of the SQL spec
require either -- or /* ... */ style comments to be allowed between
segments of a quoted literal.  This is pretty bad taste in language
design, if you ask me, but that's what it seems to say.  I think that
our current lexer rules date from before the SQL standard even had
/* ... */ style comments, which is why the lexer isn't taking it.

> I've also noticed that in section 4.1.2.6, the following statement: "At
> least one digit must follow the exponent marker (e), if one is present."

> As I've understood the statement, I think it says that the following
> instruction should not be valid because the exponent marker is not followed
> by at least one digit, but the expression is successfully evaluated:

> postgres=# SELECT 10e;
>  e
> ----
>  10
> (1 row)

"10e" is not a valid number, just like the manual says.  But "10" is a
valid number, and "e" is a valid column alias, so this is equivalent
to "SELECT 10 AS e".  There's no requirement for white space between
adjacent tokens, if the tokens couldn't validly be run together into
one token.

            regards, tom lane


pgsql-docs by date:

Previous
From: Sérgio Saquetim
Date:
Subject: Lexical Structure - String Constants
Next
From: Sérgio Saquetim
Date:
Subject: Re: Lexical Structure - String Constants