diff options
author | Georgi Kodinov <joro@sun.com> | 2009-12-11 16:02:47 +0200 |
---|---|---|
committer | Georgi Kodinov <joro@sun.com> | 2009-12-11 16:02:47 +0200 |
commit | 97620e3ba8353b62e90c56f800b230a7ebd15e4f (patch) | |
tree | b0429a55cc7533019dbc37b87f53a7608686cf95 | |
parent | 7b174dcafcab24582f7d3f255482bcc460e6b451 (diff) | |
parent | 30e51fe8540026f00c2c599098257c1e33c9b94f (diff) | |
download | mariadb-git-97620e3ba8353b62e90c56f800b230a7ebd15e4f.tar.gz |
merge of bug #49250 to 5.1-bugteam
-rw-r--r-- | mysql-test/r/fulltext.result | 14 | ||||
-rw-r--r-- | mysql-test/r/gis.result | 13 | ||||
-rw-r--r-- | mysql-test/t/fulltext.test | 21 | ||||
-rw-r--r-- | mysql-test/t/gis.test | 15 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 197 |
5 files changed, 188 insertions, 72 deletions
diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index 6022231907b..1ef6656e7a4 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -552,6 +552,20 @@ MATCH (col) AGAINST('findme') DEALLOCATE PREPARE s; DROP TABLE t1; # +# Bug #49250 : spatial btree index corruption and crash +# Part two : fulltext syntax check +# +CREATE TABLE t1(col1 TEXT, +FULLTEXT INDEX USING BTREE (col1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1))' at line 2 +CREATE TABLE t2(col1 TEXT); +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1 +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1)' at line 1 +DROP TABLE t2; +End of 5.0 tests +# # Bug #47930: MATCH IN BOOLEAN MODE returns too many results # inside subquery # diff --git a/mysql-test/r/gis.result b/mysql-test/r/gis.result index b40ff6be160..3e28227d542 100644 --- a/mysql-test/r/gis.result +++ b/mysql-test/r/gis.result @@ -984,6 +984,19 @@ GEOMFROMTEXT( SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); 1 DROP TABLE t1; +# +# Bug #49250 : spatial btree index corruption and crash +# Part one : spatial syntax check +# +CREATE TABLE t1(col1 MULTIPOLYGON NOT NULL, +SPATIAL INDEX USING BTREE (col1)); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1))' at line 2 +CREATE TABLE t2(col1 MULTIPOLYGON NOT NULL); +CREATE SPATIAL INDEX USING BTREE ON t2(col); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE ON t2(col)' at line 1 +ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); +ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'USING BTREE (col1)' at line 1 +DROP TABLE t2; End of 5.0 tests create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime); create view v1 as select * from t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 4537559509d..3853a224fd5 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -485,6 +485,27 @@ EXECUTE s; DEALLOCATE PREPARE s; DROP TABLE t1; + +--echo # +--echo # Bug #49250 : spatial btree index corruption and crash +--echo # Part two : fulltext syntax check +--echo # + +--error ER_PARSE_ERROR +CREATE TABLE t1(col1 TEXT, + FULLTEXT INDEX USING BTREE (col1)); +CREATE TABLE t2(col1 TEXT); +--error ER_PARSE_ERROR +CREATE FULLTEXT INDEX USING BTREE ON t2(col); +--error ER_PARSE_ERROR +ALTER TABLE t2 ADD FULLTEXT INDEX USING BTREE (col1); + +DROP TABLE t2; + + +--echo End of 5.0 tests + + --echo # --echo # Bug #47930: MATCH IN BOOLEAN MODE returns too many results --echo # inside subquery diff --git a/mysql-test/t/gis.test b/mysql-test/t/gis.test index 2d10c3bf1e1..bc0695aaa93 100644 --- a/mysql-test/t/gis.test +++ b/mysql-test/t/gis.test @@ -670,6 +670,21 @@ SELECT 1 FROM t1 WHERE a <> (SELECT GEOMETRYCOLLECTIONFROMWKB(b) FROM t1); DROP TABLE t1; +--echo # +--echo # Bug #49250 : spatial btree index corruption and crash +--echo # Part one : spatial syntax check +--echo # + +--error ER_PARSE_ERROR +CREATE TABLE t1(col1 MULTIPOLYGON NOT NULL, + SPATIAL INDEX USING BTREE (col1)); +CREATE TABLE t2(col1 MULTIPOLYGON NOT NULL); +--error ER_PARSE_ERROR +CREATE SPATIAL INDEX USING BTREE ON t2(col); +--error ER_PARSE_ERROR +ALTER TABLE t2 ADD SPATIAL INDEX USING BTREE (col1); + +DROP TABLE t2; --echo End of 5.0 tests diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 72b8aa32e30..f8736850684 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -596,6 +596,35 @@ Item* handle_sql2003_note184_exception(THD *thd, Item* left, bool equal, DBUG_RETURN(result); } + +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)) + 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 char *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; @@ -1330,7 +1359,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 @@ -1429,7 +1458,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 server_def server_options_list server_option definer_opt no_definer definer END_OF_INPUT @@ -1823,35 +1855,37 @@ create: $5->table.str); } } - | 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.str)) + 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)) + 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.str)) MYSQL_YYABORT; - } - key= new Key($2, $4.str, &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.str)) MYSQL_YYABORT; - lex->alter_info.key_list.push_back(key); - lex->col_list.empty(); } | CREATE DATABASE opt_if_not_exists ident { @@ -4806,32 +4840,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; - const char *key_name= $3 ? $3 : $1; - Key *key= new Key($2, key_name, &lex->key_create_info, 0, - lex->col_list); - if (key == NULL) + if (add_create_index (Lex, $2, $3 ? $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 { @@ -4847,13 +4877,9 @@ key_def: if (key == NULL) MYSQL_YYABORT; lex->alter_info.key_list.push_back(key); - key= new Key(Key::MULTIPLE, key_name, - &default_key_create_info, 1, - lex->col_list); - if (key == NULL) + if (add_create_index (lex, Key::MULTIPLE, key_name, + &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; } @@ -5421,19 +5447,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: @@ -5457,11 +5472,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; @@ -5490,14 +5511,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: @@ -5505,10 +5546,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)) |