From 1f2ef5740360148961151a71603faae497919aa6 Mon Sep 17 00:00:00 2001 From: Igor Babaev Date: Thu, 6 Mar 2014 13:56:34 -0800 Subject: [PATCH 1/8] Fixed bug mdev-5686. The calls of the function remove_eq_conds() may change the and/or structure of the where conditions. So JOIN::equal_cond should be updated for non-recursive calls of remove_eq_conds(). --- mysql-test/r/subselect4.result | 22 ++++++++++++++++++++++ mysql-test/t/subselect4.test | 21 +++++++++++++++++++++ sql/sql_select.cc | 8 +++++++- 3 files changed, 50 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/subselect4.result b/mysql-test/r/subselect4.result index 6c314c448cb..6ab62c801f7 100644 --- a/mysql-test/r/subselect4.result +++ b/mysql-test/r/subselect4.result @@ -2375,5 +2375,27 @@ ORDER BY v2.id; id a2 a3 id a2 a3 DROP VIEW v2; DROP TABLE t1,t2; +# +# MDEV-5686: degenerate disjunct in NOT IN subquery +# +CREATE TABLE t1 (a int, b int, c varchar(3)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,'CAN'),(2,2,'AUS'); +CREATE TABLE t2 (f int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3); +EXPLAIN EXTENDED +SELECT * FROM t2 +WHERE f NOT IN (SELECT b FROM t1 +WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b); +id select_type table type possible_keys key key_len ref rows filtered Extra +1 PRIMARY t2 system NULL NULL NULL NULL 1 100.00 +2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 2 100.00 Using where +Warnings: +Note 1003 select 3 AS `f` from `test`.`t2` where (not(<3>((3,(select `test`.`t1`.`b` from `test`.`t1` where (((`test`.`t1`.`c` = 'USA') or (`test`.`t1`.`c` <> 'USA')) and trigcond((((3) = `test`.`t1`.`b`) or isnull(`test`.`t1`.`b`))) and (`test`.`t1`.`b` = `test`.`t1`.`a`)) having trigcond((`test`.`t1`.`b`))))))) +SELECT * FROM t2 +WHERE f NOT IN (SELECT b FROM t1 +WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b); +f +3 +DROP TABLE t1,t2; SET optimizer_switch= @@global.optimizer_switch; set @@tmp_table_size= @@global.tmp_table_size; diff --git a/mysql-test/t/subselect4.test b/mysql-test/t/subselect4.test index 6aa1fd51859..0d029e1bf8f 100644 --- a/mysql-test/t/subselect4.test +++ b/mysql-test/t/subselect4.test @@ -1970,5 +1970,26 @@ ORDER BY v2.id; DROP VIEW v2; DROP TABLE t1,t2; +--echo # +--echo # MDEV-5686: degenerate disjunct in NOT IN subquery +--echo # + +CREATE TABLE t1 (a int, b int, c varchar(3)) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,1,'CAN'),(2,2,'AUS'); + +CREATE TABLE t2 (f int) ENGINE=MyISAM; +INSERT INTO t2 VALUES (3); + +EXPLAIN EXTENDED +SELECT * FROM t2 + WHERE f NOT IN (SELECT b FROM t1 + WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b); + +SELECT * FROM t2 + WHERE f NOT IN (SELECT b FROM t1 + WHERE 0 OR (c IN ('USA') OR c NOT IN ('USA')) AND a = b); + +DROP TABLE t1,t2; + SET optimizer_switch= @@global.optimizer_switch; set @@tmp_table_size= @@global.tmp_table_size; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index c7f31a9c956..ec71cb3b1b2 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -3530,6 +3530,9 @@ make_join_statistics(JOIN *join, List &tables_list, { conds->update_used_tables(); conds= remove_eq_conds(join->thd, conds, &join->cond_value); + if (conds && conds->type() == Item::COND_ITEM && + ((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC) + join->cond_equal= &((Item_cond_and*) conds)->cond_equal; join->select_lex->where= conds; if (join->cond_value == Item::COND_FALSE) { @@ -13228,7 +13231,10 @@ optimize_cond(JOIN *join, COND *conds, Remove all and-levels where CONST item != CONST item */ DBUG_EXECUTE("where",print_where(conds,"after const change", QT_ORDINARY);); - conds= remove_eq_conds(thd, conds, cond_value) ; + conds= remove_eq_conds(thd, conds, cond_value); + if (conds && conds->type() == Item::COND_ITEM && + ((Item_cond*) conds)->functype() == Item_func::COND_AND_FUNC) + join->cond_equal= &((Item_cond_and*) conds)->cond_equal; DBUG_EXECUTE("info",print_where(conds,"after remove", QT_ORDINARY);); } DBUG_RETURN(conds); From 321ff25f3d419bc1a1fae2390450d1b4db30b64c Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Mar 2014 13:57:07 +0200 Subject: [PATCH 2/8] MDEV-5740: Assertion `!derived->first_select()->exclude_from_table_unique_test || derived->outer_select()-> exclude_from_table_unique_test' failed on 2nd execution of PS with derived_merge Do not check tables of executed units. Debug info about stages of derived tables execution added. --- mysql-test/r/derived_view.result | 40 +++++++++++++++++++++++++ mysql-test/t/derived_view.test | 27 +++++++++++++++++ sql/sql_base.cc | 11 +++++++ sql/sql_derived.cc | 50 +++++++++++++++++++------------- sql/table.h | 4 +++ 5 files changed, 112 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/derived_view.result b/mysql-test/r/derived_view.result index acce2afb124..e958bfbdca4 100644 --- a/mysql-test/r/derived_view.result +++ b/mysql-test/r/derived_view.result @@ -2356,6 +2356,46 @@ id select_type table type possible_keys key key_len ref rows Extra 3 DEPENDENT SUBQUERY pi ref gallery_id gallery_id 4 test.gal.id 4 Using temporary; Using filesort drop table galleries, pictures; # +# MDEV-5740: Assertion +#`!derived->first_select()->exclude_from_table_unique_test || +#derived->outer_select()-> exclude_from_table_unique_test' +#failed on 2nd execution of PS with derived_merge +# +set @save_optimizer_switch5740=@@optimizer_switch; +SET optimizer_switch = 'derived_merge=on'; +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); +PREPARE stmt FROM ' + INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM (SELECT * FROM t1) AS sq +'; +EXECUTE stmt; +select * from t1; +a +1 +2 +3 +4 +1 +2 +EXECUTE stmt; +select * from t1; +a +1 +2 +3 +4 +1 +2 +3 +4 +1 +2 +deallocate prepare stmt; +drop table t1,t2; +set optimizer_switch=@save_optimizer_switch5740; +# # end of 5.3 tests # set optimizer_switch=@exit_optimizer_switch; diff --git a/mysql-test/t/derived_view.test b/mysql-test/t/derived_view.test index 61e11cebad4..de08b1c4d0d 100644 --- a/mysql-test/t/derived_view.test +++ b/mysql-test/t/derived_view.test @@ -1703,6 +1703,33 @@ ORDER BY gallery_name ASC drop table galleries, pictures; +--echo # +--echo # MDEV-5740: Assertion +--echo #`!derived->first_select()->exclude_from_table_unique_test || +--echo #derived->outer_select()-> exclude_from_table_unique_test' +--echo #failed on 2nd execution of PS with derived_merge +--echo # + +set @save_optimizer_switch5740=@@optimizer_switch; +SET optimizer_switch = 'derived_merge=on'; + +CREATE TABLE t1 (a INT); +INSERT INTO t1 VALUES (1),(2); +CREATE TABLE t2 (b INT); +INSERT INTO t2 VALUES (3),(4); + +PREPARE stmt FROM ' + INSERT INTO t1 SELECT * FROM t2 UNION SELECT * FROM (SELECT * FROM t1) AS sq +'; +EXECUTE stmt; +select * from t1; +EXECUTE stmt; +select * from t1; +deallocate prepare stmt; + +drop table t1,t2; +set optimizer_switch=@save_optimizer_switch5740; + --echo # --echo # end of 5.3 tests --echo # diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4e8847d1fe0..9d3a59afa0b 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -1735,6 +1735,17 @@ retry: DBUG_PRINT("info", ("real table: %s.%s", d_name, t_name)); for (TABLE_LIST *tl= table_list;;) { + if (tl && + tl->select_lex && tl->select_lex->master_unit() && + tl->select_lex->master_unit()->executed) + { + /* + There is no sense to check tables of already executed parts + of the query + */ + tl= tl->next_global; + continue; + } if (((! (res= find_table_in_global_list(tl, d_name, t_name))) && (! (res= mysql_lock_have_duplicate(thd, table, tl)))) || ((!res->table || res->table != table->table) && diff --git a/sql/sql_derived.cc b/sql/sql_derived.cc index 3243f0a0eff..83df1ddf59d 100644 --- a/sql/sql_derived.cc +++ b/sql/sql_derived.cc @@ -64,8 +64,10 @@ mysql_handle_derived(LEX *lex, uint phases) { bool res= FALSE; THD *thd= lex->thd; + DBUG_ENTER("mysql_handle_derived"); + DBUG_PRINT("enter", ("phases: 0x%x", phases)); if (!lex->derived_tables) - return FALSE; + DBUG_RETURN(FALSE); lex->thd->derived_tables_processing= TRUE; @@ -123,7 +125,7 @@ mysql_handle_derived(LEX *lex, uint phases) } } lex->thd->derived_tables_processing= FALSE; - return res; + DBUG_RETURN(res); } /* @@ -163,8 +165,10 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases) THD *thd= lex->thd; uint8 allowed_phases= (derived->is_merged_derived() ? DT_PHASES_MERGE : DT_PHASES_MATERIALIZE); + DBUG_ENTER("mysql_handle_single_derived"); + DBUG_PRINT("enter", ("phases: 0x%x allowed: 0x%x", phases, allowed_phases)); if (!lex->derived_tables) - return FALSE; + DBUG_RETURN(FALSE); lex->thd->derived_tables_processing= TRUE; @@ -186,7 +190,7 @@ mysql_handle_single_derived(LEX *lex, TABLE_LIST *derived, uint phases) break; } lex->thd->derived_tables_processing= FALSE; - return res; + DBUG_RETURN(res); } @@ -353,16 +357,17 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) uint tablenr; SELECT_LEX *parent_lex= derived->select_lex; Query_arena *arena, backup; + DBUG_ENTER("mysql_derived_merge"); if (derived->merged) - return FALSE; + DBUG_RETURN(FALSE); if (dt_select->uncacheable & UNCACHEABLE_RAND) { /* There is random function => fall back to materialization. */ derived->change_refs_to_fields(); derived->set_materialized_derived(); - return FALSE; + DBUG_RETURN(FALSE); } if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI || @@ -466,7 +471,7 @@ bool mysql_derived_merge(THD *thd, LEX *lex, TABLE_LIST *derived) exit_merge: if (arena) thd->restore_active_arena(arena, &backup); - return res; + DBUG_RETURN(res); } @@ -492,14 +497,15 @@ exit_merge: bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) { + DBUG_ENTER("mysql_derived_merge_for_insert"); if (derived->merged_for_insert) - return FALSE; + DBUG_RETURN(FALSE); if (derived->is_materialized_derived()) - return mysql_derived_prepare(thd, lex, derived); + DBUG_RETURN(mysql_derived_prepare(thd, lex, derived)); if (!derived->is_multitable()) { if (!derived->single_table_updatable()) - return derived->create_field_translation(thd); + DBUG_RETURN(derived->create_field_translation(thd)); if (derived->merge_underlying_list) { derived->table= derived->merge_underlying_list->table; @@ -507,7 +513,7 @@ bool mysql_derived_merge_for_insert(THD *thd, LEX *lex, TABLE_LIST *derived) derived->merged_for_insert= TRUE; } } - return FALSE; + DBUG_RETURN(FALSE); } @@ -764,9 +770,10 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived) SELECT_LEX *save_current_select= lex->current_select; bool res= FALSE; + DBUG_ENTER("mysql_derived_optimize"); if (unit->optimized) - return FALSE; + DBUG_RETURN(FALSE); lex->current_select= first_select; if (unit->is_union()) @@ -806,7 +813,7 @@ bool mysql_derived_optimize(THD *thd, LEX *lex, TABLE_LIST *derived) } err: lex->current_select= save_current_select; - return res; + DBUG_RETURN(res); } @@ -829,11 +836,12 @@ err: bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) { + DBUG_ENTER("mysql_derived_create"); TABLE *table= derived->table; SELECT_LEX_UNIT *unit= derived->get_unit(); if (table->created) - return FALSE; + DBUG_RETURN(FALSE); select_union *result= (select_union*)unit->result; if (table->s->db_type() == TMP_ENGINE_HTON) { @@ -843,13 +851,13 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) &result->tmp_table_param.recinfo, (unit->first_select()->options | thd->options | TMP_TABLE_ALL_COLUMNS))) - return(TRUE); + DBUG_RETURN(TRUE); } if (open_tmp_table(table)) - return TRUE; + DBUG_RETURN(TRUE); table->file->extra(HA_EXTRA_WRITE_CACHE); table->file->extra(HA_EXTRA_IGNORE_DUP_KEY); - return FALSE; + DBUG_RETURN(FALSE); } @@ -879,11 +887,12 @@ bool mysql_derived_create(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) { + DBUG_ENTER("mysql_derived_fill"); SELECT_LEX_UNIT *unit= derived->get_unit(); bool res= FALSE; if (unit->executed && !unit->uncacheable && !unit->describe) - return FALSE; + DBUG_RETURN(FALSE); /*check that table creation passed without problems. */ DBUG_ASSERT(derived->table && derived->table->created); SELECT_LEX *first_select= unit->first_select(); @@ -925,7 +934,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) unit->cleanup(); lex->current_select= save_current_select; - return res; + DBUG_RETURN(res); } @@ -949,6 +958,7 @@ bool mysql_derived_fill(THD *thd, LEX *lex, TABLE_LIST *derived) bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived) { + DBUG_ENTER("mysql_derived_reinit"); st_select_lex_unit *unit= derived->get_unit(); if (derived->table) @@ -958,5 +968,5 @@ bool mysql_derived_reinit(THD *thd, LEX *lex, TABLE_LIST *derived) /* for derived tables & PS (which can't be reset by Item_subquery) */ unit->reinit_exec_mechanism(); unit->set_thd(thd); - return FALSE; + DBUG_RETURN(FALSE); } diff --git a/sql/table.h b/sql/table.h index c3524ad3adf..30495e4d76f 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1791,9 +1791,11 @@ struct TABLE_LIST } inline void set_merged_derived() { + DBUG_ENTER("set_merged_derived"); derived_type= ((derived_type & DTYPE_MASK) | DTYPE_TABLE | DTYPE_MERGE); set_check_merged(); + DBUG_VOID_RETURN; } inline bool is_materialized_derived() { @@ -1801,9 +1803,11 @@ struct TABLE_LIST } void set_materialized_derived() { + DBUG_ENTER("set_materialized_derived"); derived_type= ((derived_type & DTYPE_MASK) | DTYPE_TABLE | DTYPE_MATERIALIZE); set_check_materialized(); + DBUG_VOID_RETURN; } inline bool is_multitable() { From d8ea8a3d13d2a754a1e80d11619ba3347bb7ee5f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Mar 2014 12:34:16 +0200 Subject: [PATCH 3/8] MDEV-5717: Server crash with insert statement containing DEFAULT into view Item_default_value::arg can be NULL so walk() should take it into consideration. --- mysql-test/r/view.result | 16 ++++++++++++++++ mysql-test/t/view.test | 19 +++++++++++++++++++ sql/item.h | 2 +- 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 8e5c082c6c1..1435b0c7a97 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -4790,6 +4790,22 @@ v1_field1 deallocate prepare my_stmt; DROP VIEW v1,v2; DROP TABLE t1,t2,t3,t4; +# +#MDEV-5717: Server crash with insert statement containing DEFAULT into +#view +# +CREATE TABLE t1 ( +`id` int(10) unsigned NOT NULL AUTO_INCREMENT, +`test` tinyint(3) unsigned NOT NULL DEFAULT '0', +PRIMARY KEY (`id`) +); +CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1); +INSERT INTO v1 SET test = DEFAULT; +select * from v1; +id test +1 0 +drop view v1; +drop table t1; # ----------------------------------------------------------------- # -- End of 5.3 tests. # ----------------------------------------------------------------- diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index d3a7e098ad8..5a2d90180ea 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -4720,6 +4720,25 @@ deallocate prepare my_stmt; DROP VIEW v1,v2; DROP TABLE t1,t2,t3,t4; +--echo # +--echo #MDEV-5717: Server crash with insert statement containing DEFAULT into +--echo #view +--echo # +CREATE TABLE t1 ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `test` tinyint(3) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (`id`) +); + +CREATE VIEW v1 AS (select t1.id AS id, t1.test AS test from t1); + +INSERT INTO v1 SET test = DEFAULT; + +select * from v1; + +drop view v1; +drop table t1; + --echo # ----------------------------------------------------------------- --echo # -- End of 5.3 tests. --echo # ----------------------------------------------------------------- diff --git a/sql/item.h b/sql/item.h index 80f8ef966bb..e8619ca4f92 100644 --- a/sql/item.h +++ b/sql/item.h @@ -3551,7 +3551,7 @@ public: bool walk(Item_processor processor, bool walk_subquery, uchar *args) { - return arg->walk(processor, walk_subquery, args) || + return (arg && arg->walk(processor, walk_subquery, args)) || (this->*processor)(args); } From cd29dc98216d822ad701d604b3eda886e1db2aaa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Mar 2014 15:50:00 +0200 Subject: [PATCH 4/8] MDEV-5717: Server crash with insert statement containing DEFAULT into view Item_default_value::arg can be NULL so walk() should take it into consideration. --- sql/item.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/item.h b/sql/item.h index 798abb5112a..fd4b8cb3e14 100644 --- a/sql/item.h +++ b/sql/item.h @@ -2890,7 +2890,7 @@ public: bool walk(Item_processor processor, bool walk_subquery, uchar *args) { - return arg->walk(processor, walk_subquery, args) || + return (arg && arg->walk(processor, walk_subquery, args)) || (this->*processor)(args); } From 18830d78a3796076747278afe9c85b48531f8f9c Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Mar 2014 16:34:34 +0100 Subject: [PATCH 5/8] mtr: move if(unix_socket) test to include/have_unix_socket.inc --- mysql-test/include/have_unix_socket.inc | 10 ++++++++++ mysql-test/suite/plugins/t/unix_socket.test | 6 +----- 2 files changed, 11 insertions(+), 5 deletions(-) create mode 100644 mysql-test/include/have_unix_socket.inc diff --git a/mysql-test/include/have_unix_socket.inc b/mysql-test/include/have_unix_socket.inc new file mode 100644 index 00000000000..6e4c3b9826b --- /dev/null +++ b/mysql-test/include/have_unix_socket.inc @@ -0,0 +1,10 @@ +--source include/not_embedded.inc + +if (!$AUTH_SOCKET_SO) { + skip No unix_socket plugin; +} + +if (!$USER) { + skip USER variable is undefined; +} + diff --git a/mysql-test/suite/plugins/t/unix_socket.test b/mysql-test/suite/plugins/t/unix_socket.test index fc2e6c5b3c6..3ce1d0323fb 100644 --- a/mysql-test/suite/plugins/t/unix_socket.test +++ b/mysql-test/suite/plugins/t/unix_socket.test @@ -1,8 +1,4 @@ ---source include/not_embedded.inc - -if (!$AUTH_SOCKET_SO) { - skip No auth_socket plugin; -} +--source include/have_unix_socket.inc let $plugindir=`SELECT @@global.plugin_dir`; From 5616bd55973cd1c4f4005e7033e7adff7397214d Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Mar 2014 16:35:14 +0100 Subject: [PATCH 6/8] unix_socket bypasses make_if_fail by not doing any network reads --- mysql-test/r/failed_auth_unixsocket.result | 12 +++++++++ mysql-test/t/failed_auth_unixsocket.test | 29 ++++++++++++++++++++++ sql/sql_acl.cc | 7 +++++- 3 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 mysql-test/r/failed_auth_unixsocket.result create mode 100644 mysql-test/t/failed_auth_unixsocket.test diff --git a/mysql-test/r/failed_auth_unixsocket.result b/mysql-test/r/failed_auth_unixsocket.result new file mode 100644 index 00000000000..7e2499795cb --- /dev/null +++ b/mysql-test/r/failed_auth_unixsocket.result @@ -0,0 +1,12 @@ +update mysql.user set plugin='unix_socket'; +flush privileges; +connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET); +ERROR HY000: Plugin 'unix_socket' is not loaded +ERROR HY000: Plugin 'unix_socket' is not loaded +install plugin unix_socket soname 'auth_socket.so'; +connect(localhost,USER,,test,MASTER_PORT,MASTER_SOCKET); +ERROR 28000: Access denied for user 'USER'@'localhost' (using password: NO) +ERROR 28000: Access denied for user 'USER'@'localhost' (using password: NO) +update mysql.user set plugin=''; +flush privileges; +uninstall plugin unix_socket; diff --git a/mysql-test/t/failed_auth_unixsocket.test b/mysql-test/t/failed_auth_unixsocket.test new file mode 100644 index 00000000000..36649312a00 --- /dev/null +++ b/mysql-test/t/failed_auth_unixsocket.test @@ -0,0 +1,29 @@ +--source include/have_unix_socket.inc + +# +# MDEV-3909 remote user enumeration +# unix_socket tests +# +update mysql.user set plugin='unix_socket'; +flush privileges; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $USER USER +--error ER_PLUGIN_IS_NOT_LOADED +connect (fail,localhost,$USER); + +--error ER_PLUGIN_IS_NOT_LOADED +change_user $USER; + +eval install plugin unix_socket soname '$AUTH_SOCKET_SO'; + +--replace_result $MASTER_MYSOCK MASTER_SOCKET $MASTER_MYPORT MASTER_PORT $USER USER +--error ER_ACCESS_DENIED_ERROR +connect (fail,localhost,$USER); + +--error ER_ACCESS_DENIED_ERROR +change_user $USER; + +update mysql.user set plugin=''; +flush privileges; +uninstall plugin unix_socket; + diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 9983c52abb5..f549d22eb4f 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -8192,7 +8192,12 @@ bool acl_authenticate(THD *thd, uint connect_errors, auth_plugin_name= &mpvio.acl_user->plugin; res= do_auth_once(thd, auth_plugin_name, &mpvio); } - + if (mpvio.make_it_fail) + { + mpvio.status= MPVIO_EXT::FAILURE; + res= CR_ERROR; + } + Security_context *sctx= thd->security_ctx; ACL_USER *acl_user= mpvio.acl_user; From 8428c116c7cc1fb6a04345637a10084810874dd8 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 13 Mar 2014 20:12:50 +0100 Subject: [PATCH 7/8] don't run unix_socket tests when $USER is already present in mysql.user (as it's done in 10.0) --- mysql-test/include/have_unix_socket.inc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/include/have_unix_socket.inc b/mysql-test/include/have_unix_socket.inc index 6e4c3b9826b..4246b138e9d 100644 --- a/mysql-test/include/have_unix_socket.inc +++ b/mysql-test/include/have_unix_socket.inc @@ -8,3 +8,6 @@ if (!$USER) { skip USER variable is undefined; } +if (`SELECT count(*) <> 0 FROM mysql.user WHERE user = '$USER'`) { + skip \$USER=$USER which exists in mysql.user; +} From 5c8ed7dd5473c398f788aba3aff5c168a50df83a Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 14 Mar 2014 11:38:17 +0200 Subject: [PATCH 8/8] MDEV-5446: Assertion `!table || (!table->read_set || bitmap_is_set(table->read_set, field_index))' fails on EXPLAIN EXTENDED with VALUES function field_index should be set correctly for null field created by Item_insert_value::fix_fields(). --- mysql-test/r/func_misc.result | 16 ++++++++++++++++ mysql-test/t/func_misc.test | 15 +++++++++++++++ sql/item.cc | 2 ++ 3 files changed, 33 insertions(+) diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index 56d27ff78be..83513446edf 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -272,3 +272,19 @@ ERROR HY000: Incorrect arguments to NAME_CONST SELECT NAME_CONST('a', -(1)) OR 1; NAME_CONST('a', -(1)) OR 1 1 +# +#MDEV-5446: Assertion `!table || (!table->read_set || +#bitmap_is_set(table->read_set, field_index))' fails on +#EXPLAIN EXTENDED with VALUES function +# +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10); +CREATE VIEW v1 AS SELECT * FROM t1; +EXPLAIN EXTENDED SELECT VALUES(b) FROM v1; +id select_type table type possible_keys key key_len ref rows filtered Extra +1 SIMPLE t1 system NULL NULL NULL NULL 1 100.00 +Warnings: +Note 1003 select values(10) AS `VALUES(b)` from `test`.`t1` +drop view v1; +drop table t1; +End of 5.3 tests diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index c4cc7734186..5cf316587b3 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -310,3 +310,18 @@ SELECT NAME_CONST('a', -(1 OR 2)) OR 1; SELECT NAME_CONST('a', -(1 AND 2)) AND 1; SELECT NAME_CONST('a', -(1)) OR 1; +--echo # +--echo #MDEV-5446: Assertion `!table || (!table->read_set || +--echo #bitmap_is_set(table->read_set, field_index))' fails on +--echo #EXPLAIN EXTENDED with VALUES function +--echo # +CREATE TABLE t1 (a INT, b INT) ENGINE=MyISAM; +INSERT INTO t1 VALUES (1,10); +CREATE VIEW v1 AS SELECT * FROM t1; + +EXPLAIN EXTENDED SELECT VALUES(b) FROM v1; + +drop view v1; +drop table t1; + +--echo End of 5.3 tests diff --git a/sql/item.cc b/sql/item.cc index 6a8573068fc..88489a343fb 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -7897,6 +7897,8 @@ bool Item_insert_value::fix_fields(THD *thd, Item **items) { tmp_field->init(field_arg->field->table); set_field(tmp_field); + // the index is important when read bits set + tmp_field->field_index= field_arg->field->field_index; } } return FALSE;