Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vuvova committed Jun 1, 2019
1 parent 5de08a5 commit 1d4ac3d
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 55 deletions.
1 change: 0 additions & 1 deletion mysql-test/r/derived.result
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/r/multi_update.result
Original file line number Diff line number Diff line change
Expand Up @@ -1038,4 +1038,6 @@ triggered
triggered
drop table t1,t2, t3;
drop user foo;
end of 5.5 tests
#
# end of 5.5 tests
#
3 changes: 3 additions & 0 deletions mysql-test/r/multi_update_innodb.result
Original file line number Diff line number Diff line change
Expand Up @@ -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
#
3 changes: 0 additions & 3 deletions mysql-test/t/derived.test
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
9 changes: 3 additions & 6 deletions mysql-test/t/multi_update.test
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 #

4 changes: 4 additions & 0 deletions mysql-test/t/multi_update_innodb.test
Original file line number Diff line number Diff line change
Expand Up @@ -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 #
8 changes: 3 additions & 5 deletions sql/sql_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
/*
Expand Down Expand Up @@ -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");

Expand Down Expand Up @@ -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
Expand Down
12 changes: 1 addition & 11 deletions sql/sql_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down
41 changes: 13 additions & 28 deletions sql/sql_update.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);

Expand All @@ -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 */
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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<Item> *fields,
List<Item> *values,
COND *conds,
ulonglong options,
bool mysql_multi_update(THD *thd, TABLE_LIST *table_list, List<Item> *fields,
List<Item> *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);
}
Expand All @@ -1463,11 +1450,9 @@ bool mysql_multi_update(THD *thd,

List<Item> 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);
Expand Down

0 comments on commit 1d4ac3d

Please sign in to comment.