firebird icon indicating copy to clipboard operation
firebird copied to clipboard

First ... Query valid without Space between Number and Column

Open haba-beton opened this issue 1 month ago • 7 comments

The following query is valid:

select first 1* from RDB$DATABASE

no Space between 1 and *

I think this should raise an Exception.

haba-beton avatar Nov 04 '25 19:11 haba-beton

IIRC, the tokenizer considers * a token boundary (e.g. consider 1*1 or other expressions involving *), so from the perspective from the parser, it simply receives valid tokens.

While it is not the prettiest, I'm not sure if it's actually a syntax error, and even if it should raise one according to the SQL standard (I haven't had time to dig), I don't think it's worth fixing.

mrotteveel avatar Nov 05 '25 11:11 mrotteveel

The following query is valid, too:

select first 35RDB$RELATION_ID from RDB$DATABASE

I don’t know if that could actually be a problem either; it just caught my eye. And i think, there should be a space in between.

haba-beton avatar Nov 05 '25 11:11 haba-beton

That one is IMHO a bug, and I've reported it earlier I think. Let me see if I can find it.

mrotteveel avatar Nov 05 '25 11:11 mrotteveel

See #7594, this comment of me there also explains why select first 1* is technically not a bug (* is a delimiter token by the SQL standard), while select first 35RDB$RELATION_ID should be considered bug as 5, and R are not a delimiter token nor a separator, so 35RDB$RELATION_ID should be considered a single token (that is then syntactically invalid).

mrotteveel avatar Nov 05 '25 11:11 mrotteveel

See #7594, this comment of me there also explains why select first 1* is technically not a bug (* is a delimiter token by the SQL standard), while select first 35RDB$RELATION_ID should be considered bug as 5, and R are not a delimiter token nor a separator, so 35RDB$RELATION_ID should be considered a single token (that is then syntactically invalid).

Or alternatively, they can be considered two tokens, 35 and RDB$RELATION_ID, but as those would be nondelimiter tokens, there must be a delimiter token and/or separator between them (ISO/IEC 9075-2:2023, section 5.2); the end result is the same though: it is syntactically not valid.

mrotteveel avatar Nov 05 '25 11:11 mrotteveel

IIRC, this is already fixed in #8564 (according to the description).

dyemanov avatar Nov 05 '25 11:11 dyemanov

IIRC, this is already fixed in #8564 (according to the description).

Based on the description, I'd say yes.

mrotteveel avatar Nov 05 '25 14:11 mrotteveel