MySQL 9.1.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 /// No replacement needed, do not traverse further
73
74 // Leave this item alone, but keep traversing into its children.
77 Item *replacement; // Only for REPLACE.
78};
79
80/**
81 Walk through the conditions and functions below the given item, and allows the
82 given functor to replace it with new items. See ReplaceResult.
83
84 This function is used both during resolving for making permanent changes to
85 the item tree, and during optimization for making non-permanent changes.
86
87 Note that this must not be used for permanent changes during optimization,
88 as all changes done during optimization will be rolled back if a prepared
89 statement is re-executed.
90
91 Note also that if the replaced items have different data types than the
92 original items, it may be necessary to adjust comparators in Item_bool_func2
93 objects higher up in the tree by calling set_cmp_func() on them. This is not
94 done by this function. Partly because it's generally not used for changing
95 data types, except in some special cases (at the time of writing, only in
96 resolving of ROLLUP columns). But also because of the note above about making
97 permanent changes during optimization; set_cmp_func() may make permanent
98 changes to the item, which are not rolled back at the end of execution, so
99 it's not safe to do this unconditionally under optimization. If adjusting the
100 comparators is necessary, the caller of WalkAndReplace() will have to invoke
101 set_cmp_func() manually.
102
103 @return true on error.
104 */
106 THD *thd, Item *item,
107 const std::function<ReplaceResult(Item *item, Item *parent,
108 unsigned argument_idx)> &get_new_item);
109
110#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:930
Definition: sql_list.h:494
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:2900
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:3904
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:4178
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:4421
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:5170
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:289
Definition: sql_resolver.h:62
Item * replacement
Definition: sql_resolver.h:77
enum ReplaceResult::@187 action
@ ERROR
Definition: sql_resolver.h:65
@ REPLACE
Definition: sql_resolver.h:69
@ DONE
No replacement needed, do not traverse further.
Definition: sql_resolver.h:72
@ KEEP_TRAVERSING
Definition: sql_resolver.h:75
Definition: table.h:1421