From 1d4ac3d4d3ec3d52284f7260907111618f6cb6d9 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Wed, 22 May 2019 22:05:56 +0200 Subject: [PATCH] cleanup --- mysql-test/r/derived.result | 1 - mysql-test/r/multi_update.result | 4 ++- mysql-test/r/multi_update_innodb.result | 3 ++ mysql-test/t/derived.test | 3 -- mysql-test/t/multi_update.test | 9 ++---- mysql-test/t/multi_update_innodb.test | 4 +++ sql/sql_base.cc | 8 ++--- sql/sql_base.h | 12 +------- sql/sql_update.cc | 41 ++++++++----------------- 9 files changed, 30 insertions(+), 55 deletions(-) diff --git a/mysql-test/r/derived.result b/mysql-test/r/derived.result index 5debfaed5e30f..2c0d009567837 100644 --- a/mysql-test/r/derived.result +++ b/mysql-test/r/derived.result @@ -1,4 +1,3 @@ -drop table if exists t1,t2,t3; set @save_derived_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; select * from (select 2 from DUAL) b; diff --git a/mysql-test/r/multi_update.result b/mysql-test/r/multi_update.result index e04637a3a5469..e38d8737355a6 100644 --- a/mysql-test/r/multi_update.result +++ b/mysql-test/r/multi_update.result @@ -1038,4 +1038,6 @@ triggered triggered drop table t1,t2, t3; drop user foo; -end of 5.5 tests +# +# end of 5.5 tests +# diff --git a/mysql-test/r/multi_update_innodb.result b/mysql-test/r/multi_update_innodb.result index 643287c3a9304..1d727f00e3e26 100644 --- a/mysql-test/r/multi_update_innodb.result +++ b/mysql-test/r/multi_update_innodb.result @@ -67,3 +67,6 @@ SELECT * FROM t2; col_int_key pk_1 pk_2 col_int 1 2 3 4 DROP TABLE t1,t2; +# +# end of 5.5 tests +# diff --git a/mysql-test/t/derived.test b/mysql-test/t/derived.test index 217203422e0e7..62b2c43ca121f 100644 --- a/mysql-test/t/derived.test +++ b/mysql-test/t/derived.test @@ -1,7 +1,4 @@ # Initialize ---disable_warnings -drop table if exists t1,t2,t3; ---enable_warnings set @save_derived_optimizer_switch=@@optimizer_switch; set optimizer_switch='derived_merge=off,derived_with_keys=off'; diff --git a/mysql-test/t/multi_update.test b/mysql-test/t/multi_update.test index 964108b9b99b5..14c5574f61c0b 100644 --- a/mysql-test/t/multi_update.test +++ b/mysql-test/t/multi_update.test @@ -371,7 +371,6 @@ drop table t1, t2; # connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK); -connection root; --disable_warnings create database mysqltest; --enable_warnings @@ -381,7 +380,6 @@ create table mysqltest.t3 (a int, b int, primary key (a)); grant select on mysqltest.* to mysqltest_1@localhost; grant update on mysqltest.t1 to mysqltest_1@localhost; connect (user1,localhost,mysqltest_1,,mysqltest,$MASTER_MYPORT,$MASTER_MYSOCK); -connection user1; update t1, t2 set t1.b=1 where t1.a=t2.a; update t1, t2 set t1.b=(select t3.b from t3 where t1.a=t3.a) where t1.a=t2.a; connection root; @@ -494,15 +492,12 @@ insert into t2 values (10), (20), (30); create view v1 as select a as b, a/10 as a from t2; connect (locker,localhost,root,,test); -connection locker; lock table t1 write; connect (changer,localhost,root,,test); -connection changer; send alter table t1 add column c int default 100 after a; connect (updater,localhost,root,,test); -connection updater; # Wait till "alter table t1 ..." of session changer is in work. # = There is one session waiting. let $wait_condition= select count(*)= 1 from information_schema.processlist @@ -1086,5 +1081,7 @@ select * from t2; drop table t1,t2, t3; drop user foo; ---echo end of 5.5 tests +--echo # +--echo # end of 5.5 tests +--echo # diff --git a/mysql-test/t/multi_update_innodb.test b/mysql-test/t/multi_update_innodb.test index 51757c29553b3..5807af4f489e8 100644 --- a/mysql-test/t/multi_update_innodb.test +++ b/mysql-test/t/multi_update_innodb.test @@ -75,3 +75,7 @@ UPDATE t2 AS A NATURAL JOIN t2 B SET A.pk_2=10,B.pk_2=11; SELECT * FROM t2; DROP TABLE t1,t2; + +--echo # +--echo # end of 5.5 tests +--echo # diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 4cc7b2fe3b9f4..a98cfbbd5c04e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -5003,8 +5003,7 @@ open_tables_check_upgradable_mdl(THD *thd, TABLE_LIST *tables_start, @retval TRUE Error, reported. */ -bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, - Sroutine_hash_entry **sroutine_to_open_list, uint flags, +bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy) { /* @@ -5053,7 +5052,7 @@ bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, has_prelocking_list= thd->lex->requires_prelocking(); table_to_open= start; - sroutine_to_open= sroutine_to_open_list; + sroutine_to_open= &thd->lex->sroutines_list.first; *counter= 0; thd_proc_info(thd, "Opening tables"); @@ -5112,8 +5111,7 @@ bool open_tables(THD *thd, TABLE_LIST **start, uint *counter, elements in prelocking list/set. */ while (*table_to_open || - (thd->locked_tables_mode <= LTM_LOCK_TABLES && - *sroutine_to_open)) + (thd->locked_tables_mode <= LTM_LOCK_TABLES && *sroutine_to_open)) { /* For every table in the list of tables to open, try to find or open diff --git a/sql/sql_base.h b/sql/sql_base.h index 8a2317d2386ca..ea92e880db716 100644 --- a/sql/sql_base.h +++ b/sql/sql_base.h @@ -276,8 +276,7 @@ int init_ftfuncs(THD *thd, SELECT_LEX* select, bool no_order); bool lock_table_names(THD *thd, TABLE_LIST *table_list, TABLE_LIST *table_list_end, ulong lock_wait_timeout, uint flags); -bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, - Sroutine_hash_entry **sroutine_to_open, uint flags, +bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags, Prelocking_strategy *prelocking_strategy); /* open_and_lock_tables with optional derived handling */ bool open_and_lock_tables(THD *thd, TABLE_LIST *tables, @@ -499,15 +498,6 @@ class Alter_table_prelocking_strategy : public Prelocking_strategy }; -inline bool -open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags, - Prelocking_strategy *prelocking_strategy) -{ - return open_tables(thd, tables, counter, &thd->lex->sroutines_list.first, - flags, prelocking_strategy); -} - - inline bool open_tables(THD *thd, TABLE_LIST **tables, uint *counter, uint flags) { diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 384449115231d..ac0665070426b 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -1251,9 +1251,8 @@ int mysql_multi_update_prepare(THD *thd) if (setup_tables_and_check_access(thd, &lex->select_lex.context, &lex->select_lex.top_join_list, - table_list, - lex->select_lex.leaf_tables, FALSE, - UPDATE_ACL, SELECT_ACL, FALSE)) + table_list, lex->select_lex.leaf_tables, + FALSE, UPDATE_ACL, SELECT_ACL, FALSE)) DBUG_RETURN(TRUE); if (lex->select_lex.handle_derived(thd->lex, DT_MERGE)) @@ -1272,9 +1271,7 @@ int mysql_multi_update_prepare(THD *thd) } if (update_view && check_fields(thd, *fields)) - { DBUG_RETURN(TRUE); - } thd->table_map_for_update= tables_for_update= get_table_map(fields); @@ -1293,8 +1290,7 @@ int mysql_multi_update_prepare(THD *thd) TABLE *table= tl->table; /* Only set timestamp column if this is not modified */ if (table->timestamp_field && - bitmap_is_set(table->write_set, - table->timestamp_field->field_index)) + bitmap_is_set(table->write_set, table->timestamp_field->field_index)) table->timestamp_field_type= TIMESTAMP_NO_AUTO_SET; /* if table will be updated then check that it is unique */ @@ -1355,10 +1351,8 @@ int mysql_multi_update_prepare(THD *thd) if (!tl->is_derived()) { uint want_privilege= tl->updating ? UPDATE_ACL : SELECT_ACL; - if (check_access(thd, want_privilege, tl->db, - &tl->grant.privilege, - &tl->grant.m_internal, - 0, 0) || + if (check_access(thd, want_privilege, tl->db, &tl->grant.privilege, + &tl->grant.m_internal, 0, 0) || check_grant(thd, want_privilege, tl, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); } @@ -1434,25 +1428,18 @@ int mysql_multi_update_prepare(THD *thd) Setup multi-update handling and call SELECT to do the join */ -bool mysql_multi_update(THD *thd, - TABLE_LIST *table_list, - List *fields, - List *values, - COND *conds, - ulonglong options, +bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List *fields, + List *values, COND *conds, ulonglong options, enum enum_duplicates handle_duplicates, - bool ignore, - SELECT_LEX_UNIT *unit, - SELECT_LEX *select_lex, - multi_update **result) + bool ignore, SELECT_LEX_UNIT *unit, + SELECT_LEX *select_lex, multi_update **result) { bool res; DBUG_ENTER("mysql_multi_update"); if (!(*result= new multi_update(table_list, &thd->lex->select_lex.leaf_tables, - fields, values, - handle_duplicates, ignore))) + fields, values, handle_duplicates, ignore))) { DBUG_RETURN(TRUE); } @@ -1463,11 +1450,9 @@ bool mysql_multi_update(THD *thd, List total_list; - res= mysql_select(thd, &select_lex->ref_pointer_array, - table_list, select_lex->with_wild, - total_list, - conds, 0, (ORDER *) NULL, (ORDER *)NULL, (Item *) NULL, - (ORDER *)NULL, + res= mysql_select(thd, &select_lex->ref_pointer_array, table_list, + select_lex->with_wild, total_list, conds, 0, NULL, NULL, + NULL, NULL, options | SELECT_NO_JOIN_CACHE | SELECT_NO_UNLOCK | OPTION_SETUP_TABLES_DONE, *result, unit, select_lex);