odc icon indicating copy to clipboard operation
odc copied to clipboard

[Bug]: ODC comment issue: syntax error when there are two white spaces before --

Open alvinloong opened this issue 2 years ago • 0 comments

ODC version

版本号:4.2.3-1706773002000 Server: 4.2.3-20240201 Release Date: 2024-02-01

OB version

Server version: 5.6.25 OceanBase 4.2.1.3 (r103050012024012511-44db4190d80efddf8db98d564d661fa9417b63a6) (Built Jan 25 2024 11:55:53)

What happened?

In OceanBase MySQL mode, syntax error shows when there are two or more white spaces before --

SELECT
    *
FROM
    information_schema.key_column_usage
WHERE
        upper(table_schema) = upper('test')
    -- AND constraint_name = 'PRIMARY'
    AND upper(table_name) = upper('test');

执行以下 SQL 失败 SELECT * FROM information_schema.key_column_usage WHERE upper(table_schema) = upper('test') -- AND constraint_name = 'PRIM RY' AND upper(table_name) = upper('test') 失败原因: ErrorCode = 1064, SQLState = 42000, Details = You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'RY' AND upper(table_name) = upper('test')' at line 8

What did you expect to happen?

NO syntax error when there are two or more white spaces before --.

As in obclient window:

Server version: 5.6.25 OceanBase 4.2.1.3 (r103050012024012511-44db4190d80efddf8db98d564d661fa9417b63a6) (Built Jan 25 2024 11:55:53)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql>
mysql>
mysql> SELECT
    ->     *
    -> FROM
    ->     information_schema.key_column_usage
    -> WHERE
    ->         upper(table_schema) = upper('test')
    ->     -- AND constraint_name = 'PRIMARY'
    ->     AND upper(table_name) = upper('test');
+--------------------+-------------------+-----------------+---------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
| CONSTRAINT_CATALOG | CONSTRAINT_SCHEMA | CONSTRAINT_NAME | TABLE_CATALOG | TABLE_SCHEMA | TABLE_NAME | COLUMN_NAME | ORDINAL_POSITION | POSITION_IN_UNIQUE_CONSTRAINT | REFERENCED_TABLE_SCHEMA | REFERENCED_TABLE_NAME | REFERENCED_COLUMN_NAME |
+--------------------+-------------------+-----------------+---------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
| def                | test              | PRIMARY         | def           | test         | test       | n1          |                1 |                          NULL | NULL                    | NULL                  | NULL                   |
+--------------------+-------------------+-----------------+---------------+--------------+------------+-------------+------------------+-------------------------------+-------------------------+-----------------------+------------------------+
1 row in set (1.02 sec)

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

Just run the following SQL

SELECT
    *
FROM
    information_schema.key_column_usage
WHERE
        upper(table_schema) = upper('test')
    -- AND constraint_name = 'PRIMARY'
    AND upper(table_name) = upper('test');

Anything else we need to know?

No response

Cloud

No response

alvinloong avatar Feb 05 '24 03:02 alvinloong