MDEV-27066: Fixed scientific notation parsing bug
The bug occurs where the float token containing a dot with an 'e' notation was dropped from the request completely. This causes a manner of invalid SQL statements like: select id 1.e, char 10.e(id 2.e), concat 3.e('a'12356.e,'b'1.e,'c'1.1234e)1.e, 12 1.e*2 1.e, 12 1.e/2 1.e, 12 1.e|2 1.e, 12 1.e^2 1.e, 12 1.e%2 1.e, 12 1.e&2 from test; To be parsed correctly as if it was: select id, char(id), concat('a','b','c'), 12*2, 12/2, 12|2, 12^2, 12%2, 12&2 from test.test; This correct parsing occurs when e is followed by any of: ( ) . , | & % * ^ /
This commit is contained in:
parent
fe065f8d90
commit
749d8dedc3
@ -1338,3 +1338,34 @@ Select view_definition from information_schema.views where table_schema='test' a
|
||||
view_definition
|
||||
select 1 not between 2 like 3 and 4 AS `1 not between (2 like 3) and 4`
|
||||
drop view v1;
|
||||
#
|
||||
# Start of 10.2 tests
|
||||
#
|
||||
#
|
||||
# MDEV-27066 Fixed scientific notation parser
|
||||
#
|
||||
SELECT 1 1.e*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 '1.e*1' at line 1
|
||||
SELECT 1 1.e/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 '1.e/1' at line 1
|
||||
SELECT 1 1.e^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 '1.e^1' at line 1
|
||||
SELECT 1 1.e%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 '1.e%1' at line 1
|
||||
SELECT 1 1.e&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 '1.e&1' at line 1
|
||||
SELECT 1 1.e|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 '1.e|1' at line 1
|
||||
SELECT 1.e(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 '1.e(1)' at line 1
|
||||
SELECT (1 1.e);
|
||||
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 '1.e)' at line 1
|
||||
SELECT 1 1.e, 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 '1.e, 1' at line 1
|
||||
CREATE TABLE scientific_notation (test int);
|
||||
SELECT tmp 1.e.test FROM scientific_notation AS tmp;
|
||||
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 '1.e.test FROM scientific_notation AS tmp' at line 1
|
||||
DROP TABLE scientific_notation;
|
||||
#
|
||||
# End of 10.2 tests
|
||||
#
|
||||
|
@ -1365,3 +1365,49 @@ create or replace view v1 as select 1 not between (2 like 3) and 4;
|
||||
Select view_definition from information_schema.views where table_schema='test' and table_name='v1';
|
||||
|
||||
drop view v1;
|
||||
|
||||
--echo #
|
||||
--echo # Start of 10.2 tests
|
||||
--echo #
|
||||
--echo #
|
||||
|
||||
--echo # MDEV-27066 Fixed scientific notation parser
|
||||
--echo #
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e*1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e/1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e^1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e%1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e&1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e|1;
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1.e(1);
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT (1 1.e);
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT 1 1.e, 1;
|
||||
|
||||
CREATE TABLE scientific_notation (test int);
|
||||
|
||||
--error ER_PARSE_ERROR
|
||||
SELECT tmp 1.e.test FROM scientific_notation AS tmp;
|
||||
|
||||
DROP TABLE scientific_notation;
|
||||
|
||||
--echo #
|
||||
--echo # End of 10.2 tests
|
||||
--echo #
|
||||
|
@ -1664,8 +1664,7 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
|
||||
c = lip->yyGet(); // Skip sign
|
||||
if (!my_isdigit(cs,c))
|
||||
{ // No digit after sign
|
||||
state= MY_LEX_CHAR;
|
||||
break;
|
||||
return (ABORT_SYM);
|
||||
}
|
||||
while (my_isdigit(cs,lip->yyGet())) ;
|
||||
yylval->lex_str=get_token(lip, 0, lip->yyLength());
|
||||
|
Loading…
x
Reference in New Issue
Block a user