MySQL 8.3.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, 2023, 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 also distributed 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 included with MySQL.
16
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License, version 2.0, for more details.
21
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25
26#include <functional>
27
28class Item;
29class THD;
30struct TABLE;
31class Table_ref;
32
33struct ORDER;
34template <typename Element_type>
36
38template <class T>
39class List;
40
41template <class T>
42class mem_root_deque;
43
44/**
45 @file sql/sql_resolver.h
46 Name resolution functions.
47*/
48
49void propagate_nullability(mem_root_deque<Table_ref *> *tables, bool nullable);
50
51bool setup_order(THD *thd, Ref_item_array ref_item_array, Table_ref *tables,
52 mem_root_deque<Item *> *fields, ORDER *order);
54 const mem_root_deque<Item *> &values, TABLE *tab);
55
56bool find_order_in_list(THD *thd, Ref_item_array ref_item_array,
57 Table_ref *tables, ORDER *order,
58 mem_root_deque<Item *> *fields, bool is_group_field,
59 bool is_window_order);
60
62 enum {
63 // Immediately return with an error.
65
66 // Replace the given Item with the one in “replacement”;
67 // do not traverse further.
69
70 // Leave this item alone, but keep traversing into its children.
73 Item *replacement; // Only for REPLACE.
74};
75
76/**
77 Walk through the conditions and functions below the given item, and allows the
78 given functor to replace it with new items. See ReplaceResult.
79
80 This function is used both during resolving for making permanent changes to
81 the item tree, and during optimization for making non-permanent changes.
82
83 Note that this must not be used for permanent changes during optimization,
84 as all changes done during optimization will be rolled back if a prepared
85 statement is re-executed.
86
87 Note also that if the replaced items have different data types than the
88 original items, it may be necessary to adjust comparators in Item_bool_func2
89 objects higher up in the tree by calling set_cmp_func() on them. This is not
90 done by this function. Partly because it's generally not used for changing
91 data types, except in some special cases (at the time of writing, only in
92 resolving of ROLLUP columns). But also because of the note above about making
93 permanent changes during optimization; set_cmp_func() may make permanent
94 changes to the item, which are not rolled back at the end of execution, so
95 it's not safe to do this unconditionally under optimization. If adjusting the
96 comparators is necessary, the caller of WalkAndReplace() will have to invoke
97 set_cmp_func() manually.
98
99 @return true on error.
100 */
102 THD *thd, Item *item,
103 const std::function<ReplaceResult(Item *item, Item *parent,
104 unsigned argument_idx)> &get_new_item);
105
106#endif /* SQL_RESOLVER_INCLUDED */
A wrapper class which provides array bounds checking.
Definition: sql_array.h:46
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:933
Definition: sql_list.h:434
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:35
Definition: table.h:2853
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:110
void propagate_nullability(mem_root_deque< Table_ref * > *tables, bool nullable)
Propagate nullability into inner tables of outer join operation.
Definition: sql_resolver.cc:3886
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:4144
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:4367
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:5057
Bounds_checked_array< Item * > Ref_item_array
Definition: sql_resolver.h:35
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:283
Definition: sql_resolver.h:61
Item * replacement
Definition: sql_resolver.h:73
@ ERROR
Definition: sql_resolver.h:64
@ REPLACE
Definition: sql_resolver.h:68
@ KEEP_TRAVERSING
Definition: sql_resolver.h:71
enum ReplaceResult::@182 action
Definition: table.h:1403