Commit fbe604d8 authored by Daniel Black's avatar Daniel Black

MDEV-32795: ALTER SEQUENCE IF NOT EXISTS non_existing_seq Errors rather than note

Like all IF NOT EXISTS syntax, a Note should be generated.

The original commit of Seqeuences cleared the IF NOT EXISTS part
in the sql/sql_yacc.yy with lex->create_info.init(). Without this
bit set there was no way it could do anything other than error.

To remedy this removal, the sql_yacc.yy components have been
minimised as they where all set at the beginning of the ALTER.
This way the opt_if_not_exists correctly set the IF_EXISTS flag.

In MDEV-13005 (bb4dd70e) the error code changed, requiring
ER_UNKNOWN_SEQUENCES to be handled in the function
No_such_table_error_handler::handle_condition.
parent 7504985d
...@@ -210,8 +210,12 @@ create table t1 (a int); ...@@ -210,8 +210,12 @@ create table t1 (a int);
alter sequence t1 minvalue=100; alter sequence t1 minvalue=100;
ERROR 42S02: 'test.t1' is not a SEQUENCE ERROR 42S02: 'test.t1' is not a SEQUENCE
drop table t1; drop table t1;
#
# MDEV-32795: ALTER SEQUENCE IF NOT EXISTS non_existing_seq Errors rather than note
#
alter sequence if exists t1 minvalue=100; alter sequence if exists t1 minvalue=100;
ERROR 42S02: Unknown SEQUENCE: 't1' Warnings:
Note 4091 Unknown SEQUENCE: 'test.t1'
alter sequence t1 minvalue=100; alter sequence t1 minvalue=100;
ERROR 42S02: Unknown SEQUENCE: 't1' ERROR 42S02: Unknown SEQUENCE: 't1'
create sequence t1; create sequence t1;
......
...@@ -120,8 +120,12 @@ create table t1 (a int); ...@@ -120,8 +120,12 @@ create table t1 (a int);
alter sequence t1 minvalue=100; alter sequence t1 minvalue=100;
drop table t1; drop table t1;
--error ER_UNKNOWN_SEQUENCES --echo #
--echo # MDEV-32795: ALTER SEQUENCE IF NOT EXISTS non_existing_seq Errors rather than note
--echo #
alter sequence if exists t1 minvalue=100; alter sequence if exists t1 minvalue=100;
--error ER_UNKNOWN_SEQUENCES --error ER_UNKNOWN_SEQUENCES
alter sequence t1 minvalue=100; alter sequence t1 minvalue=100;
......
...@@ -77,7 +77,9 @@ No_such_table_error_handler::handle_condition(THD *, ...@@ -77,7 +77,9 @@ No_such_table_error_handler::handle_condition(THD *,
Sql_condition ** cond_hdl) Sql_condition ** cond_hdl)
{ {
*cond_hdl= NULL; *cond_hdl= NULL;
if (sql_errno == ER_NO_SUCH_TABLE || sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE) if (sql_errno == ER_NO_SUCH_TABLE
|| sql_errno == ER_NO_SUCH_TABLE_IN_ENGINE
|| sql_errno == ER_UNKNOWN_SEQUENCES)
{ {
m_handled_errors++; m_handled_errors++;
return TRUE; return TRUE;
......
...@@ -8128,11 +8128,7 @@ alter: ...@@ -8128,11 +8128,7 @@ alter:
| ALTER SEQUENCE_SYM opt_if_exists | ALTER SEQUENCE_SYM opt_if_exists
{ {
LEX *lex= Lex; LEX *lex= Lex;
lex->name= null_clex_str;
lex->table_type= TABLE_TYPE_UNKNOWN;
lex->sql_command= SQLCOM_ALTER_SEQUENCE; lex->sql_command= SQLCOM_ALTER_SEQUENCE;
lex->create_info.init();
lex->no_write_to_binlog= 0;
DBUG_ASSERT(!lex->m_sql_cmd); DBUG_ASSERT(!lex->m_sql_cmd);
if (Lex->main_select_push()) if (Lex->main_select_push())
MYSQL_YYABORT; MYSQL_YYABORT;
......
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