MySQL 8.3.0
Source Code Documentation
replace_item.h
Go to the documentation of this file.
1/* Copyright (c) 2021, 2023, 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 also distributed 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 included with MySQL.
13
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License, version 2.0, for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
22
23#ifndef SQL_JOIN_OPTIMIZER_REPLACE_ITEM_H
24#define SQL_JOIN_OPTIMIZER_REPLACE_ITEM_H
25
26class Func_ptr;
27class Item;
28class Item_field;
29template <class T>
30class Mem_root_array;
31class THD;
33
34/*
35 Return a new item that is to be used after materialization (as given by
36 items_to_copy). There are three main cases:
37
38 1. The item isn't touched by materialization (e.g., because it's constant,
39 or because we're not ready to compute it yet).
40 2. The item is directly in the items_to_copy list, so it has its own field
41 in the resulting temporary table; the corresponding new Item_field
42 is returned.
43 3. A _part_ of the item is in the items_to_copy list; e.g. say that we
44 have an item (t1.x + 1), and t1.x is materialized into <temporary>.x.
45 (In particular, this happens when having expressions that contain
46 aggregate functions _and_ non-aggregates.) In this case, we go in and
47 modify the item in-place, so that the appropriate sub-expressions are
48 replaced; in this case, to (<temporary>.x + 1). This assumes that we
49 never use the same item before and after a materialization in the
50 query plan!
51 */
53 THD *thd, Item *item, const Func_ptr_array &items_to_copy,
54 bool need_exact_match);
55
56/**
57 Like FindReplacementOrReplaceMaterializedItems, but only search _below_ the
58 item, ie. ignore point 2 above. This can be useful if doing self-replacement,
59 ie., we are replacing source items in items_to_copy and don't want to
60 replace an item with its own output.
61 */
62void ReplaceMaterializedItems(THD *thd, Item *item,
63 const Func_ptr_array &items_to_copy,
64 bool need_exact_match);
65
66#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:47
Definition: item.h:4340
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:933
A typesafe replacement for DYNAMIC_ARRAY.
Definition: mem_root_array.h:425
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
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:101
Item * FindReplacementOrReplaceMaterializedItems(THD *thd, Item *item, const Func_ptr_array &items_to_copy, bool need_exact_match)
Definition: replace_item.cc:81