ISQL and comments

64 views
Skip to first unread message

Adriano dos Santos Fernandes

unread,
Nov 27, 2023, 5:07:16 AM11/27/23
to firebir...@googlegroups.com
In
https://github.com/FirebirdSQL/firebird/pull/7868#issuecomment-1826727278
Pavel Zotov is saying about "broken" behavior of ISQL in master.

I think this is wrong.

ISQL should not eat comments just because it's in the start of a statement.

Engine just accepts comments, no matter their position.

And in this version, ISQL also accept comments as parts of frontend
statements (even in their middle):

v5:
SQL> set /* comment */ echo on;
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 19
-echo
SQL>

master:
SQL> set /* comment */ echo on;
SQL>

Here is another weird thing about old behavior, where errors don't match:

v5:
SQL> /* comment */ select @ from rdb$database;
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 8
-@

master:
SQL> /* comment */ select @ from rdb$database;
Statement failed, SQLSTATE = 42000
Dynamic SQL Error
-SQL error code = -104
-Token unknown - line 1, column 22
-@

Let's see another example:

SQL> /* Multi-line comments
---> */
CON> create package pkg as begin end;

Currently engine don't preserve these comments before CREATE and I don't
think it's a correct behavior. One day that could be preserved, but if
ISQL eats comments, they will be lost anyway.

So IMO, the new behavior must be maintained as an improvement.


Adriano

Dmitry Yemanov

unread,
Dec 5, 2023, 8:12:57 AM12/5/23
to firebir...@googlegroups.com
I tend to agree. IMHO, the statement consists of whatever our parser
accepts from the grammar POV, up to the terminator character. Whether
there are embedded comments is irrelevant, as well as location of comments.


Dmitry


Reply all
Reply to author
Forward
0 new messages