MySQL 8.4.0
Source Code Documentation
sql_resolver.h
Go to the documentation of this file.
1#ifndef SQL_RESOLVER_INCLUDED
2#define SQL_RESOLVER_INCLUDED
3
4/* Copyright (c) 2000, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27#include <functional>
28
29class Item;
30class THD;
31struct TABLE;
32class Table_ref;
33
34struct ORDER;
35template <typename Element_type>
37
39template <class T>
40class List;
41
42template <class T>
43class mem_root_deque;
44
45/**
46 @file sql/sql_resolver.h
47 Name resolution functions.
48*/
49
50void propagate_nullability(mem_root_deque<Table_ref *> *tables, bool nullable);
51
52bool setup_order(THD *thd, Ref_item_array ref_item_array, Table_ref *tables,
53 mem_root_deque<Item *> *fields, ORDER *order);
55 const mem_root_deque<Item *> &values, TABLE *tab);
56
57bool find_order_in_list(THD *thd, Ref_item_array ref_item_array,
58 Table_ref *tables, ORDER *order,
59 mem_root_deque<Item *> *fields, bool is_group_field,
60 bool is_window_order);
61
63 enum {
64 // Immediately return with an error.
66
67 // Replace the given Item with the one in “replacement”;
68 // do not traverse further.
70
71 // Leave this item alone, but keep traversing into its children.
74 Item *replacement; // Only for REPLACE.
75};
76
77/**
78 Walk through the conditions and functions below the given item, and allows the
79 given functor to replace it with new items. See ReplaceResult.
80
81 This function is used both during resolving for making permanent changes to
82 the item tree, and during optimization for making non-permanent changes.
83
84 Note that this must not be used for permanent changes during optimization,
85 as all changes done during optimization will be rolled back if a prepared
86 statement is re-executed.
87
88 Note also that if the replaced items have different data types than the
89 original items, it may be necessary to adjust comparators in Item_bool_func2
90 objects higher up in the tree by calling set_cmp_func() on them. This is not
91 done by this function. Partly because it's generally not used for changing
92 data types, except in some special cases (at the time of writing, only in
93 resolving of ROLLUP columns). But also because of the note above about making
94 permanent changes during optimization; set_cmp_func() may make permanent
95 changes to the item, which are not rolled back at the end of execution, so
96 it's not safe to do this unconditionally under optimization. If adjusting the
97 comparators is necessary, the caller of WalkAndReplace() will have to invoke
98 set_cmp_func() manually.
99
100 @return true on error.
101 */
103 THD *thd, Item *item,
104 const std::function<ReplaceResult(Item *item, Item *parent,
105 unsigned argument_idx)> &get_new_item);
106
107#endif /* SQL_RESOLVER_INCLUDED */
A wrapper class which provides array bounds checking.
Definition: sql_array.h:47
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:934
Definition: sql_list.h:467
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Definition: table.h:2863
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
void propagate_nullability(mem_root_deque< Table_ref * > *tables, bool nullable)
Propagate nullability into inner tables of outer join operation.
Definition: sql_resolver.cc:3891
bool find_order_in_list(THD *thd, Ref_item_array ref_item_array, Table_ref *tables, ORDER *order, mem_root_deque< Item * > *fields, bool is_group_field, bool is_window_order)
Resolve an ORDER BY or GROUP BY column reference.
Definition: sql_resolver.cc:4149
bool setup_order(THD *thd, Ref_item_array ref_item_array, Table_ref *tables, mem_root_deque< Item * > *fields, ORDER *order)
Resolve and setup list of expressions in ORDER BY clause.
Definition: sql_resolver.cc:4372
bool validate_gc_assignment(const mem_root_deque< Item * > &fields, const mem_root_deque< Item * > &values, TABLE *tab)
validate_gc_assignment Check whether the other values except DEFAULT are assigned for generated colum...
Definition: sql_resolver.cc:5062
Bounds_checked_array< Item * > Ref_item_array
Definition: sql_resolver.h:36
bool WalkAndReplace(THD *thd, Item *item, const std::function< ReplaceResult(Item *item, Item *parent, unsigned argument_idx)> &get_new_item)
Walk through the conditions and functions below the given item, and allows the given functor to repla...
Definition: table.h:285
Definition: sql_resolver.h:62
Item * replacement
Definition: sql_resolver.h:74
enum ReplaceResult::@185 action
@ ERROR
Definition: sql_resolver.h:65
@ REPLACE
Definition: sql_resolver.h:69
@ KEEP_TRAVERSING
Definition: sql_resolver.h:72
Definition: table.h:1405