oceanbase / odc

OceanBase Developer Center(ODC), An open-source, enterprise-grade database tool for collaborative development
https://github.com/oceanbase/odc
Apache License 2.0
529 stars 50 forks source link

[Bug]: SQL statements executed within obmysql and native mysql cannot be checked for syntax errors #693

Closed sl01388797 closed 10 months ago

sl01388797 commented 10 months ago

ODC version

odc422

OB version

*

What happened?

image image image

What did you expect to happen?

Before executing SQL, SQL checks for errors and jumps to database changes

How can we reproduce it (as minimally and precisely as possible)?

  1. Turn on the switch for syntax errors
  2. Entering incorrect SQL statements in the SQL window

Anything else we need to know?

No response

Cloud

No response

yhilmare commented 10 months ago

this is a parser's bug, the parser will not report syntax error if we supply a sql that the prefix is grammatical but the suffix is not grammatical. eg.

select * from test asdasdakkfjiaruwerewiru;

the sql above get a syntax error obviously, but this is a sql without any syntax error for parser cause that the prefix of this sql is grammatical.

the root cause of this bug is that we ignore the EOF of the statement.

yhilmare commented 10 months ago

the way to fix this issue is much too simple: we should parse the sql from the beginning to the end(EOF)

yhilmare commented 10 months ago

before:

截屏2023-11-01 21 08 45

after:

截屏2023-11-01 21 11 50
yhilmare commented 10 months ago

further more, the parser will not report any syntax error if the input's any prefix is grammatical:

截屏2023-11-01 21 13 04
sl01388797 commented 10 months ago

Image

pass