mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252).
Syntax modified to allow statements: ALTER TABLE ADD/DROP COLUMN ALTER TABLE ADD/DROP INDEX ALTER TABLE ADD/DROP FOREIGN KEY ALTER TABLE ADD/DROP PARTITION ALTER TABLE CHANGE COLUMN ALTER TABLE MODIFY COLUMN DROP INDEX to have IF (NOT) EXISTS options. Appropriate implementations added to mysql_alter_table(). per-file comments: mysql-test/r/alter_table.result MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). test result updated. mysql-test/r/fulltext.result MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). mysql-test/r/partition.result test result updated. MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). mysql-test/t/alter_table.test tests added. MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). mysql-test/t/fulltext.test MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). tests added. mysql-test/t/partition.test MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). tests added. sql/field.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). create_if_not_exists field added. sql/field.h MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). create_if_not_exists field added. sql/partition_info.h MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). has_unique_name made public. sql/sp_head.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). sql/sql_class.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). create_if_not_exists inited. sql/sql_class.h MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). create_if_not_exists inited. sql/sql_lex.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). check_exists inited. sql/sql_lex.h MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). check_exists inited. sql/sql_parse.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). check_exists inited. sql/sql_table.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). handle_if_exists_options() added. it's called in mysql_alter_table(). sql/sql_trigger.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). check_exists instead of drop_if_exists. sql/sql_view.cc MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). check_exists instead of drop_if_exists. sql/sql_yacc.yy MDEV-318 IF (NOT) EXIST clauses for ALTER TABLE (MWL #252). sintax modified.
This commit is contained in:
@ -2084,7 +2084,7 @@ mysql_execute_command(THD *thd)
|
||||
if (!(lex->sql_command == SQLCOM_UPDATE_MULTI) &&
|
||||
!(lex->sql_command == SQLCOM_SET_OPTION) &&
|
||||
!(lex->sql_command == SQLCOM_DROP_TABLE &&
|
||||
lex->drop_temporary && lex->drop_if_exists) &&
|
||||
lex->drop_temporary && lex->check_exists) &&
|
||||
all_tables_not_ok(thd, all_tables))
|
||||
{
|
||||
/* we warn the slave SQL thread */
|
||||
@ -3285,7 +3285,7 @@ end_with_restore_list:
|
||||
thd->variables.option_bits|= OPTION_KEEP_LOG;
|
||||
}
|
||||
/* DDL and binlog write order are protected by metadata locks. */
|
||||
res= mysql_rm_table(thd, first_table, lex->drop_if_exists,
|
||||
res= mysql_rm_table(thd, first_table, lex->check_exists,
|
||||
lex->drop_temporary);
|
||||
}
|
||||
break;
|
||||
@ -3499,7 +3499,7 @@ end_with_restore_list:
|
||||
#endif
|
||||
if (check_access(thd, DROP_ACL, lex->name.str, NULL, NULL, 1, 0))
|
||||
break;
|
||||
res= mysql_rm_db(thd, lex->name.str, lex->drop_if_exists, 0);
|
||||
res= mysql_rm_db(thd, lex->name.str, lex->check_exists, 0);
|
||||
break;
|
||||
}
|
||||
case SQLCOM_ALTER_DB_UPGRADE:
|
||||
@ -3627,7 +3627,7 @@ end_with_restore_list:
|
||||
case SQLCOM_DROP_EVENT:
|
||||
if (!(res= Events::drop_event(thd,
|
||||
lex->spname->m_db, lex->spname->m_name,
|
||||
lex->drop_if_exists)))
|
||||
lex->check_exists)))
|
||||
my_ok(thd);
|
||||
break;
|
||||
#else
|
||||
@ -4314,7 +4314,7 @@ create_sp_error:
|
||||
|
||||
if (lex->spname->m_db.str == NULL)
|
||||
{
|
||||
if (lex->drop_if_exists)
|
||||
if (lex->check_exists)
|
||||
{
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
ER_SP_DOES_NOT_EXIST, ER(ER_SP_DOES_NOT_EXIST),
|
||||
@ -4383,7 +4383,7 @@ create_sp_error:
|
||||
my_ok(thd);
|
||||
break;
|
||||
case SP_KEY_NOT_FOUND:
|
||||
if (lex->drop_if_exists)
|
||||
if (lex->check_exists)
|
||||
{
|
||||
res= write_bin_log(thd, TRUE, thd->query(), thd->query_length());
|
||||
push_warning_printf(thd, MYSQL_ERROR::WARN_LEVEL_NOTE,
|
||||
@ -4596,7 +4596,7 @@ create_sp_error:
|
||||
|
||||
if ((err_code= drop_server(thd, &lex->server_options)))
|
||||
{
|
||||
if (! lex->drop_if_exists && err_code == ER_FOREIGN_SERVER_DOESNT_EXIST)
|
||||
if (! lex->check_exists && err_code == ER_FOREIGN_SERVER_DOESNT_EXIST)
|
||||
{
|
||||
DBUG_PRINT("info", ("problem dropping server %s",
|
||||
lex->server_options.server_name));
|
||||
@ -6016,7 +6016,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
|
||||
lex->col_list.push_back(new Key_part_spec(*field_name, 0));
|
||||
key= new Key(Key::PRIMARY, null_lex_str,
|
||||
&default_key_create_info,
|
||||
0, lex->col_list, NULL);
|
||||
0, lex->col_list, NULL, lex->check_exists);
|
||||
lex->alter_info.key_list.push_back(key);
|
||||
lex->col_list.empty();
|
||||
}
|
||||
@ -6026,7 +6026,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
|
||||
lex->col_list.push_back(new Key_part_spec(*field_name, 0));
|
||||
key= new Key(Key::UNIQUE, null_lex_str,
|
||||
&default_key_create_info, 0,
|
||||
lex->col_list, NULL);
|
||||
lex->col_list, NULL, lex->check_exists);
|
||||
lex->alter_info.key_list.push_back(key);
|
||||
lex->col_list.empty();
|
||||
}
|
||||
@ -6078,7 +6078,7 @@ bool add_field_to_list(THD *thd, LEX_STRING *field_name, enum_field_types type,
|
||||
new_field->init(thd, field_name->str, type, length, decimals, type_modifier,
|
||||
default_value, on_update_value, comment, change,
|
||||
interval_list, cs, uint_geom_type, vcol_info,
|
||||
create_options))
|
||||
create_options, lex->check_exists))
|
||||
DBUG_RETURN(1);
|
||||
|
||||
lex->alter_info.create_list.push_back(new_field);
|
||||
|
Reference in New Issue
Block a user