Commit c73b987e authored by Sergei Golubchik's avatar Sergei Golubchik

MDEV-8328 Evaluation of two "!" operators depends on space in beetween

fix the lexer to backtrack when parsing
"<=", "<>", "!=", ">=", "<<", ">>", "<=>".
parent c3c272cc
......@@ -643,3 +643,23 @@ CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW
SET default_storage_engine = NEW.INNODB;
ERROR 42S22: Unknown column 'INNODB' in 'NEW'
DROP TABLE t1;
select 0==0;
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 '=0' at line 1
select 1=!0, 1 = ! 0;
1=!0 1 = ! 0
1 1
select !!0, ! ! 0;
!!0 ! ! 0
0 0
select 2>!0, 2 > ! 0;
2>!0 2 > ! 0
1 1
select 0<=!0, 0 <= !0;
0<=!0 0 <= !0
1 1
select 1<<!0, 1 << !0;
1<<!0 1 << !0
2 2
select 0<!0, 0 < ! 0;
0<!0 0 < ! 0
1 1
......@@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123';
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321";
SET PASSWORD FOR u1 = PASSWORD('pwd 098');
SET PASSWORD FOR u1=<secret>;
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 '=<secret>' 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 '<secret>' at line 1
CREATE USER u3 IDENTIFIED BY '';
drop user u1, u2, u3;
select 2;
......
......@@ -165,7 +165,7 @@ CREATE USER u1 IDENTIFIED BY 'pwd-123';
GRANT ALL ON sa_db TO u2 IDENTIFIED BY "pwd-321";
SET PASSWORD FOR u1 = PASSWORD('pwd 098');
SET PASSWORD FOR u1=<secret>;
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 '=<secret>' 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 '<secret>' at line 1
CREATE USER u3 IDENTIFIED BY '';
drop user u1, u2, u3;
select 2;
......
......@@ -758,3 +758,15 @@ CREATE TABLE t1 (s VARCHAR(100));
CREATE TRIGGER trigger1 BEFORE INSERT ON t1 FOR EACH ROW
SET default_storage_engine = NEW.INNODB;
DROP TABLE t1;
#
# MDEV-8328 Evaluation of two "!" operators depends on space in beetween
#
--error ER_PARSE_ERROR
select 0==0;
select 1=!0, 1 = ! 0;
select !!0, ! ! 0;
select 2>!0, 2 > ! 0;
select 0<=!0, 0 <= !0;
select 1<<!0, 1 << !0;
select 0<!0, 0 < ! 0;
......@@ -46,12 +46,9 @@ SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
static SYMBOL symbols[] = {
{ "&&", SYM(AND_AND_SYM)},
{ "<", SYM(LT)},
{ "<=", SYM(LE)},
{ "<>", SYM(NE)},
{ "!=", SYM(NE)},
{ "=", SYM(EQ)},
{ ">", SYM(GT_SYM)},
{ ">=", SYM(GE)},
{ "<<", SYM(SHIFT_LEFT)},
{ ">>", SYM(SHIFT_RIGHT)},
......
......@@ -1452,32 +1452,35 @@ static int lex_one_token(YYSTYPE *yylval, THD *thd)
return (BIN_NUM);
case MY_LEX_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START; // Allow signed numbers
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
lip->yySkip();
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{
lip->next_state= MY_LEX_START; // Allow signed numbers
return(tokval);
lip->yySkip();
if ((tokval= find_keyword(lip, 2, 0)))
return(tokval);
lip->yyUnget();
}
state = MY_LEX_CHAR; // Something fishy found
break;
return(c);
case MY_LEX_LONG_CMP_OP: // Incomplete comparison operator
lip->next_state= MY_LEX_START;
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP ||
state_map[(uchar) lip->yyPeek()] == MY_LEX_LONG_CMP_OP)
{
lip->yySkip();
if (state_map[(uchar) lip->yyPeek()] == MY_LEX_CMP_OP)
{
lip->yySkip();
if ((tokval= find_keyword(lip, 3, 0)))
return(tokval);
lip->yyUnget();
}
if ((tokval= find_keyword(lip, 2, 0)))
return(tokval);
lip->yyUnget();
}
if ((tokval = find_keyword(lip, lip->yyLength() + 1, 0)))
{
lip->next_state= MY_LEX_START; // Found long op
return(tokval);
}
state = MY_LEX_CHAR; // Something fishy found
break;
return(c);
case MY_LEX_BOOL:
if (c != lip->yyPeek())
......
......@@ -970,7 +970,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token ENGINES_SYM
%token ENGINE_SYM
%token ENUM
%token EQ /* OPERATOR */
%token EQUAL_SYM /* OPERATOR */
%token ERROR_SYM
%token ERRORS
......@@ -1016,7 +1015,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token GRANTS
%token GROUP_SYM /* SQL-2003-R */
%token GROUP_CONCAT_SYM
%token GT_SYM /* OPERATOR */
%token HANDLER_SYM
%token HARD_SYM
%token HASH_SYM
......@@ -1095,7 +1093,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%token LONG_SYM
%token LOOP_SYM
%token LOW_PRIORITY
%token LT /* OPERATOR */
%token MASTER_CONNECT_RETRY_SYM
%token MASTER_HOST_SYM
%token MASTER_LOG_FILE_SYM
......@@ -1439,7 +1436,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize);
%left XOR
%left AND_SYM AND_AND_SYM
%left BETWEEN_SYM CASE_SYM WHEN_SYM THEN_SYM ELSE
%left EQ EQUAL_SYM GE GT_SYM LE LT NE IS LIKE REGEXP IN_SYM
%left '=' EQUAL_SYM GE '>' LE '<' NE IS LIKE REGEXP IN_SYM
%left '|'
%left '&'
%left SHIFT_LEFT SHIFT_RIGHT
......@@ -1922,58 +1919,58 @@ master_defs:
;
master_def:
MASTER_HOST_SYM EQ TEXT_STRING_sys
MASTER_HOST_SYM '=' TEXT_STRING_sys
{
Lex->mi.host = $3.str;
}
| MASTER_USER_SYM EQ TEXT_STRING_sys
| MASTER_USER_SYM '=' TEXT_STRING_sys
{
Lex->mi.user = $3.str;
}
| MASTER_PASSWORD_SYM EQ TEXT_STRING_sys
| MASTER_PASSWORD_SYM '=' TEXT_STRING_sys
{
Lex->mi.password = $3.str;
}
| MASTER_PORT_SYM EQ ulong_num
| MASTER_PORT_SYM '=' ulong_num
{
Lex->mi.port = $3;
}
| MASTER_CONNECT_RETRY_SYM EQ ulong_num
| MASTER_CONNECT_RETRY_SYM '=' ulong_num
{
Lex->mi.connect_retry = $3;
}
| MASTER_SSL_SYM EQ ulong_num
| MASTER_SSL_SYM '=' ulong_num
{
Lex->mi.ssl= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
| MASTER_SSL_CA_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CA_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_ca= $3.str;
}
| MASTER_SSL_CAPATH_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CAPATH_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_capath= $3.str;
}
| MASTER_SSL_CERT_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CERT_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cert= $3.str;
}
| MASTER_SSL_CIPHER_SYM EQ TEXT_STRING_sys
| MASTER_SSL_CIPHER_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_cipher= $3.str;
}
| MASTER_SSL_KEY_SYM EQ TEXT_STRING_sys
| MASTER_SSL_KEY_SYM '=' TEXT_STRING_sys
{
Lex->mi.ssl_key= $3.str;
}
| MASTER_SSL_VERIFY_SERVER_CERT_SYM EQ ulong_num
| MASTER_SSL_VERIFY_SERVER_CERT_SYM '=' ulong_num
{
Lex->mi.ssl_verify_server_cert= $3 ?
LEX_MASTER_INFO::LEX_MI_ENABLE : LEX_MASTER_INFO::LEX_MI_DISABLE;
}
| MASTER_HEARTBEAT_PERIOD_SYM EQ NUM_literal
| MASTER_HEARTBEAT_PERIOD_SYM '=' NUM_literal
{
Lex->mi.heartbeat_period= (float) $3->val_real();
if (Lex->mi.heartbeat_period > SLAVE_MAX_HEARTBEAT_PERIOD ||
......@@ -2004,7 +2001,7 @@ master_def:
}
Lex->mi.heartbeat_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
| IGNORE_SERVER_IDS_SYM EQ '(' ignore_server_id_list ')'
| IGNORE_SERVER_IDS_SYM '=' '(' ignore_server_id_list ')'
{
Lex->mi.repl_ignore_server_ids_opt= LEX_MASTER_INFO::LEX_MI_ENABLE;
}
......@@ -2025,11 +2022,11 @@ ignore_server_id:
}
master_file_def:
MASTER_LOG_FILE_SYM EQ TEXT_STRING_sys
MASTER_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.log_file_name = $3.str;
}
| MASTER_LOG_POS_SYM EQ ulonglong_num
| MASTER_LOG_POS_SYM '=' ulonglong_num
{
Lex->mi.pos = $3;
/*
......@@ -2045,11 +2042,11 @@ master_file_def:
*/
Lex->mi.pos = max(BIN_LOG_HEADER_SIZE, Lex->mi.pos);
}
| RELAY_LOG_FILE_SYM EQ TEXT_STRING_sys
| RELAY_LOG_FILE_SYM '=' TEXT_STRING_sys
{
Lex->mi.relay_log_name = $3.str;
}
| RELAY_LOG_POS_SYM EQ ulong_num
| RELAY_LOG_POS_SYM '=' ulong_num
{
Lex->mi.relay_log_pos = $3;
/* Adjust if < BIN_LOG_HEADER_SIZE (same comment as Lex->mi.pos) */
......@@ -3032,7 +3029,7 @@ opt_set_signal_information:
;
signal_information_item_list:
signal_condition_information_item_name EQ signal_allowed_expr
signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
......@@ -3041,7 +3038,7 @@ signal_information_item_list:
info->m_item[index]= $3;
}
| signal_information_item_list ','
signal_condition_information_item_name EQ signal_allowed_expr
signal_condition_information_item_name '=' signal_allowed_expr
{
Set_signal_information *info;
info= &thd->m_parser_state->m_yacc.m_set_signal_info;
......@@ -4439,7 +4436,7 @@ opt_linear:
opt_key_algo:
/* empty */
{ Lex->part_info->key_algorithm= partition_info::KEY_ALGORITHM_NONE;}
| ALGORITHM_SYM EQ real_ulong_num
| ALGORITHM_SYM '=' real_ulong_num
{
switch ($3) {
case 1:
......@@ -7076,7 +7073,7 @@ opt_place:
opt_to:
/* empty */ {}
| TO_SYM {}
| EQ {}
| '=' {}
| AS {}
;
......@@ -7943,13 +7940,13 @@ bool_pri:
if ($$ == NULL)
MYSQL_YYABORT;
}
| bool_pri comp_op predicate %prec EQ
| bool_pri comp_op predicate %prec '='
{
$$= (*$2)(0)->create($1,$3);
if ($$ == NULL)
MYSQL_YYABORT;
}
| bool_pri comp_op all_or_any '(' subselect ')' %prec EQ
| bool_pri comp_op all_or_any '(' subselect ')' %prec '='
{
$$= all_any_subquery_creator($1, $2, $3, $5);
if ($$ == NULL)
......@@ -8172,11 +8169,11 @@ not2:
;
comp_op:
EQ { $$ = &comp_eq_creator; }
'=' { $$ = &comp_eq_creator; }
| GE { $$ = &comp_ge_creator; }
| GT_SYM { $$ = &comp_gt_creator; }
| '>' { $$ = &comp_gt_creator; }
| LE { $$ = &comp_le_creator; }
| LT { $$ = &comp_lt_creator; }
| '<' { $$ = &comp_lt_creator; }
| NE { $$ = &comp_ne_creator; }
;
......@@ -10197,7 +10194,7 @@ date_time_type:
table_alias:
/* empty */
| AS
| EQ
| '='
;
opt_table_alias:
......@@ -11100,7 +11097,7 @@ ident_eq_value:
;
equal:
EQ {}
'=' {}
| SET_VAR {}
;
......@@ -13968,11 +13965,11 @@ handler_rkey_function:
;
handler_rkey_mode:
EQ { $$=HA_READ_KEY_EXACT; }
'=' { $$=HA_READ_KEY_EXACT; }
| GE { $$=HA_READ_KEY_OR_NEXT; }
| LE { $$=HA_READ_KEY_OR_PREV; }
| GT_SYM { $$=HA_READ_AFTER_KEY; }
| LT { $$=HA_READ_BEFORE_KEY; }
| '>' { $$=HA_READ_AFTER_KEY; }
| '<' { $$=HA_READ_BEFORE_KEY; }
;
/* GRANT / REVOKE */
......@@ -14744,7 +14741,7 @@ no_definer:
;
definer:
DEFINER_SYM EQ user
DEFINER_SYM '=' user
{
thd->lex->definer= get_current_user(thd, $3);
}
......@@ -14771,11 +14768,11 @@ view_replace:
;
view_algorithm:
ALGORITHM_SYM EQ UNDEFINED_SYM
ALGORITHM_SYM '=' UNDEFINED_SYM
{ Lex->create_view_algorithm= DTYPE_ALGORITHM_UNDEFINED; }
| ALGORITHM_SYM EQ MERGE_SYM
| ALGORITHM_SYM '=' MERGE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_MERGE; }
| ALGORITHM_SYM EQ TEMPTABLE_SYM
| ALGORITHM_SYM '=' TEMPTABLE_SYM
{ Lex->create_view_algorithm= VIEW_ALGORITHM_TMPTABLE; }
;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment