From ccbf851fb35bea85e295e8fb1c229754d1ecedef Mon Sep 17 00:00:00 2001 From: Mahmoud Khaled Date: Sat, 28 Feb 2026 22:28:04 +0200 Subject: [PATCH] MDEV-17677: Keywords followed by .number parsed as identifiers Problem:for example SELECT.1 treated as identifier instead of keyword + 0.1 from starting identifiers after dot --- mysql-test/main/parser.result | 39 +++++++++++++++++ mysql-test/main/parser.test | 43 +++++++++++++++++++ .../suite/funcs_1/r/innodb_trig_0407.result | 2 +- .../suite/funcs_1/r/memory_trig_0407.result | 2 +- .../suite/funcs_1/r/myisam_trig_0407.result | 2 +- sql/sql_lex.cc | 4 +- 6 files changed, 87 insertions(+), 5 deletions(-) diff --git a/mysql-test/main/parser.result b/mysql-test/main/parser.result index b52af23eb4921..d4b13c062a4c9 100644 --- a/mysql-test/main/parser.result +++ b/mysql-test/main/parser.result @@ -2269,3 +2269,42 @@ $$ # # End of 10.6 tests # +# +# MDEV-17677 : Keywords are parsed as identifiers when followed by a dot +# +test for Nd (should work) +SELECT.1; +.1 +0.1 +SELECT.123+0; +.123+0 +0.123 +SELECT.5 * 2; +.5 * 2 +1.0 +test for Mn +SELECT.́1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.\00811' at line 1 +SELECT.̈abc; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.̈abc' at line 1 +test for Mc +SELECT.ःtest; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.ःtest' at line 1 +test for Pc +SELECT.‿a; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.‿a' at line 1 +test for Cf +SELECT.‎abc; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.‎abc' at line 1 +test for Middle-dot and underscore +SELECT.·123; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SELECT.·123' at line 1 +ٍSELECT._1; +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '\008DSELECT._1' at line 1 +still work as identifier +CREATE TABLE `SELECT` (a INT); +INSERT INTO `SELECT` VALUES (5); +SELECT `SELECT`.a FROM `SELECT`; +a +5 +DROP TABLE `SELECT`; diff --git a/mysql-test/main/parser.test b/mysql-test/main/parser.test index 5ddbaf29314fd..04ca9d098bb32 100644 --- a/mysql-test/main/parser.test +++ b/mysql-test/main/parser.test @@ -2067,3 +2067,46 @@ DELIMITER ;$$ --echo # --echo # End of 10.6 tests --echo # + +--echo # +--echo # MDEV-17677 : Keywords are parsed as identifiers when followed by a dot +--echo # + +--echo test for Nd (should work) +SELECT.1; +SELECT.123+0; +SELECT.5 * 2; + +--character_set utf8mb4 +--echo test for Mn +--error ER_PARSE_ERROR +SELECT.́1; + +--error ER_PARSE_ERROR +SELECT.̈abc; + + +-- echo test for Mc +--error ER_PARSE_ERROR +SELECT.ःtest; + +--echo test for Pc +--error ER_PARSE_ERROR +SELECT.‿a; + +--echo test for Cf +--error ER_PARSE_ERROR +SELECT.‎abc; + +--echo test for Middle-dot and underscore +--error ER_PARSE_ERROR +SELECT.·123; +--error ER_PARSE_ERROR +ٍSELECT._1; + +--echo still work as identifier +CREATE TABLE `SELECT` (a INT); +INSERT INTO `SELECT` VALUES (5); +SELECT `SELECT`.a FROM `SELECT`; +DROP TABLE `SELECT`; + diff --git a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result index 281e4e8d0f6c3..5b9a16d2f17fd 100644 --- a/mysql-test/suite/funcs_1/r/innodb_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/innodb_trig_0407.result @@ -138,7 +138,7 @@ create table t1_433a (f1a char (5)) engine = ; CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row set new.f1 = 'Trigger 3.5.4.3'; Drop trigger t1.433.trg3; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.trg3' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger db_drop3.t1.433.trg3; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger mysql.trg3; diff --git a/mysql-test/suite/funcs_1/r/memory_trig_0407.result b/mysql-test/suite/funcs_1/r/memory_trig_0407.result index c9a15b46aba07..bf9d20da2f13b 100644 --- a/mysql-test/suite/funcs_1/r/memory_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/memory_trig_0407.result @@ -138,7 +138,7 @@ create table t1_433a (f1a char (5)) engine = ; CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row set new.f1 = 'Trigger 3.5.4.3'; Drop trigger t1.433.trg3; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.trg3' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger db_drop3.t1.433.trg3; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger mysql.trg3; diff --git a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result index c9a15b46aba07..bf9d20da2f13b 100644 --- a/mysql-test/suite/funcs_1/r/myisam_trig_0407.result +++ b/mysql-test/suite/funcs_1/r/myisam_trig_0407.result @@ -138,7 +138,7 @@ create table t1_433a (f1a char (5)) engine = ; CREATE TRIGGER trg3 BEFORE INSERT on t1_433 for each row set new.f1 = 'Trigger 3.5.4.3'; Drop trigger t1.433.trg3; -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.trg3' at line 1 +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger db_drop3.t1.433.trg3; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '.433.trg3' at line 1 Drop trigger mysql.trg3; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 4358aed10b645..b4f9830d62c13 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -2851,7 +2851,7 @@ int Lex_input_stream::scan_ident_middle(THD *thd, Lex_ident_cli_st *str, yylineno++; } } - if (start == get_ptr() && c == '.' && ident_map[(uchar) yyPeek()]) + if (start == get_ptr() && c == '.' && ident_map[(uchar) yyPeek()] && !my_isdigit(cs, yyPeek())) next_state= MY_LEX_IDENT_SEP; else { // '(' must follow directly if function @@ -12439,4 +12439,4 @@ bool SELECT_LEX_UNIT::is_derived_eliminated() const if (!derived->table) return true; return derived->table->map & outer_select()->join->eliminated_tables; -} +} \ No newline at end of file