File: item_row.h

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (158 lines) | stat: -rw-r--r-- 5,576 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
#ifndef ITEM_ROW_INCLUDED
#define ITEM_ROW_INCLUDED

/* Copyright (c) 2002, 2025, Oracle and/or its affiliates.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License, version 2.0,
   as published by the Free Software Foundation.

   This program is designed to work with certain software (including
   but not limited to OpenSSL) that is licensed under separate terms,
   as designated in a particular file or component or in included license
   documentation.  The authors of MySQL hereby grant you an additional
   permission to link the program and your derivative works with the
   separately licensed software that they have either included with
   the program or referenced in the documentation.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License, version 2.0, for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA */

#include <sys/types.h>

#include "my_compiler.h"
#include "my_inttypes.h"
#include "my_table_map.h"
#include "my_time.h"
#include "mysql/udf_registration_types.h"
#include "mysql_time.h"
#include "sql/enum_query_type.h"
#include "sql/item.h"            // Item
#include "sql/parse_location.h"  // POS
#include "sql/sql_const.h"       // Item_processor

struct Parse_context;

class Query_block;
class Send_field;
class String;
class THD;
class my_decimal;
template <class T>
class List;

/**
   Item which stores (x,y,...) and ROW(x,y,...).
   Note that this can be recursive: ((x,y),(z,t)) is a ROW of ROWs.
*/
class Item_row : public Item {
  typedef Item super;

  Item **items;
  table_map used_tables_cache, not_null_tables_cache;
  uint arg_count;
  /**
     If elements are made only of constants, of which one or more are
     NULL. For example, this item is (1,2,NULL), or ( (1,NULL), (2,3) ).
  */
  bool with_null;

 public:
  /**
    Row items used for comparing rows and IN operations on rows:

    @param pos    current parse context
    @param head   first column in the row
    @param tail   rest of columns in the row

    @verbatim
    (a, b, c) > (10, 10, 30)
    (a, b, c) = (select c, d, e, from t1 where x=12)
    (a, b, c) IN ((1,2,2), (3,4,5), (6,7,8)
    (a, b, c) IN (select c, d, e, from t1)
    @endverbatim

    @todo
      think placing 2-3 component items in item (as it done for function
  */
  Item_row(const POS &pos, Item *head, const mem_root_deque<Item *> &tail);
  Item_row(Item *head, const mem_root_deque<Item *> &tail);
  Item_row(Item_row *item)
      : Item(),
        items(item->items),
        used_tables_cache(item->used_tables_cache),
        not_null_tables_cache(0),
        arg_count(item->arg_count),
        with_null(false) {
    /*
      The convention for data_type() of this class is that it starts as
      MYSQL_TYPE_INVALID and ends as MYSQL_TYPE_NULL when resolving is complete.
      This is just used as an indicator of resolver progress. A row object does
      not have a data type by itself.
    */
    set_data_type(MYSQL_TYPE_INVALID);
  }
  bool itemize(Parse_context *pc, Item **res) override;

  enum Type type() const override { return ROW_ITEM; }
  void illegal_method_call(const char *) const MY_ATTRIBUTE((cold));
  bool is_null() override { return null_value; }
  void make_field(Send_field *) override { illegal_method_call("make_field"); }
  double val_real() override {
    illegal_method_call("val_real");
    return 0;
  }
  longlong val_int() override {
    illegal_method_call("val_int");
    return 0;
  }
  String *val_str(String *) override {
    illegal_method_call("val_str");
    return nullptr;
  }
  my_decimal *val_decimal(my_decimal *) override {
    illegal_method_call("val_decimal");
    return nullptr;
  }
  bool get_date(MYSQL_TIME *, my_time_flags_t) override {
    illegal_method_call("get_date");
    return true;
  }
  bool get_time(MYSQL_TIME *) override {
    illegal_method_call("get_time");
    return true;
  }

  bool fix_fields(THD *thd, Item **ref) override;
  void fix_after_pullout(Query_block *parent_query_block,
                         Query_block *removed_query_block) override;
  bool propagate_type(THD *thd, const Type_properties &type) override;
  void cleanup() override;
  void split_sum_func(THD *thd, Ref_item_array ref_item_array,
                      mem_root_deque<Item *> *fields) override;
  table_map used_tables() const override { return used_tables_cache; }
  enum Item_result result_type() const override { return ROW_RESULT; }
  void update_used_tables() override;
  table_map not_null_tables() const override { return not_null_tables_cache; }
  void print(const THD *thd, String *str,
             enum_query_type query_type) const override;

  bool walk(Item_processor processor, enum_walk walk, uchar *arg) override;
  Item *transform(Item_transformer transformer, uchar *arg) override;

  uint cols() const override { return arg_count; }
  Item *element_index(uint i) override { return items[i]; }
  Item **addr(uint i) override { return items + i; }
  bool check_cols(uint c) override;
  bool null_inside() override { return with_null; }
  void bring_value() override;
  bool check_function_as_value_generator(uchar *) override { return false; }
};

#endif /* ITEM_ROW_INCLUDED */