Skip to content

Commit

Permalink
Crash when giving error message for ALTER SEQUENCE
Browse files Browse the repository at this point in the history
Fixes MDEV-14761 "Assertion `!mysql_parse_status || thd->is_error() ||
thd->get_internal_handler()' failed in parse_sql"
  • Loading branch information
montywi committed Feb 15, 2018
1 parent c17a06a commit 7bd81c7
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 8 deletions.
9 changes: 9 additions & 0 deletions mysql-test/suite/sql_sequence/other.result
Original file line number Diff line number Diff line change
Expand Up @@ -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;
11 changes: 11 additions & 0 deletions mysql-test/suite/sql_sequence/other.test
Original file line number Diff line number Diff line change
Expand Up @@ -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;
35 changes: 31 additions & 4 deletions sql/sql_yacc.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down
35 changes: 31 additions & 4 deletions sql/sql_yacc_ora.yy
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand All @@ -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;
}
Expand Down

0 comments on commit 7bd81c7

Please sign in to comment.