MySQL  8.0.27
Source Code Documentation
Go to the documentation of this file.
4 /* Copyright (c) 2002, 2021, Oracle and/or its affiliates.
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.
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.
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
20  GNU General Public License, version 2.0, for more details.
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 */
26 #include <sys/types.h>
28 #include "my_compiler.h"
29 #include "my_inttypes.h"
30 #include "my_table_map.h"
31 #include "my_time.h"
33 #include "mysql_time.h"
34 #include "sql/enum_query_type.h"
35 #include "sql/item.h" // Item
36 #include "sql/parse_location.h" // POS
37 #include "sql/sql_const.h" // Item_processor
39 struct Parse_context;
41 class Query_block;
42 class Send_field;
43 class String;
44 class THD;
45 class my_decimal;
46 template <class T>
47 class List;
49 /**
50  Item which stores (x,y,...) and ROW(x,y,...).
51  Note that this can be recursive: ((x,y),(z,t)) is a ROW of ROWs.
52 */
53 class Item_row : public Item {
54  typedef Item super;
59  /**
60  If elements are made only of constants, of which one or more are
61  NULL. For example, this item is (1,2,NULL), or ( (1,NULL), (2,3) ).
62  */
63  bool with_null;
65  public:
66  /**
67  Row items used for comparing rows and IN operations on rows:
69  @param pos current parse context
70  @param head first column in the row
71  @param tail rest of columns in the row
73  @verbatim
74  (a, b, c) > (10, 10, 30)
75  (a, b, c) = (select c, d, e, from t1 where x=12)
76  (a, b, c) IN ((1,2,2), (3,4,5), (6,7,8)
77  (a, b, c) IN (select c, d, e, from t1)
78  @endverbatim
80  @todo
81  think placing 2-3 component items in item (as it done for function
82  */
83  Item_row(const POS &pos, Item *head, const mem_root_deque<Item *> &tail);
84  Item_row(Item *head, const mem_root_deque<Item *> &tail);
86  : Item(),
87  items(item->items),
90  arg_count(item->arg_count),
91  with_null(false) {
92  /*
93  The convention for data_type() of this class is that it starts as
94  MYSQL_TYPE_INVALID and ends as MYSQL_TYPE_NULL when resolving is complete.
95  This is just used as an indicator of resolver progress. A row object does
96  not have a data type by itself.
97  */
99  }
100  bool itemize(Parse_context *pc, Item **res) override;
102  enum Type type() const override { return ROW_ITEM; }
103  void illegal_method_call(const char *) const MY_ATTRIBUTE((cold));
104  bool is_null() override { return null_value; }
105  void make_field(Send_field *) override { illegal_method_call("make_field"); }
106  double val_real() override {
107  illegal_method_call("val_real");
108  return 0;
109  }
110  longlong val_int() override {
111  illegal_method_call("val_int");
112  return 0;
113  }
114  String *val_str(String *) override {
115  illegal_method_call("val_str");
116  return nullptr;
117  }
119  illegal_method_call("val_decimal");
120  return nullptr;
121  }
122  bool get_date(MYSQL_TIME *, my_time_flags_t) override {
123  illegal_method_call("get_date");
124  return true;
125  }
126  bool get_time(MYSQL_TIME *) override {
127  illegal_method_call("get_time");
128  return true;
129  }
131  bool fix_fields(THD *thd, Item **ref) override;
132  void fix_after_pullout(Query_block *parent_query_block,
133  Query_block *removed_query_block) override;
134  bool propagate_type(THD *thd, const Type_properties &type) override;
135  void cleanup() override;
136  void split_sum_func(THD *thd, Ref_item_array ref_item_array,
137  mem_root_deque<Item *> *fields) override;
138  table_map used_tables() const override { return used_tables_cache; }
139  enum Item_result result_type() const override { return ROW_RESULT; }
140  void update_used_tables() override;
141  table_map not_null_tables() const override { return not_null_tables_cache; }
142  void print(const THD *thd, String *str,
143  enum_query_type query_type) const override;
145  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
146  Item *transform(Item_transformer transformer, uchar *arg) override;
148  uint cols() const override { return arg_count; }
149  Item *element_index(uint i) override { return items[i]; }
150  Item **addr(uint i) override { return items + i; }
151  bool check_cols(uint c) override;
152  bool null_inside() override { return with_null; }
153  void bring_value() override;
154  bool check_function_as_value_generator(uchar *) override { return false; }
155 };
157 #endif /* ITEM_ROW_INCLUDED */
Item which stores (x,y,...) and ROW(x,y,...).
Definition: item_row.h:53
void illegal_method_call(const char *) const
void update_used_tables() override
Updates used tables, not null tables information and accumulates properties up the item tree,...
void bring_value() override
Item_row(const POS &pos, Item *head, const mem_root_deque< Item * > &tail)
Row items used for comparing rows and IN operations on rows:
bool is_null() override
The method allows to determine nullness of a complex expression without fully evaluating it,...
Definition: item_row.h:104
bool itemize(Parse_context *pc, Item **res) override
The same as contextualize() but with additional parameter.
enum Type type() const override
Definition: item_row.h:102
String * val_str(String *) override
Definition: item_row.h:114
longlong val_int() override
Definition: item_row.h:110
Item_row(Item_row *item)
Definition: item_row.h:85
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 ...
table_map used_tables_cache
Definition: item_row.h:57
void fix_after_pullout(Query_block *parent_query_block, Query_block *removed_query_block) override
uint cols() const override
Definition: item_row.h:148
void split_sum_func(THD *thd, Ref_item_array ref_item_array, mem_root_deque< Item * > *fields) override
enum Item_result result_type() const override
Definition: item_row.h:139
Item ** items
Definition: item_row.h:56
table_map used_tables() const override
Definition: item_row.h:138
bool get_time(MYSQL_TIME *) override
Definition: item_row.h:126
bool fix_fields(THD *thd, Item **ref) override
double val_real() override
Definition: item_row.h:106
bool walk(Item_processor processor, enum_walk walk, uchar *arg) override
bool propagate_type(THD *thd, const Type_properties &type) override
bool with_null
If elements are made only of constants, of which one or more are NULL.
Definition: item_row.h:63
bool check_cols(uint c) override
Item * element_index(uint i) override
Definition: item_row.h:149
Item ** addr(uint i) override
Definition: item_row.h:150
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:154
void print(const THD *thd, String *str, enum_query_type query_type) const override
This method is used for to:
table_map not_null_tables_cache
Definition: item_row.h:57
my_decimal * val_decimal(my_decimal *) override
Definition: item_row.h:118
void make_field(Send_field *) override
Definition: item_row.h:105
bool get_date(MYSQL_TIME *, my_time_flags_t) override
Definition: item_row.h:122
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:141
void cleanup() override
Called for every Item after use (preparation and execution).
Item super
Definition: item_row.h:54
bool null_inside() override
Definition: item_row.h:152
uint arg_count
Definition: item_row.h:58
Base class that is used to represent any kind of expression in a relational query.
Definition: item.h:802
void set_data_type(enum_field_types data_type)
Set the data type of the current Item.
Definition: item.h:1329
bool null_value
True if item is null.
Definition: item.h:3353
Definition: item.h:838
Definition: item.h:858
Definition: sql_list.h:431
This class represents a query block, aka a query specification, which is a query consisting of a SELE...
Definition: sql_lex.h:1123
Definition: field.h:4583
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_class.h:821
Type properties, used to collect type information for later assignment to an Item object.
Definition: item.h:624
my_decimal class limits 'decimal_t' type to what we need in MySQL.
Definition: my_decimal.h:92
char * pos
Query type constants (usable as bitmap flags).
Definition: enum_query_type.h:30
Definition: field_types.h:78
Item *(Item::* Item_transformer)(uchar *arg)
Type for transformers used by Item::transform and Item::compile.
Definition: item.h:719
Header for compiler-dependent features.
Some integer typedefs for easier portability.
unsigned char uchar
Definition: my_inttypes.h:51
long long int longlong
Definition: my_inttypes.h:54
uint64_t table_map
Definition: my_table_map.h:29
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:82
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)
PT & ref(PT *tp)
File containing constants that can be used throughout the server.
bool(Item::* Item_processor)(uchar *arg)
Processor type for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:452
Enumeration for {Item,Query_block[_UNIT],Table_function}walk.
Definition: sql_const.h:434
Definition: mysql_time.h:81
Environment data for the contextualization phase.
Definition: parse_tree_node_base.h:90
Bison "location" class.
Definition: parse_location.h:42
unsigned int uint
Type of the user defined function return slot and arguments.
Definition: udf_registration_types.h:38
long long
Definition: udf_registration_types.h:43