Commit 7bd81c72 authored by Monty's avatar Monty

Crash when giving error message for ALTER SEQUENCE

Fixes MDEV-14761 "Assertion `!mysql_parse_status || thd->is_error() ||
thd->get_internal_handler()' failed in parse_sql"
parent c17a06ab
......@@ -162,3 +162,12 @@ select next value for s1;
ERROR HY000: Can't execute the query because you have a conflicting read lock
unlock tables;
drop sequence s1;
#
# MDEV-14761
# Assertion `!mysql_parse_status || thd->is_error() ||
# thd->get_internal_handler()' failed in parse_sql
#
CREATE SEQUENCE s1;
ALTER SEQUENCE s1 MAXVALUE 100 NO MAXVALUE;
ERROR HY000: Option 'MAXVALUE' used twice in statement
DROP SEQUENCE s1;
......@@ -131,3 +131,14 @@ create sequence s2;
select next value for s1;
unlock tables;
drop sequence s1;
--echo #
--echo # MDEV-14761
--echo # Assertion `!mysql_parse_status || thd->is_error() ||
--echo # thd->get_internal_handler()' failed in parse_sql
--echo #
CREATE SEQUENCE s1;
--error ER_DUP_ARGUMENT
ALTER SEQUENCE s1 MAXVALUE 100 NO MAXVALUE;
DROP SEQUENCE s1;
......@@ -2685,59 +2685,80 @@ sequence_def:
| NO_SYM MINVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
}
| NOMINVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
}
| MAXVALUE_SYM opt_equal longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_max_value)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->max_value= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| NO_SYM MAXVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| NOMAXVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| START_SYM opt_with longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_start)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "START"));
Lex->create_info.seq_create_info->start= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_start;
}
| INCREMENT_SYM opt_by longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_increment)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "INCREMENT"));
Lex->create_info.seq_create_info->increment= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_increment;
}
| CACHE_SYM opt_equal longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cache)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE"));
Lex->create_info.seq_create_info->cache= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache;
}
| NOCACHE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cache)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE"));
Lex->create_info.seq_create_info->cache= 0;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache;
}
| CYCLE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cycle)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE"));
Lex->create_info.seq_create_info->cycle= 1;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle;
}
| NOCYCLE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cycle)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE"));
Lex->create_info.seq_create_info->cycle= 0;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle;
}
......@@ -2748,6 +2769,9 @@ sequence_def:
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
YYABORT;
}
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_restart)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart;
}
| RESTART_SYM opt_with longlong_num
......@@ -2757,6 +2781,9 @@ sequence_def:
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
YYABORT;
}
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_restart)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART"));
Lex->create_info.seq_create_info->restart= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart | seq_field_used_restart_value;
}
......
......@@ -2121,59 +2121,80 @@ sequence_def:
| NO_SYM MINVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
}
| NOMINVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_min_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MINVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_min_value;
}
| MAXVALUE_SYM opt_equal longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_max_value)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->max_value= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| NO_SYM MAXVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| NOMAXVALUE_SYM
{
if (Lex->create_info.seq_create_info->used_fields & seq_field_used_max_value)
MYSQL_YYABORT;
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "MAXVALUE"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_max_value;
}
| START_SYM opt_with longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_start)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "START"));
Lex->create_info.seq_create_info->start= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_start;
}
| INCREMENT_SYM opt_by longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_increment)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "INCREMENT"));
Lex->create_info.seq_create_info->increment= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_increment;
}
| CACHE_SYM opt_equal longlong_num
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cache)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE"));
Lex->create_info.seq_create_info->cache= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache;
}
| NOCACHE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cache)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CACHE"));
Lex->create_info.seq_create_info->cache= 0;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cache;
}
| CYCLE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cycle)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE"));
Lex->create_info.seq_create_info->cycle= 1;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle;
}
| NOCYCLE_SYM
{
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_cycle)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "CYCLE"));
Lex->create_info.seq_create_info->cycle= 0;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_cycle;
}
......@@ -2184,6 +2205,9 @@ sequence_def:
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
YYABORT;
}
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_restart)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART"));
Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart;
}
| RESTART_SYM opt_with longlong_num
......@@ -2193,6 +2217,9 @@ sequence_def:
thd->parse_error(ER_SYNTAX_ERROR, "RESTART");
YYABORT;
}
if (Lex->create_info.seq_create_info->used_fields &
seq_field_used_restart)
my_yyabort_error((ER_DUP_ARGUMENT, MYF(0), "RESTART"));
Lex->create_info.seq_create_info->restart= $3;
Lex->create_info.seq_create_info->used_fields|= seq_field_used_restart | seq_field_used_restart_value;
}
......
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