From b1a8b3aa6eb3f8f8c2df218e4eb25e4af710b66a Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Wed, 4 Aug 2010 15:58:09 +0300 Subject: [PATCH 1/3] Bug #42144: plugin_load fails Reverted the ulong->uint diff Re-applied the first diff. The original commit message follows: enum plugin system variables are ulong internally, not int. On systems where long is not the same as an int it causes problems. Fixed by correct typecasting. Removed the test from the experimental list. --- include/mysql/plugin.h | 2 +- mysys/my_getopt.c | 10 +++++----- sql/sql_plugin.cc | 8 ++++---- storage/example/ha_example.cc | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h index c2ca8a0f94e..55ef6070f85 100644 --- a/include/mysql/plugin.h +++ b/include/mysql/plugin.h @@ -318,7 +318,7 @@ DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \ #name, comment, check, update, &varname, def, min, max, blk } #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ -DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned int) = { \ +DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ #name, comment, check, update, &varname, def, typelib } diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index 6ed4189a69a..0327db33e98 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -664,13 +664,13 @@ static int setval(const struct my_option *opts, void *value, char *argument, Accept an integer representation of the enumerated item. */ char *endptr; - uint arg= (uint) strtoul(argument, &endptr, 10); + ulong arg= strtoul(argument, &endptr, 10); if (*endptr || arg >= opts->typelib->count) return EXIT_ARGUMENT_INVALID; - *(uint*)result_pos= arg; + *((ulong*) result_pos)= arg; } else - *(uint*)result_pos= type - 1; + *((ulong*) result_pos)= type - 1; } break; case GET_SET: @@ -1008,7 +1008,7 @@ static void init_one_value(const struct my_option *option, void *variable, *((int*) variable)= (int) getopt_ll_limit_value((int) value, option, NULL); break; case GET_ENUM: - *((uint*) variable)= (uint) value; + *((ulong*) variable)= (ulong) value; break; case GET_UINT: *((uint*) variable)= (uint) getopt_ull_limit_value((uint) value, option, NULL); @@ -1248,7 +1248,7 @@ void my_print_variables(const struct my_option *options) } break; case GET_ENUM: - printf("%s\n", get_type(optp->typelib, *(uint*) value)); + printf("%s\n", get_type(optp->typelib, *(ulong*) value)); break; case GET_STR: case GET_STR_ALLOC: /* fall through */ diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 6eed702e5ec..a5640f5d80c 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3030,12 +3030,12 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, Allocate temporary space for the value of the tristate. This option will have a limited lifetime and is not used beyond server initialization. - GET_ENUM value is unsigned integer. + GET_ENUM value is a unsigned long integer. */ options[0].value= options[1].value= (uchar **)alloc_root(mem_root, - sizeof(uint)); - *((uint*) options[0].value)= *((uint*) options[1].value)= - (uint) options[0].def_value; + sizeof(ulong)); + *((ulong*) options[0].value)= *((ulong*) options[1].value)= + (ulong) options[0].def_value; options+= 2; diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 402be70efab..2a4fe538c85 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -848,7 +848,7 @@ int ha_example::create(const char *name, TABLE *table_arg, struct st_mysql_storage_engine example_storage_engine= { MYSQL_HANDLERTON_INTERFACE_VERSION }; -static uint srv_enum_var= 0; +static ulong srv_enum_var= 0; static ulong srv_ulong_var= 0; const char *enum_var_names[]= From 0c81dcf332bd9b3e2a68354efab9bf6ea96df2d3 Mon Sep 17 00:00:00 2001 From: Martin Hansson Date: Thu, 5 Aug 2010 12:42:14 +0200 Subject: [PATCH 2/3] Bug#54568: create view cause Assertion failed: 0, file .\item_subselect.cc, line 836 IN quantified predicates are never executed directly. They are rather wrapped inside nodes called IN Optimizers (Item_in_optimizer) which take care of the execution. However, this is not done during query preparation. Unfortunately the LIKE predicate pre-evaluates constant right-hand side arguments even during name resolution. Likely this is meant as an optimization. Fixed by not pre-evaluating LIKE arguments in view prepare mode. --- mysql-test/r/subselect4.result | 21 +++++++++++++++++++++ mysql-test/t/subselect4.test | 16 ++++++++++++++++ sql/item_cmpfunc.cc | 2 +- 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 482e0045840..fad65d3f000 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -59,3 +59,24 @@ FROM t3 WHERE 1 = 0 GROUP BY 1; (SELECT 1 FROM t1,t2 WHERE t2.b > t3.b) DROP TABLE t1,t2,t3; End of 5.0 tests. +# +# Bug#54568: create view cause Assertion failed: 0, +# file .\item_subselect.cc, line 836 +# +EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1249 Select 2 was reduced during optimization +DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +id select_type table type possible_keys key key_len ref rows Extra +1 PRIMARY NULL NULL NULL NULL NULL NULL NULL No tables used +Warnings: +Note 1249 Select 2 was reduced during optimization +# None of the below should crash +CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); +DROP VIEW v1, v2; +# +# End of 5.1 tests. +# diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 440eca22828..2c6efdbaac2 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -62,3 +62,19 @@ FROM t3 WHERE 1 = 0 GROUP BY 1; DROP TABLE t1,t2,t3; --echo End of 5.0 tests. + +--echo # +--echo # Bug#54568: create view cause Assertion failed: 0, +--echo # file .\item_subselect.cc, line 836 +--echo # +EXPLAIN SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +DESCRIBE SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +--echo # None of the below should crash +CREATE VIEW v1 AS SELECT 1 LIKE ( 1 IN ( SELECT 1 ) ); +CREATE VIEW v2 AS SELECT 1 LIKE '%' ESCAPE ( 1 IN ( SELECT 1 ) ); +DROP VIEW v1, v2; + + +--echo # +--echo # End of 5.1 tests. +--echo # diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index e91aba63023..fe4616f64d7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -4606,7 +4606,7 @@ bool Item_func_like::fix_fields(THD *thd, Item **ref) return TRUE; } - if (escape_item->const_item()) + if (escape_item->const_item() && !thd->lex->view_prepare_mode) { /* If we are on execution stage */ String *escape_str= escape_item->val_str(&cmp.value1); From 7b3b8ae154da00cb35c067db62a2df57f0ea978f Mon Sep 17 00:00:00 2001 From: Georgi Kodinov Date: Thu, 5 Aug 2010 15:10:24 +0300 Subject: [PATCH 3/3] Addendum to bug #42144 : fixed a wrong type conversation causing plugin tests failures on sparc64. --- sql/sql_plugin.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index a5640f5d80c..e0fc88c3068 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -3319,7 +3319,7 @@ static int test_plugin_options(MEM_ROOT *tmp_root, struct st_plugin_int *tmp, Set plugin loading policy from option value. First element in the option list is always the option value. */ - plugin_load_policy= (enum_plugin_load_policy)*(uint*)opts[0].value; + plugin_load_policy= (enum_plugin_load_policy)*(ulong*)opts[0].value; } disable_plugin= (plugin_load_policy == PLUGIN_OFF);