Skip to content

Commit 03b579f

Browse files
committed
Bug#28753085: REMOVE SELECT_LEX_UNIT::THD
Remove the public THD member from SELECT_LEX_UNIT. Instead have the SELECT_LEX_UNIT member functions take THD as argument if needed. This refactoring reduces the state of SELECT_LEX_UNIT, makes it easier to later replace THD method-by-method, and makes THD dependencies more explicit. Change-Id: I4ff16c5ad15748805674f8d80ccc221cc3628149
1 parent df93450 commit 03b579f

33 files changed

+461
-496
lines changed

sql/dd/info_schema/table_stats.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -840,7 +840,7 @@ ulonglong Table_statistics::read_stat_by_open_table(
840840
}
841841

842842
end:
843-
lex->unit->cleanup(true);
843+
lex->unit->cleanup(thd, true);
844844

845845
/* Restore original LEX value, statement's arena and THD arena values. */
846846
lex_end(thd->lex);

sql/dd_sql_view.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ class View_metadata_updater_context {
103103
m_thd->set_open_tables_state(&m_open_tables_state_backup);
104104

105105
// Restore lex.
106-
m_thd->lex->unit->cleanup(true);
106+
m_thd->lex->unit->cleanup(m_thd, true);
107107
lex_end(m_thd->lex);
108108
delete static_cast<st_lex_local *>(m_thd->lex);
109109
m_thd->lex = m_saved_lex;
@@ -494,7 +494,7 @@ static bool open_views_and_update_metadata(
494494
order->used_alias = false; /// @see Item::print_for_order()
495495
}
496496
Sql_mode_parse_guard parse_guard(thd);
497-
thd->lex->unit->print(&view_query, QT_TO_ARGUMENT_CHARSET);
497+
thd->lex->unit->print(thd, &view_query, QT_TO_ARGUMENT_CHARSET);
498498
if (lex_string_strmake(thd->mem_root, &view->select_stmt, view_query.ptr(),
499499
view_query.length()))
500500
DBUG_RETURN(true);
@@ -518,15 +518,15 @@ static bool open_views_and_update_metadata(
518518
res = trans_commit_stmt(thd) || trans_commit(thd);
519519
}
520520
if (res) {
521-
view_lex->unit->cleanup(true);
521+
view_lex->unit->cleanup(thd, true);
522522
lex_end(view_lex);
523523
thd->lex = org_lex;
524524
DBUG_RETURN(true);
525525
}
526526
tdc_remove_table(thd, TDC_RT_REMOVE_ALL, view->get_db_name(),
527527
view->get_table_name(), false);
528528

529-
view_lex->unit->cleanup(true);
529+
view_lex->unit->cleanup(thd, true);
530530
lex_end(view_lex);
531531
thd->lex = org_lex;
532532
}

sql/event_data_objects.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,7 @@ bool Event_job_data::execute(THD *thd, bool drop) {
11791179
}
11801180
}
11811181
if (save_sctx) event_sctx.restore_security_context(thd, save_sctx);
1182-
thd->lex->unit->cleanup(true);
1182+
thd->lex->unit->cleanup(thd, true);
11831183
thd->end_statement();
11841184
thd->cleanup_after_query();
11851185
/* Avoid races with SHOW PROCESSLIST */

sql/item_buff.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
1+
/* Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
22
33
This program is free software; you can redistribute it and/or modify
44
it under the terms of the GNU General Public License, version 2.0,
@@ -56,16 +56,16 @@ Cached_item *new_Cached_item(THD *thd, Item *item) {
5656
switch (item->result_type()) {
5757
case STRING_RESULT:
5858
if (item->is_temporal())
59-
return new (*THR_MALLOC) Cached_item_temporal(item);
59+
return new (thd->mem_root) Cached_item_temporal(item);
6060
if (item->data_type() == MYSQL_TYPE_JSON)
61-
return new (*THR_MALLOC) Cached_item_json(item);
62-
return new (*THR_MALLOC) Cached_item_str(thd, item);
61+
return new (thd->mem_root) Cached_item_json(item);
62+
return new (thd->mem_root) Cached_item_str(thd, item);
6363
case INT_RESULT:
64-
return new (*THR_MALLOC) Cached_item_int(item);
64+
return new (thd->mem_root) Cached_item_int(item);
6565
case REAL_RESULT:
66-
return new (*THR_MALLOC) Cached_item_real(item);
66+
return new (thd->mem_root) Cached_item_real(item);
6767
case DECIMAL_RESULT:
68-
return new (*THR_MALLOC) Cached_item_decimal(item);
68+
return new (thd->mem_root) Cached_item_decimal(item);
6969
case ROW_RESULT:
7070
default:
7171
DBUG_ASSERT(0);

sql/item_cmpfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ bool Item_func_not_all::empty_underlying_subquery() {
405405
*/
406406
if (subselect && subselect->substype() != Item_subselect::ANY_SUBS &&
407407
!subselect->unit->item->is_evaluated())
408-
subselect->unit->item->exec();
408+
subselect->unit->item->exec(current_thd);
409409
return ((test_sum_item && !test_sum_item->any_value()) ||
410410
(test_sub_item && !test_sub_item->any_value()));
411411
}

0 commit comments

Comments
 (0)