Allowed characters in regular identifiers

26 views
Skip to first unread message

Mark Rotteveel

unread,
Mar 12, 2026, 5:48:18 AM (3 days ago) Mar 12
to firebir...@googlegroups.com
I was writing a test just now for disabled escape processing in Jaybird,
which would result in certain JDBC escapes to be passed without
transformation to Firebird.

Specifically, it sent the statement
```
select {fn exp(2)} from RDB$DATABASE
```

I had expected this to fail with a "Token unknown - line 1, column 8; {"
but instead it failed with "Token unknown - line 1, column 15; (". Some
experimentation shows that regular identifiers accept { and } (even as
first character), which I did not know nor expect.

As far as is documented, Firebird defines regular identifiers as

```
<name> ::=
<letter> | <name><letter> | <name><digit> | <name>_ | <name>$

<letter> ::= <upper letter> | <lower letter>

<upper letter> ::= A | B | C | D | E | F | G | H | I | J | K | L | M |
N | O | P | Q | R | S | T | U | V | W | X | Y | Z

<lower letter> ::= a | b | c | d | e | f | g | h | i | j | k | l | m |
n | o | p | q | r | s | t | u | v | w | x | y | z

<digit> ::= 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
```

(see
https://firebirdsql.org/file/documentation/chunk/en/refdocs/fblangref50/fblangref50-structure-identifiers.html)

The above syntax is closer to the definition of <regular identifier> in
SQL-86 than to its definition in SQL:2023; compared to SQL-86, it only
adds the $. It's also the syntax defined in the InterBase 6.0 Language
Reference (page 16).

This makes me wonder:

1) Is this a Firebird bug or a documentation bug?
2) What are the actual characters supported in a regular identifier in
Firebird 5?

For comparison, SQL:2023 defines:

"""
```
<regular identifier> ::=
<identifier body>

<identifier body> ::=
<identifier start> [ <identifier part>... ]

<identifier part> ::=
<identifier start>
| <identifier extend>

<identifier start> ::=
!! See the Syntax Rules.

<identifier extend> ::=
!! See the Syntax Rules.
```

Syntax Rules

1) An <identifier start> is any character in the Unicode General
Category classes “Lu”, “Ll”, “Lt”, “Lm”, “Lo”, or “Nl”.

NOTE 112 — The Unicode General Category classes “Lu”, “Ll”, “Lt”, “Lm”,
“Lo”, and “Nl” are assigned to Unicode characters that are,
respectively, upper-case letters, lower-case letters, title-case
letters, modifier letters, other letters, and letter numbers.

2) An <identifier extend> is U+00B7, “Middle Dot”, or any character in
the Unicode General Category classes “Mn”, “Mc”, “Nd”, or “Pc”.

NOTE 113 — The Unicode General Category classes “Mn”, “Mc”, “Nd”, and
“Pc”, are assigned to Unicode characters that are, respectively,
non-spacing marks, spacing combining marks, decimal numbers, and
connector punctuations
"""

Mark
--
Mark Rotteveel

Dimitry Sibiryakov

unread,
Mar 12, 2026, 6:29:03 AM (3 days ago) Mar 12
to firebir...@googlegroups.com
'Mark Rotteveel' via firebird-devel wrote 12.03.2026 10:48:
> This makes me wonder:
>
> 1) Is this a Firebird bug or a documentation bug?
> 2) What are the actual characters supported in a regular identifier in Firebird 5?

It looks for me as a bug introduced during introduction of schemas, though it
may be an undocumented feature as well:

const auto validateUnquotedIdentifier = [&](const string& name)
{
if (name.length() > MAX_SQL_IDENTIFIER_LEN)
(Arg::Gds(isc_invalid_name) << str).raise();

bool first = true;

for (const auto c : name)
{
if (!((c >= 'A' && c <= 'Z') ||
(c >= 'a' && c <= 'z') ||
==> c == '{' ||
==> c == '}' ||
(!first && c >= '0' && c <= '9') ||
(!first && c == '$') ||
(!first && c == '_')))
{

(Arg::Gds(isc_invalid_unqualified_name_list) << str).raise();
}

first = false;
}

return true;
};


--
WBR, SD.

Mark Rotteveel

unread,
Mar 12, 2026, 8:15:38 AM (3 days ago) Mar 12
to firebir...@googlegroups.com
On 12-03-2026 11:28, 'Dimitry Sibiryakov' via firebird-devel wrote:
> 'Mark Rotteveel' via firebird-devel wrote 12.03.2026 10:48:
>> This makes me wonder:
>>
>> 1) Is this a Firebird bug or a documentation bug?
>> 2) What are the actual characters supported in a regular identifier in
>> Firebird 5?
>
>   It looks for me as a bug introduced during introduction of schemas,
> though it may be an undocumented feature as well:

Given I experience it in Firebird 5, I don't think it's related to
introduction of schema, though I can't find that specific method in the
Firebird 5 code.

Mark

--
Mark Rotteveel

Mark Rotteveel

unread,
Mar 12, 2026, 8:24:45 AM (3 days ago) Mar 12
to firebir...@googlegroups.com
I did find in chars.h:

/* 123 { */ 0 | CHR_LETTER | CHR_IDENT,
/* 124 | */ 0,
/* 125 } */ 0 | CHR_LETTER | CHR_IDENT,

Also in B1_5_Release, so I guess that is established behaviour then.

Mark
--
Mark Rotteveel

Adriano dos Santos Fernandes

unread,
Mar 12, 2026, 9:23:03 PM (2 days ago) Mar 12
to firebir...@googlegroups.com
On 3/12/26 06:48, 'Mark Rotteveel' via firebird-devel wrote:
> I was writing a test just now for disabled escape processing in Jaybird,
> which would result in certain JDBC escapes to be passed without
> transformation to Firebird.
>
> Specifically, it sent the statement
> ```
> select {fn exp(2)} from RDB$DATABASE
> ```
>
> I had expected this to fail with a "Token unknown - line 1, column 8; {"
> but instead it failed with "Token unknown - line 1, column 15; (". Some
> experimentation shows that regular identifiers accept { and } (even as
> first character), which I did not know nor expect.
>
> As far as is documented, Firebird defines regular identifiers as
>

Not news: https://sourceforge.net/p/firebird/mailman/message/24592091/


Adriano

Mark Rotteveel

unread,
Mar 13, 2026, 4:32:32 AM (2 days ago) Mar 13
to firebir...@googlegroups.com
OK. Now I am wondering *if* I should document this, and if so *how*,
because I feel it is problematic syntax.

It's problematic because:

1. The SQL standard actually uses braces in some syntax, in 7.9 <row
pattern common syntax>, specifically in <row pattern quantifier>, which
is used by 7.7 <row pattern recognition clause> (i.e. MATCH_RECOGNIZE)
and 7.15 <window clause> (see <window frame clause>)

2. Consider ODBC and JDBC escape syntax, which relies on braces because
when it was defined, the SQL standard did not use them. I'm sure that
people using JDBC (Jaybird), and probably ODBC, have never used braces
in their column names as it would make executing statements impossible.

3. I've heard rumours from a developer working on Oracle's JDBC driver
(but that was hearsay from someone else in Oracle), that the SQL
standard committee is thinking about more usages of braces in SQL syntax.

I propose we explicitly add to the Firebird 6 release notes that this
previously undocumented syntax is now deprecated and will be disallowed
in Firebird 7, and that when you use braces in an identifier, you'll
need to use delimited identifiers going forward. Any objections?

Mark
--
Mark Rotteveel
Reply all
Reply to author
Forward
0 new messages