1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-01 03:47:19 +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:
Alexey Botchkov
2013-04-13 11:59:16 +05:00
parent 1a600125ff
commit d8dccde6df
19 changed files with 523 additions and 88 deletions

View File

@ -222,8 +222,9 @@ public:
enum drop_type {KEY, COLUMN };
const char *name;
enum drop_type type;
Alter_drop(enum drop_type par_type,const char *par_name)
:name(par_name), type(par_type) {}
bool drop_if_exists;
Alter_drop(enum drop_type par_type,const char *par_name, bool par_exists)
:name(par_name), type(par_type), drop_if_exists(par_exists) {}
/**
Used to make a clone of this object for ALTER/CREATE TABLE
@sa comment for Key_part_spec::clone
@ -257,20 +258,23 @@ public:
LEX_STRING name;
engine_option_value *option_list;
bool generated;
bool create_if_not_exists;
Key(enum Keytype type_par, const LEX_STRING &name_arg,
KEY_CREATE_INFO *key_info_arg,
bool generated_arg, List<Key_part_spec> &cols,
engine_option_value *create_opt)
engine_option_value *create_opt, bool if_not_exists_opt)
:type(type_par), key_create_info(*key_info_arg), columns(cols),
name(name_arg), option_list(create_opt), generated(generated_arg)
name(name_arg), option_list(create_opt), generated(generated_arg),
create_if_not_exists(if_not_exists_opt)
{}
Key(enum Keytype type_par, const char *name_arg, size_t name_len_arg,
KEY_CREATE_INFO *key_info_arg, bool generated_arg,
List<Key_part_spec> &cols,
engine_option_value *create_opt)
engine_option_value *create_opt, bool if_not_exists_opt)
:type(type_par), key_create_info(*key_info_arg), columns(cols),
option_list(create_opt), generated(generated_arg)
option_list(create_opt), generated(generated_arg),
create_if_not_exists(if_not_exists_opt)
{
name.str= (char *)name_arg;
name.length= name_len_arg;
@ -301,8 +305,10 @@ public:
uint delete_opt, update_opt, match_opt;
Foreign_key(const LEX_STRING &name_arg, List<Key_part_spec> &cols,
Table_ident *table, List<Key_part_spec> &ref_cols,
uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg)
:Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols, NULL),
uint delete_opt_arg, uint update_opt_arg, uint match_opt_arg,
bool if_not_exists_opt)
:Key(FOREIGN_KEY, name_arg, &default_key_create_info, 0, cols, NULL,
if_not_exists_opt),
ref_table(table), ref_columns(ref_cols),
delete_opt(delete_opt_arg), update_opt(update_opt_arg),
match_opt(match_opt_arg)