MySQL 8.4.2
Source Code Documentation
replace_item.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2024, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef SQL_JOIN_OPTIMIZER_REPLACE_ITEM_H
25#define SQL_JOIN_OPTIMIZER_REPLACE_ITEM_H
26
27class Func_ptr;
28class Item;
29class Item_field;
30template <class T>
31class Mem_root_array;
32class THD;
34
35/*
36 Return a new item that is to be used after materialization (as given by
37 items_to_copy). There are three main cases:
38
39 1. The item isn't touched by materialization (e.g., because it's constant,
40 or because we're not ready to compute it yet).
41 2. The item is directly in the items_to_copy list, so it has its own field
42 in the resulting temporary table; the corresponding new Item_field
43 is returned.
44 3. A _part_ of the item is in the items_to_copy list; e.g. say that we
45 have an item (t1.x + 1), and t1.x is materialized into <temporary>.x.
46 (In particular, this happens when having expressions that contain
47 aggregate functions _and_ non-aggregates.) In this case, we go in and
48 modify the item in-place, so that the appropriate sub-expressions are
49 replaced; in this case, to (<temporary>.x + 1). This assumes that we
50 never use the same item before and after a materialization in the
51 query plan!
52 */
54 THD *thd, Item *item, const Func_ptr_array &items_to_copy,
55 bool need_exact_match);
56
57/**
58 Like FindReplacementOrReplaceMaterializedItems, but only search _below_ the
59 item, ie. ignore point 2 above. This can be useful if doing self-replacement,
60 ie., we are replacing source items in items_to_copy and don't want to
61 replace an item with its own output.
62 */
63void ReplaceMaterializedItems(THD *thd, Item *item,
64 const Func_ptr_array &items_to_copy,
65 bool need_exact_match);
66
67#endif // SQL_JOIN_OPTIMIZER_REPLACE_ITEM_H
Helper class for copy_funcs(); represents an Item to copy from table to next tmp table.
Definition: temp_table_param.h:48
Definition: item.h:4342
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:426
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
void ReplaceMaterializedItems(THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
Like FindReplacementOrReplaceMaterializedItems, but only search below the item, ie.
Definition: replace_item.cc:102
Item * FindReplacementOrReplaceMaterializedItems(THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
Definition: replace_item.cc:82