diff options
author | Konstantin Osipov <kostja@sun.com> | 2010-02-02 12:22:17 +0300 |
---|---|---|
committer | Konstantin Osipov <kostja@sun.com> | 2010-02-02 12:22:17 +0300 |
commit | c6c1ddabaf2d41b362921524d617fbc772c1c9b6 (patch) | |
tree | 919a1043e20b3f1f6a58331ae90a4a9529b0ab5e /sql/sql_yacc.yy | |
parent | 665100b69dfebe45e2d3b68116c6718560bf63b2 (diff) | |
parent | d4f23f0cf6db38731a161c5c7b0b056fc67e5c02 (diff) | |
download | mariadb-git-c6c1ddabaf2d41b362921524d617fbc772c1c9b6.tar.gz |
Merge next-mr -> next-4284.
Diffstat (limited to 'sql/sql_yacc.yy')
-rw-r--r-- | sql/sql_yacc.yy | 199 |
1 files changed, 126 insertions, 73 deletions
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6d946e42262..b1a740db9a5 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -682,6 +682,35 @@ bool setup_select_in_parentheses(LEX *lex) return FALSE; } +static bool add_create_index_prepare (LEX *lex, Table_ident *table) +{ + lex->sql_command= SQLCOM_CREATE_INDEX; + if (!lex->current_select->add_table_to_list(lex->thd, table, NULL, + TL_OPTION_UPDATING, + TL_WRITE_ALLOW_READ)) + return TRUE; + lex->alter_info.reset(); + lex->alter_info.flags= ALTER_ADD_INDEX; + lex->col_list.empty(); + lex->change= NullS; + return FALSE; +} + +static bool add_create_index (LEX *lex, Key::Keytype type, + const LEX_STRING &name, + KEY_CREATE_INFO *info= NULL, bool generated= 0) +{ + Key *key; + key= new Key(type, name, info ? info : &lex->key_create_info, generated, + lex->col_list); + if (key == NULL) + return TRUE; + + lex->alter_info.key_list.push_back(key); + lex->col_list.empty(); + return FALSE; +} + %} %union { int num; @@ -1435,7 +1464,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); option_type opt_var_type opt_var_ident_type %type <key_type> - key_type opt_unique_or_fulltext constraint_key_type + normal_key_type opt_unique constraint_key_type fulltext spatial %type <key_alg> btree_or_rtree @@ -1538,7 +1567,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b, ulong *yystacksize); view_suid view_tail view_list_opt view_list view_select view_check_option trigger_tail sp_tail sf_tail udf_tail event_tail install uninstall partition_entry binlog_base64_event - init_key_options key_options key_opts key_opt key_using_alg + init_key_options normal_key_options normal_key_opts all_key_opt + spatial_key_options fulltext_key_options normal_key_opt + fulltext_key_opt spatial_key_opt fulltext_key_opts spatial_key_opts + key_using_alg part_column_list server_def server_options_list server_option definer_opt no_definer definer @@ -2003,36 +2035,37 @@ create: } create_table_set_open_action_and_adjust_tables(lex); } - | CREATE opt_unique_or_fulltext INDEX_SYM ident key_alg ON + | CREATE opt_unique INDEX_SYM ident key_alg ON table_ident + { + if (add_create_index_prepare(Lex, $7)) + MYSQL_YYABORT; + } + '(' key_list ')' normal_key_options + { + if (add_create_index(Lex, $2, $4)) + MYSQL_YYABORT; + } + | CREATE fulltext INDEX_SYM ident init_key_options ON table_ident { - LEX *lex=Lex; - lex->sql_command= SQLCOM_CREATE_INDEX; - if (!lex->current_select->add_table_to_list(lex->thd, $7, - NULL, - TL_OPTION_UPDATING, - TL_WRITE_ALLOW_READ)) + if (add_create_index_prepare(Lex, $7)) MYSQL_YYABORT; - lex->alter_info.reset(); - lex->alter_info.flags= ALTER_ADD_INDEX; - lex->col_list.empty(); - lex->change=NullS; } - '(' key_list ')' key_options + '(' key_list ')' fulltext_key_options { - LEX *lex=Lex; - Key *key; - if ($2 != Key::FULLTEXT && lex->key_create_info.parser_name.str) - { - my_parse_error(ER(ER_SYNTAX_ERROR)); + if (add_create_index(Lex, $2, $4)) MYSQL_YYABORT; - } - key= new Key($2, $4, &lex->key_create_info, 0, - lex->col_list); - if (key == NULL) + } + | CREATE spatial INDEX_SYM ident init_key_options ON + table_ident + { + if (add_create_index_prepare(Lex, $7)) + MYSQL_YYABORT; + } + '(' key_list ')' spatial_key_options + { + if (add_create_index(Lex, $2, $4)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident { @@ -4456,7 +4489,7 @@ part_func_expr: lex->safe_to_cache_query= 1; if (not_corr_func) { - my_parse_error(ER(ER_CONST_EXPR_IN_PARTITION_FUNC_ERROR)); + my_parse_error(ER(ER_WRONG_EXPR_IN_PARTITION_FUNC_ERROR)); MYSQL_YYABORT; } $$=$1; @@ -5239,31 +5272,28 @@ column_def: ; key_def: - key_type opt_ident key_alg '(' key_list ')' key_options + normal_key_type opt_ident key_alg '(' key_list ')' normal_key_options { - LEX *lex=Lex; - if ($1 != Key::FULLTEXT && lex->key_create_info.parser_name.str) - { - my_parse_error(ER(ER_SYNTAX_ERROR)); + if (add_create_index (Lex, $1, $2)) MYSQL_YYABORT; - } - Key *key= new Key($1, $2, &lex->key_create_info, 0, - lex->col_list); - if (key == NULL) + } + | fulltext opt_key_or_index opt_ident init_key_options + '(' key_list ')' fulltext_key_options + { + if (add_create_index (Lex, $1, $3)) + MYSQL_YYABORT; + } + | spatial opt_key_or_index opt_ident init_key_options + '(' key_list ')' spatial_key_options + { + if (add_create_index (Lex, $1, $3)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint constraint_key_type opt_ident key_alg - '(' key_list ')' key_options + '(' key_list ')' normal_key_options { - LEX *lex=Lex; - Key *key= new Key($2, $3.str ? $3 : $1, &lex->key_create_info, 0, - lex->col_list); - if (key == NULL) + if (add_create_index (Lex, $2, $3.str ? $3 : $1)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); /* Alloced by sql_alloc */ } | opt_constraint FOREIGN KEY_SYM opt_ident '(' key_list ')' references { @@ -5277,13 +5307,9 @@ key_def: if (key == NULL) MYSQL_YYABORT; lex->alter_info.key_list.push_back(key); - key= new Key(Key::MULTIPLE, $1.str ? $1 : $4, - &default_key_create_info, 1, - lex->col_list); - if (key == NULL) + if (add_create_index (lex, Key::MULTIPLE, $1.str ? $1 : $4, + &default_key_create_info, 1)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); /* Alloced by sql_alloc */ /* Only used for ALTER TABLE. Ignored otherwise. */ lex->alter_info.flags|= ALTER_FOREIGN_KEY; } @@ -5902,19 +5928,8 @@ delete_option: | SET DEFAULT { $$= (int) Foreign_key::FK_OPTION_DEFAULT; } ; -key_type: +normal_key_type: key_or_index { $$= Key::MULTIPLE; } - | FULLTEXT_SYM opt_key_or_index { $$= Key::FULLTEXT; } - | SPATIAL_SYM opt_key_or_index - { -#ifdef HAVE_SPATIAL - $$= Key::SPATIAL; -#else - my_error(ER_FEATURE_DISABLED, MYF(0), - sym_group_geom.name, sym_group_geom.needed_define); - MYSQL_YYABORT; -#endif - } ; constraint_key_type: @@ -5938,11 +5953,17 @@ keys_or_index: | INDEXES {} ; -opt_unique_or_fulltext: +opt_unique: /* empty */ { $$= Key::MULTIPLE; } | UNIQUE_SYM { $$= Key::UNIQUE; } - | FULLTEXT_SYM { $$= Key::FULLTEXT;} - | SPATIAL_SYM + ; + +fulltext: + FULLTEXT_SYM { $$= Key::FULLTEXT;} + ; + +spatial: + SPATIAL_SYM { #ifdef HAVE_SPATIAL $$= Key::SPATIAL; @@ -5971,14 +5992,34 @@ key_alg: | init_key_options key_using_alg ; -key_options: +normal_key_options: + /* empty */ {} + | normal_key_opts + ; + +fulltext_key_options: /* empty */ {} - | key_opts + | fulltext_key_opts + ; + +spatial_key_options: + /* empty */ {} + | spatial_key_opts + ; + +normal_key_opts: + normal_key_opt + | normal_key_opts normal_key_opt + ; + +spatial_key_opts: + spatial_key_opt + | spatial_key_opts spatial_key_opt ; -key_opts: - key_opt - | key_opts key_opt +fulltext_key_opts: + fulltext_key_opt + | fulltext_key_opts fulltext_key_opt ; key_using_alg: @@ -5986,10 +6027,22 @@ key_using_alg: | TYPE_SYM btree_or_rtree { Lex->key_create_info.algorithm= $2; } ; -key_opt: - key_using_alg - | KEY_BLOCK_SIZE opt_equal ulong_num +all_key_opt: + KEY_BLOCK_SIZE opt_equal ulong_num { Lex->key_create_info.block_size= $3; } + ; + +normal_key_opt: + all_key_opt + | key_using_alg + ; + +spatial_key_opt: + all_key_opt + ; + +fulltext_key_opt: + all_key_opt | WITH PARSER_SYM IDENT_sys { if (plugin_is_ready(&$3, MYSQL_FTPARSER_PLUGIN)) |