MySQL 8.4.3
Source Code Documentation
item_row.h
Go to the documentation of this file.
1#ifndef ITEM_ROW_INCLUDED
2#define ITEM_ROW_INCLUDED
3
4/* Copyright (c) 2002, 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 <sys/types.h>
28
29#include "my_compiler.h"
30#include "my_inttypes.h"
31#include "my_table_map.h"
32#include "my_time.h"
34#include "mysql_time.h"
35#include "sql/enum_query_type.h"
36#include "sql/item.h" // Item
37#include "sql/parse_location.h" // POS
38#include "sql/sql_const.h" // Item_processor
39
40struct Parse_context;
41
42class Query_block;
43class Send_field;
44class String;
45class THD;
46class my_decimal;
47template <class T>
48class List;
49
50/**
51 Item which stores (x,y,...) and ROW(x,y,...).
52 Note that this can be recursive: ((x,y),(z,t)) is a ROW of ROWs.
53*/
54class Item_row : public Item {
55 typedef Item super;
56
60 /**
61 If elements are made only of constants, of which one or more are
62 NULL. For example, this item is (1,2,NULL), or ( (1,NULL), (2,3) ).
63 */
65
66 public:
67 /**
68 Row items used for comparing rows and IN operations on rows:
69
70 @param pos current parse context
71 @param head first column in the row
72 @param tail rest of columns in the row
73
74 @verbatim
75 (a, b, c) > (10, 10, 30)
76 (a, b, c) = (select c, d, e, from t1 where x=12)
77 (a, b, c) IN ((1,2,2), (3,4,5), (6,7,8)
78 (a, b, c) IN (select c, d, e, from t1)
79 @endverbatim
80
81 @todo
82 think placing 2-3 component items in item (as it done for function
83 */
84 Item_row(const POS &pos, Item *head, const mem_root_deque<Item *> &tail);
85 Item_row(Item *head, const mem_root_deque<Item *> &tail);
87 : Item(),
88 items(item->items),
91 arg_count(item->arg_count),
92 with_null(false) {
93 /*
94 The convention for data_type() of this class is that it starts as
95 MYSQL_TYPE_INVALID and ends as MYSQL_TYPE_NULL when resolving is complete.
96 This is just used as an indicator of resolver progress. A row object does
97 not have a data type by itself.
98 */
100 }
101 bool do_itemize(Parse_context *pc, Item **res) override;
102
103 enum Type type() const override { return ROW_ITEM; }
104 void illegal_method_call(const char *) const MY_ATTRIBUTE((cold));
105 bool is_null() override { return null_value; }
106 void make_field(Send_field *) override { illegal_method_call("make_field"); }
107 double val_real() override {
108 illegal_method_call("val_real");
109 return 0;
110 }
111 longlong val_int() override {
112 illegal_method_call("val_int");
113 return 0;
114 }
115 String *val_str(String *) override {
116 illegal_method_call("val_str");
117 return nullptr;
118 }
120 illegal_method_call("val_decimal");
121 return nullptr;
122 }
124 illegal_method_call("get_date");
125 return true;
126 }
127 bool get_time(MYSQL_TIME *) override {
128 illegal_method_call("get_time");
129 return true;
130 }
131
132 bool fix_fields(THD *thd, Item **ref) override;
133 void fix_after_pullout(Query_block *parent_query_block,
134 Query_block *removed_query_block) override;
135 bool propagate_type(THD *thd, const Type_properties &type) override;
136 void cleanup() override;
137 bool split_sum_func(THD *thd, Ref_item_array ref_item_array,
138 mem_root_deque<Item *> *fields) override;
139 table_map used_tables() const override { return used_tables_cache; }
140 enum Item_result result_type() const override { return ROW_RESULT; }
141 void update_used_tables() override;
143 void print(const THD *thd, String *str,
144 enum_query_type query_type) const override;
145
146 bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
147 Item *transform(Item_transformer transformer, uchar *arg) override;
148 Item *compile(Item_analyzer analyzer, uchar **arg_p,
149 Item_transformer transformer, uchar *arg_t) override;
150 uint cols() const override { return arg_count; }
151 Item *element_index(uint i) override { return items[i]; }
152 Item **addr(uint i) override { return items + i; }
153 bool check_cols(uint c) override;
154 bool null_inside() override { return with_null; }
155 void bring_value() override;
156 bool check_function_as_value_generator(uchar *) override { return false; }
157};
158
159#endif /* ITEM_ROW_INCLUDED */
Item which stores (x,y,...) and ROW(x,y,...).
Definition: item_row.h:54
void illegal_method_call(const char *) const
Definition: item_row.cc:87
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
Definition: item_row.cc:144
bool do_itemize(Parse_context *pc, Item **res) override
The core function that does the actual itemization.
Definition: item_row.cc:78
void bring_value() override
Definition: item_row.cc:227
Item_row(const POS &pos, Item *head, const mem_root_deque< Item * > &tail)
Row items used for comparing rows and IN operations on rows:
Definition: item_row.cc:40
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_row.h:105
enum Type type() const override
Definition: item_row.h:103
longlong val_int() override
Definition: item_row.h:111
Item_row(Item_row *item)
Definition: item_row.h:86
Item * transform(Item_transformer transformer, uchar *arg) override
Perform a generic transformation of the Item tree, by adding zero or more additional Item objects to ...
Definition: item_row.cc:206
table_map used_tables_cache
Definition: item_row.h:58
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block) override
Fix after tables have been moved from one query_block level to the parent level, e....
Definition: item_row.cc:157
uint cols() const override
Definition: item_row.h:150
enum Item_result result_type() const override
Definition: item_row.h:140
Item ** items
Definition: item_row.h:57
table_map used_tables() const override
Definition: item_row.h:139
bool get_time(MYSQL_TIME *) override
Definition: item_row.h:127
bool fix_fields(THD *thd, Item **ref) override
Definition: item_row.cc:94
bool split_sum_func(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields) override
Definition: item_row.cc:133
double val_real() override
Definition: item_row.h:107
my_decimal * val_decimal(my_decimal *) override
Definition: item_row.h:119
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
Traverses a tree of Items in prefix and/or postfix order.
Definition: item_row.cc:197
bool propagate_type(THD *thd, const Type_properties &type) override
Propagate data type specifications into parameters and user variables.
Definition: item_row.cc:168
bool with_null
If elements are made only of constants, of which one or more are NULL.
Definition: item_row.h:64
bool check_cols(uint c) override
Definition: item_row.cc:179
bool check_function_as_value_generator(uchar *) override
Check if this item is allowed for a virtual column or inside a default expression.
Definition: item_row.h:156
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
Definition: item_row.cc:187
table_map not_null_tables_cache
Definition: item_row.h:58
Item ** addr(uint i) override
Definition: item_row.h:152
void make_field(Send_field *) override
Definition: item_row.h:106
bool get_date(MYSQL_TIME *, my_time_flags_t) override
Definition: item_row.h:123
Item * compile(Item_analyzer analyzer, uchar **arg_p, Item_transformer transformer, uchar *arg_t) override
Perform a generic "compilation" of the Item tree, ie transform the Item tree by adding zero or more I...
Definition: item_row.cc:214
table_map not_null_tables() const override
Return table map of tables that can't be NULL tables (tables that are used in a context where if they...
Definition: item_row.h:142
String * val_str(String *) override
Definition: item_row.h:115
void cleanup() override
Called for every Item after use (preparation and execution).
Definition: item_row.cc:127
Item super
Definition: item_row.h:55
bool null_inside() override
Definition: item_row.h:154
Item * element_index(uint i) override
Definition: item_row.h:151
uint arg_count
Definition: item_row.h:59
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:936
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1501
bool null_value
True if item is null.
Definition: item.h:3667
Type
Definition: item.h:971
@ ROW_ITEM
A row of other items.
Definition: item.h:988
Definition: sql_list.h:467
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1163
Definition: field.h:4652
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Type properties, used to collect type information for later assignment to an Item object.
Definition: item.h:631
A (partial) implementation of std::deque allocating its blocks on a MEM_ROOT.
Definition: mem_root_deque.h:111
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:95
enum_query_type
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:31
@ MYSQL_TYPE_INVALID
Definition: field_types.h:77
bool(Item::* Item_analyzer)(uchar **argp)
Definition: item.h:718
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:727
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:52
long long int longlong
Definition: my_inttypes.h:55
uint64_t table_map
Definition: my_table_map.h:30
Interface for low level time utilities.
unsigned int my_time_flags_t
Flags to str_to_datetime and number_to_datetime.
Definition: my_time.h:94
Time declarations shared between the server and client API: you should not add anything to this heade...
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
PT & ref(PT *tp)
Definition: tablespace_impl.cc:359
File containing constants that can be used throughout the server.
enum_walk
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:287
bool(Item::*)(unsigned char *) Item_processor
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:305
Definition: mysql_time.h:82
Bison "location" class.
Definition: parse_location.h:43
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:420
Item_result
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:39
@ ROW_RESULT
long long
Definition: udf_registration_types.h:44