1 #ifndef ITEM_ROW_INCLUDED 2 #define ITEM_ROW_INCLUDED 3 4 /* Copyright (c) 2002, 2021, 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 Foundation, 24 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA */ 25 26 #include "item.h" // Item 27 28 /** 29 Item which stores (x,y,...) and ROW(x,y,...). 30 Note that this can be recursive: ((x,y),(z,t)) is a ROW of ROWs. 31 */ 32 class Item_row: public Item 33 { 34 typedef Item super; 35 36 Item **items; 37 table_map used_tables_cache, not_null_tables_cache; 38 uint arg_count; 39 bool const_item_cache; 40 /** 41 If elements are made only of constants, of which one or more are 42 NULL. For example, this item is (1,2,NULL), or ( (1,NULL), (2,3) ). 43 */ 44 bool with_null; 45 public: 46 /** 47 Row items used for comparing rows and IN operations on rows: 48 49 @param pos current parse context 50 @param head first column in the row 51 @param tail rest of columns in the row 52 53 @verbatim 54 (a, b, c) > (10, 10, 30) 55 (a, b, c) = (select c, d, e, from t1 where x=12) 56 (a, b, c) IN ((1,2,2), (3,4,5), (6,7,8) 57 (a, b, c) IN (select c, d, e, from t1) 58 @endverbatim 59 60 @todo 61 think placing 2-3 component items in item (as it done for function 62 */ 63 Item_row(const POS &pos, Item *head, List<Item> &tail); 64 Item_row(Item *head, List<Item> &tail); Item_row(Item_row * item)65 Item_row(Item_row *item): 66 Item(), 67 items(item->items), 68 used_tables_cache(item->used_tables_cache), 69 not_null_tables_cache(0), 70 arg_count(item->arg_count), 71 const_item_cache(item->const_item_cache), 72 with_null(0) 73 {} 74 75 virtual bool itemize(Parse_context *pc, Item **res); 76 type()77 enum Type type() const { return ROW_ITEM; }; 78 void illegal_method_call(const char *); is_null()79 bool is_null() { return null_value; } make_field(Send_field *)80 void make_field(Send_field *) 81 { 82 illegal_method_call((const char*)"make_field"); 83 }; val_real()84 double val_real() 85 { 86 illegal_method_call((const char*)"val"); 87 return 0; 88 }; val_int()89 longlong val_int() 90 { 91 illegal_method_call((const char*)"val_int"); 92 return 0; 93 }; val_str(String *)94 String *val_str(String *) 95 { 96 illegal_method_call((const char*)"val_str"); 97 return 0; 98 }; val_decimal(my_decimal *)99 my_decimal *val_decimal(my_decimal *) 100 { 101 illegal_method_call((const char*)"val_decimal"); 102 return 0; 103 }; get_date(MYSQL_TIME * ltime,my_time_flags_t fuzzydate)104 bool get_date(MYSQL_TIME *ltime, my_time_flags_t fuzzydate) 105 { 106 illegal_method_call((const char *) "get_date"); 107 return true; 108 } get_time(MYSQL_TIME * ltime)109 bool get_time(MYSQL_TIME *ltime) 110 { 111 illegal_method_call((const char *) "get_time"); 112 return true; 113 } 114 115 bool fix_fields(THD *thd, Item **ref); 116 void fix_after_pullout(st_select_lex *parent_select, 117 st_select_lex *removed_select); 118 void cleanup(); 119 void split_sum_func(THD *thd, Ref_ptr_array ref_pointer_array, 120 List<Item> &fields); used_tables()121 table_map used_tables() const { return used_tables_cache; }; const_item()122 bool const_item() const { return const_item_cache; }; result_type()123 enum Item_result result_type() const { return ROW_RESULT; } 124 void update_used_tables(); not_null_tables()125 table_map not_null_tables() const { return not_null_tables_cache; } 126 virtual void print(String *str, enum_query_type query_type); 127 128 bool walk(Item_processor processor, enum_walk walk, uchar *arg); 129 Item *transform(Item_transformer transformer, uchar *arg); 130 cols()131 uint cols() { return arg_count; } element_index(uint i)132 Item* element_index(uint i) { return items[i]; } addr(uint i)133 Item** addr(uint i) { return items + i; } 134 bool check_cols(uint c); null_inside()135 bool null_inside() { return with_null; }; 136 void bring_value(); check_gcol_func_processor(uchar * int_arg)137 bool check_gcol_func_processor(uchar *int_arg) {return false; } 138 }; 139 140 #endif /* ITEM_ROW_INCLUDED */ 141