24 #include "thr_malloc.h"
26 #include "sql_array.h"
37 char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg)
39 ulonglong tmp= ((ulonglong) char_length_arg) * mbmaxlen_arg;
40 return (tmp > UINT_MAX32) ? (uint32) UINT_MAX32 : (uint32) tmp;
62 #define MY_COLL_ALLOW_SUPERSET_CONV 1
63 #define MY_COLL_ALLOW_COERCIBLE_CONV 2
64 #define MY_COLL_DISALLOW_NONE 4
65 #define MY_COLL_ALLOW_NUMERIC_CONV 8
67 #define MY_COLL_ALLOW_CONV (MY_COLL_ALLOW_SUPERSET_CONV | MY_COLL_ALLOW_COERCIBLE_CONV)
68 #define MY_COLL_CMP_CONV (MY_COLL_ALLOW_CONV | MY_COLL_DISALLOW_NONE)
73 enum Derivation derivation;
78 repertoire= cs->state & MY_CS_PUREASCII ?
79 MY_REPERTOIRE_ASCII : MY_REPERTOIRE_UNICODE30;
83 collation= &my_charset_bin;
84 derivation= DERIVATION_NONE;
85 repertoire= MY_REPERTOIRE_UNICODE30;
89 collation= collation_arg;
90 derivation= derivation_arg;
91 set_repertoire_from_charset(collation_arg);
95 collation= dt.collation;
96 derivation= dt.derivation;
97 repertoire= dt.repertoire;
99 void set(
const CHARSET_INFO *collation_arg, Derivation derivation_arg)
101 collation= collation_arg;
102 derivation= derivation_arg;
103 set_repertoire_from_charset(collation_arg);
106 Derivation derivation_arg,
109 collation= collation_arg;
110 derivation= derivation_arg;
111 repertoire= repertoire_arg;
115 collation= &my_charset_numeric;
116 derivation= DERIVATION_NUMERIC;
117 repertoire= MY_REPERTOIRE_NUMERIC;
121 collation= collation_arg;
122 set_repertoire_from_charset(collation_arg);
124 void set(Derivation derivation_arg)
125 { derivation= derivation_arg; }
126 void set_repertoire(uint repertoire_arg)
127 { repertoire= repertoire_arg; }
131 const char *derivation_name()
const
135 case DERIVATION_NUMERIC:
return "NUMERIC";
136 case DERIVATION_IGNORABLE:
return "IGNORABLE";
137 case DERIVATION_COERCIBLE:
return "COERCIBLE";
138 case DERIVATION_IMPLICIT:
return "IMPLICIT";
139 case DERIVATION_SYSCONST:
return "SYSCONST";
140 case DERIVATION_EXPLICIT:
return "EXPLICIT";
141 case DERIVATION_NONE:
return "NONE";
142 default:
return "UNKNOWN";
161 void set_or_copy(
const char *str,
size_t length,
bool is_null_terminated)
163 if (is_null_terminated)
178 Name_string(
const char *str,
size_t length,
bool is_null_terminated):
181 set_or_copy(str, length, is_null_terminated);
186 set_or_copy(str.str, str.length, is_null_terminated);
195 void copy(
const char *str,
size_t length)
197 copy(str, length, system_charset_info);
199 void copy(
const char *str)
201 copy(str, (str ? strlen(str) : 0), system_charset_info);
205 copy(lex.str, lex.length);
209 copy(lex->str, lex->length);
218 bool eq(
const char *str)
const
220 DBUG_ASSERT(str &&
ptr());
221 return my_strcasecmp(system_charset_info,
ptr(), str) == 0;
223 bool eq_safe(
const char *str)
const
232 return eq(name.
ptr());
241 #define NAME_STRING(x) Name_string(C_STRING_WITH_LEN(x))
254 bool m_is_autogenerated;
278 void copy(
const char *str_arg,
size_t length_arg,
const CHARSET_INFO *cs_arg,
279 bool is_autogenerated_arg);
324 virtual Item_result type()
const {
return REAL_RESULT; }
327 fix_length_and_dec(
Item *item,
Item *arg)
const;
330 virtual void set_zero(
Hybrid_type *val)
const { val->real= 0.0; }
332 { val->real+= f->val_real(); }
333 virtual void div(
Hybrid_type *val, ulonglong u)
const
334 { val->real/= ulonglong2double(u); }
336 virtual longlong val_int(
Hybrid_type *val,
bool unsigned_flag)
const
337 {
return (longlong) rint(val->real); }
338 virtual double val_real(
Hybrid_type *val)
const {
return val->real; }
349 virtual Item_result type()
const {
return DECIMAL_RESULT; }
352 fix_length_and_dec(
Item *arg,
Item *item)
const;
359 virtual longlong val_int(
Hybrid_type *val,
bool unsigned_flag)
const;
362 {
return &val->dec_buf[val->used_dec_buf_no]; }
371 virtual Item_result type()
const {
return INT_RESULT; }
374 fix_length_and_dec(
Item *arg,
Item *item)
const;
380 { val->integer+= f->val_int(); }
381 virtual void div(
Hybrid_type *val, ulonglong u)
const
382 { val->integer/= (longlong) u; }
384 virtual longlong val_int(
Hybrid_type *val,
bool unsigned_flag)
const
385 {
return val->integer; }
387 {
return (
double) val->integer; }
390 int2my_decimal(E_DEC_FATAL_ERROR, val->integer, 0, &val->dec_buf[2]);
391 return &val->dec_buf[2];
394 { buf->set(val->integer, &my_charset_bin);
return buf;}
400 void dummy_error_processor(THD *thd,
void *data);
402 void view_error_processor(THD *thd,
void *data);
455 st_select_lex *select_lex;
462 void (*error_processor)(THD *,
void *);
463 void *error_processor_data;
479 Security_context *security_ctx;
482 :outer_context(0), table_list(0), select_lex(0),
483 error_processor_data(0),
490 error_processor= &dummy_error_processor;
491 first_name_resolution_table= NULL;
492 last_name_resolution_table= NULL;
495 void resolve_in_table_list_only(
TABLE_LIST *tables)
497 table_list= first_name_resolution_table= tables;
501 void process_error(THD *thd)
503 (*error_processor)(thd, error_processor_data);
518 bool save_resolve_in_select_list;
528 save_table_list= context->table_list;
529 save_first_name_resolution_table= context->first_name_resolution_table;
531 save_next_local= table_list->next_local;
532 save_next_name_resolution_table= table_list->next_name_resolution_table;
538 table_list->next_local= save_next_local;
539 table_list->next_name_resolution_table= save_next_name_resolution_table;
540 context->table_list= save_table_list;
541 context->first_name_resolution_table= save_first_name_resolution_table;
547 return save_first_name_resolution_table;
578 typedef enum monotonicity_info
581 MONOTONIC_INCREASING,
582 MONOTONIC_INCREASING_NOT_NULL,
583 MONOTONIC_STRICT_INCREASING,
584 MONOTONIC_STRICT_INCREASING_NOT_NULL
585 } enum_monotonicity_info;
607 virtual void set_required_privilege(
bool rw) {};
625 virtual void set_out_param_info(
Send_field *info) {}
627 virtual const Send_field *get_out_param_info()
const
632 typedef bool (
Item::*Item_processor) (uchar *arg);
644 typedef bool (
Item::*Item_analyzer) (uchar **argp);
645 typedef Item* (
Item::*Item_transformer) (uchar *arg);
646 typedef void (*Cond_traverser) (
const Item *item,
void *arg);
652 void operator=(
Item &);
654 int8 is_expensive_cache;
655 virtual bool is_expensive_processor(uchar *arg) {
return 0; }
658 static void *
operator new(
size_t size)
throw ()
659 {
return sql_alloc(
size); }
660 static void *
operator new(
size_t size,
MEM_ROOT *mem_root)
throw ()
661 {
return alloc_root(mem_root,
size); }
662 static void operator delete(
void *ptr,
size_t size) { TRASH(ptr,
size); }
663 static void operator delete(
void *ptr,
MEM_ROOT *mem_root) {}
665 enum Type {FIELD_ITEM= 0, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM,
666 INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM,
667 COPY_STR_ITEM, FIELD_AVG_ITEM, DEFAULT_VALUE_ITEM,
668 PROC_ITEM,COND_ITEM, REF_ITEM, FIELD_STD_ITEM,
669 FIELD_VARIANCE_ITEM, INSERT_VALUE_ITEM,
670 SUBSELECT_ITEM, ROW_ITEM, CACHE_ITEM, TYPE_HOLDER,
671 PARAM_ITEM, TRIGGER_FIELD_ITEM, DECIMAL_ITEM,
672 XPATH_NODESET, XPATH_NODESET_CMP,
675 enum cond_result { COND_UNDEF,COND_OK,COND_TRUE,COND_FALSE };
677 enum traverse_order { POSTFIX, PREFIX };
721 my_bool unsigned_flag;
722 my_bool with_sum_func;
725 Item_result cmp_context;
727 my_bool with_subselect;
731 my_bool with_stored_program;
764 void rename(
char *new_name);
765 void init_make_field(
Send_field *tmp_field,
enum enum_field_types type);
766 virtual void cleanup();
769 virtual bool fix_fields(THD *,
Item **);
780 st_select_lex *removed_select)
786 inline void quick_fix_field() { fixed= 1; }
788 type_conversion_status save_in_field_no_warnings(
Field *field,
789 bool no_conversions);
798 bool no_conversions);
799 virtual void save_org_in_field(
Field *field)
801 virtual type_conversion_status save_safe_in_field(
Field *field)
804 virtual bool eq(
const Item *,
bool binary_cmp)
const;
805 virtual Item_result result_type()
const {
return REAL_RESULT; }
813 return decimals ? DECIMAL_RESULT : INT_RESULT;
814 if (result_type() == STRING_RESULT)
816 return result_type();
824 return is_temporal_with_date() ?
825 (decimals ? DECIMAL_RESULT : INT_RESULT) : result_type();
827 virtual Item_result cast_to_int_type()
const {
return result_type(); }
828 virtual enum_field_types string_field_type()
const;
829 virtual enum_field_types field_type()
const;
830 virtual enum Type type()
const =0;
837 virtual enum_monotonicity_info get_monotonicity_info()
const
838 {
return NON_MONOTONIC; }
873 virtual longlong val_int_endpoint(
bool left_endp,
bool *incl_endp)
874 { DBUG_ASSERT(0);
return 0; }
888 virtual double val_real()=0;
899 virtual longlong val_int()=0;
914 if (field_type() == MYSQL_TYPE_TIME)
916 DBUG_ASSERT(is_temporal_with_date());
930 inline ulonglong val_uint() {
return (ulonglong) val_int(); }
1079 longlong val_int_from_decimal();
1080 longlong val_int_from_date();
1081 longlong val_int_from_time();
1082 longlong val_int_from_datetime();
1083 double val_real_from_decimal();
1154 type_conversion_status save_time_in_field(
Field *field);
1155 type_conversion_status save_date_in_field(
Field *field);
1156 type_conversion_status save_str_value_in_field(
Field *field,
String *result);
1158 virtual Field *get_tmp_table_field() {
return 0; }
1160 virtual Field *tmp_table_field(
TABLE *t_arg) {
return 0; }
1161 virtual const char *full_name()
const
1163 return item_name.
is_set() ? item_name.
ptr() :
"???";
1172 virtual double val_result() {
return val_real(); }
1173 virtual longlong val_int_result() {
return val_int(); }
1182 virtual String *str_result(
String* tmp) {
return val_str(tmp); }
1184 {
return val_decimal(val); }
1185 virtual bool val_bool_result() {
return val_bool(); }
1186 virtual bool is_null_result() {
return is_null(); }
1189 virtual table_map used_tables()
const {
return (table_map) 0L; }
1203 DBUG_ASSERT(!(used_tables() & OUTER_REF_TABLE_BIT));
1205 return used_tables();
1218 virtual table_map not_null_tables()
const {
return used_tables(); }
1223 virtual bool basic_const_item()
const {
return 0; }
1225 virtual Item *clone_item() {
return 0; }
1226 virtual cond_result eq_cmp_result()
const {
return COND_OK; }
1227 inline uint float_length(uint decimals_par)
const
1228 {
return decimals != NOT_FIXED_DEC ? (DBL_DIG+2+decimals_par) : DBL_DIG+8;}
1229 virtual uint decimal_precision()
const;
1230 inline int decimal_int_part()
const
1231 {
return my_decimal_int_part(decimal_precision(), decimals); }
1246 virtual bool const_item()
const
1248 if (used_tables() == 0)
1256 virtual bool const_during_execution()
const
1257 {
return (used_tables() & ~PARAM_TABLE_BIT) == 0; }
1272 str->append(full_name());
1275 void print_item_w_name(
String *, enum_query_type query_type);
1285 virtual void update_used_tables() {}
1286 virtual void split_sum_func(THD *thd,
Ref_ptr_array ref_pointer_array,
1291 Item **ref,
bool skip_registered);
1292 virtual bool get_date(
MYSQL_TIME *ltime,uint fuzzydate)= 0;
1300 virtual bool get_date_result(
MYSQL_TIME *ltime,uint fuzzydate)
1301 {
return get_date(ltime,fuzzydate); }
1309 virtual bool is_null() {
return 0; }
1314 virtual void update_null_value () { (void) val_int(); }
1326 virtual void top_level_item() {}
1331 virtual void set_result_field(
Field *field) {}
1332 virtual bool is_result_field() {
return 0; }
1333 virtual bool is_bool_func() {
return 0; }
1334 virtual void save_in_result_field(
bool no_conversions) {}
1339 virtual void no_rows_in_result() {}
1340 virtual Item *copy_or_same(THD *thd) {
return this; }
1347 {
return real_items ? real_item() :
this; }
1348 virtual Item *real_item() {
return this; }
1349 virtual Item *get_tmp_table_item(THD *thd) {
return copy_or_same(thd); }
1352 virtual const CHARSET_INFO *compare_collation() {
return NULL; }
1358 virtual const CHARSET_INFO *charset_for_protocol(
void)
const
1360 return result_type() == STRING_RESULT ? collation.collation :
1364 virtual bool walk(Item_processor processor,
bool walk_subquery, uchar *arg)
1366 return (this->*processor)(arg);
1369 virtual Item*
transform(Item_transformer transformer, uchar *arg);
1391 virtual Item* compile(Item_analyzer analyzer, uchar **arg_p,
1392 Item_transformer transformer, uchar *arg_t)
1394 if ((this->*analyzer) (arg_p))
1395 return ((this->*transformer) (arg_t));
1399 virtual void traverse_cond(Cond_traverser traverser,
1400 void *arg, traverse_order order)
1402 (*traverser)(
this, arg);
1412 virtual bool intro_version(uchar *int_arg) {
return 0; }
1414 virtual bool remove_dependence_processor(uchar * arg) {
return 0; }
1415 virtual bool remove_fixed(uchar * arg) { fixed= 0;
return 0; }
1417 virtual bool collect_item_field_processor(uchar * arg) {
return 0; }
1418 virtual bool add_field_to_set_processor(uchar * arg) {
return 0; }
1428 virtual bool find_item_in_field_list_processor(uchar *arg) {
return 0; }
1429 virtual bool change_context_processor(uchar *context) {
return 0; }
1430 virtual bool reset_query_id_processor(uchar *query_id_arg) {
return 0; }
1431 virtual bool find_item_processor(uchar *arg) {
return this == (
void *) arg; }
1432 virtual bool register_field_in_read_map(uchar *arg) {
return 0; }
1433 virtual bool inform_item_in_cond_of_tab(uchar *join_tab_index) {
return false; }
1466 virtual bool equality_substitution_analyzer(uchar **arg) {
return false; }
1468 virtual Item* equality_substitution_transformer(uchar *arg) {
return this; }
1521 virtual bool check_partition_func_processor(uchar *bool_arg) {
return TRUE;}
1522 virtual bool subst_argument_checker(uchar **arg)
1528 virtual bool explain_subquery_checker(uchar **arg) {
return true; }
1529 virtual Item *explain_subquery_propagator(uchar *arg) {
return this; }
1531 virtual Item *equal_fields_propagator(uchar * arg) {
return this; }
1532 virtual bool set_no_const_sub(uchar *arg) {
return FALSE; }
1533 virtual Item *replace_equal_field(uchar * arg) {
return this; }
1539 virtual bool check_valid_arguments_processor(uchar *bool_arg)
1565 virtual Item *this_item() {
return this; }
1566 virtual const Item *this_item()
const {
return this; }
1572 virtual Item **this_item_addr(THD *thd,
Item **addr_arg) {
return addr_arg; }
1575 virtual uint cols() {
return 1; }
1576 virtual Item* element_index(uint
i) {
return this; }
1577 virtual Item** addr(uint
i) {
return 0; }
1578 virtual bool check_cols(uint c);
1580 virtual bool null_inside() {
return 0; }
1582 virtual void bring_value() {}
1585 virtual Item_field *field_for_view_update() {
return 0; }
1587 virtual Item *neg_transformer(THD *thd) {
return NULL; }
1588 virtual Item *update_value_transformer(uchar *select_arg) {
return this; }
1596 virtual bool is_splocal() {
return 0; }
1606 inline bool is_temporal_with_date()
const
1608 return is_temporal_type_with_date(field_type());
1610 inline bool is_temporal_with_date_and_time()
const
1612 return is_temporal_type_with_date_and_time(field_type());
1614 inline bool is_temporal_with_time()
const
1616 return is_temporal_type_with_time(field_type());
1618 inline bool is_temporal()
const
1620 return is_temporal_type(field_type());
1634 if (cmp_context == (Item_result)-1 || item->cmp_context == cmp_context)
1637 if (is_temporal_with_date())
1638 return item->is_temporal_with_date() ||
1639 item->cmp_context == STRING_RESULT;
1640 if (item->is_temporal_with_date())
1641 return is_temporal_with_date() || cmp_context == STRING_RESULT;
1644 virtual Field::geometry_type get_geometry_type()
const
1645 {
return Field::GEOM_GEOMETRY; };
1646 String *check_well_formed_result(
String *str,
bool send_error= 0);
1660 virtual bool is_expensive()
1662 if (is_expensive_cache < 0)
1663 is_expensive_cache= walk(&Item::is_expensive_processor, 0, (uchar*)0);
1664 return test(is_expensive_cache);
1667 uint32 max_char_length()
const
1668 {
return max_length / collation.collation->mbmaxlen; }
1669 void fix_length_and_charset(uint32 max_char_length_arg,
1672 max_length= char_to_byte_length_safe(max_char_length_arg, cs->mbmaxlen);
1673 collation.collation= cs;
1675 void fix_char_length(uint32 max_char_length_arg)
1677 max_length= char_to_byte_length_safe(max_char_length_arg,
1678 collation.collation->mbmaxlen);
1680 void fix_char_length_ulonglong(ulonglong max_char_length_arg)
1682 ulonglong max_result_length= max_char_length_arg *
1683 collation.collation->mbmaxlen;
1684 if (max_result_length >= MAX_BLOB_WIDTH)
1686 max_length= MAX_BLOB_WIDTH;
1690 max_length= (uint32) max_result_length;
1692 void fix_length_and_charset_datetime(uint32 max_char_length_arg)
1694 collation.set(&my_charset_numeric, DERIVATION_NUMERIC, MY_REPERTOIRE_ASCII);
1695 fix_char_length(max_char_length_arg);
1697 void fix_length_and_dec_and_charset_datetime(uint32 max_char_length_arg,
1701 fix_length_and_charset_datetime(max_char_length_arg +
1702 (dec_arg ? dec_arg + 1 : 0));
1707 virtual bool is_outer_field()
const { DBUG_ASSERT(fixed);
return FALSE; }
1726 virtual bool has_stored_program()
const {
return with_stored_program; }
1737 table_map used_table_map;
1740 void set_used_tables(table_map map) { used_table_map= map; }
1741 table_map used_tables()
const {
return used_table_map; }
1751 item_name= orig_name;
1788 bool fix_fields(THD *thd,
Item **);
1794 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
1801 bool no_conversions);
1809 inline void Item_sp_variable::make_field(
Send_field *field)
1811 Item *it= this_item();
1812 it->item_name.
copy(item_name.
is_set() ? item_name : m_name);
1813 it->make_field(field);
1816 inline type_conversion_status
1824 return this_item()->
send(protocol, str);
1839 Item_result m_result_type;
1840 enum_field_types m_field_type;
1848 bool limit_clause_param;
1870 enum_field_types sp_var_type,
1871 uint pos_in_q= 0, uint len_in_q= 0);
1873 bool is_splocal() {
return 1; }
1876 const Item *this_item()
const;
1877 Item **this_item_addr(THD *thd,
Item **);
1879 virtual void print(
String *str, enum_query_type query_type);
1882 inline uint get_var_idx()
const;
1884 inline enum Type type()
const;
1885 inline Item_result result_type()
const;
1886 inline enum_field_types field_type()
const {
return m_field_type; }
1902 inline uint Item_splocal::get_var_idx()
const
1907 inline enum Item::Type Item_splocal::type()
const
1912 inline Item_result Item_splocal::result_type()
const
1914 return m_result_type;
1929 const Item *this_item()
const;
1930 Item **this_item_addr(THD *thd,
Item **);
1932 inline enum Type type()
const;
1933 inline Item_result result_type()
const;
1941 virtual void print(
String *str, enum_query_type query_type);
1944 uint m_case_expr_id;
1951 inline enum Item::Type Item_case_expr::type()
const
1953 return this_item()->type();
1956 inline Item_result Item_case_expr::result_type()
const
1958 return this_item()->result_type();
1984 bool fix_fields(THD *,
Item **);
1986 enum Type type()
const;
1991 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
1994 virtual void print(
String *str, enum_query_type query_type);
1996 Item_result result_type()
const
1998 return value_item->result_type();
2008 return value_item->
send(protocol, str);
2014 bool agg_item_collations_for_comparison(
DTCollation &c,
const char *
name,
2016 bool agg_item_set_converter(
DTCollation &coll,
const char *fname,
2017 Item **args, uint nargs, uint
flags,
int item_sep);
2025 uint
flags= MY_COLL_ALLOW_SUPERSET_CONV |
2026 MY_COLL_ALLOW_COERCIBLE_CONV |
2027 MY_COLL_ALLOW_NUMERIC_CONV;
2028 return agg_item_charsets(c, name, items, nitems, flags, item_sep);
2035 uint
flags= MY_COLL_ALLOW_SUPERSET_CONV |
2036 MY_COLL_ALLOW_COERCIBLE_CONV |
2037 MY_COLL_DISALLOW_NONE;
2038 return agg_item_charsets(c, name, items, nitems, flags, item_sep);
2041 agg_item_charsets_for_string_result_with_comparison(
DTCollation &c,
2046 uint
flags= MY_COLL_ALLOW_SUPERSET_CONV |
2047 MY_COLL_ALLOW_COERCIBLE_CONV |
2048 MY_COLL_ALLOW_NUMERIC_CONV |
2049 MY_COLL_DISALLOW_NONE;
2050 return agg_item_charsets(c, name, items, nitems, flags, item_sep);
2057 Item_num() { collation.set_numeric(); }
2060 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
2063 #define NO_CACHED_FIELD_INDEX ((uint)(-1))
2065 class st_select_lex;
2075 const char *orig_db_name;
2076 const char *orig_table_name;
2077 const char *orig_field_name;
2081 const char *db_name;
2082 const char *table_name;
2083 const char *field_name;
2084 bool alias_name_used;
2090 uint cached_field_index;
2097 st_select_lex *depended_from;
2099 const char *db_name_arg,
const char *table_name_arg,
2100 const char *field_name_arg);
2102 const char *full_name()
const;
2104 st_select_lex *removed_select);
2106 bool remove_dependence_processor(uchar * arg);
2107 virtual void print(
String *str, enum_query_type query_type);
2108 virtual bool change_context_processor(uchar *cntx)
2111 const char *db_name,
2113 bool any_privileges);
2121 const char *db_name;
2122 const char *table_name;
2125 const char *table_name_arg)
2126 :field(par_field), db_name(db_arg), table_name(table_name_arg)
2129 enum Type type()
const {
return FIELD_ITEM; }
2130 double val_real() {
return field->val_real(); }
2131 longlong val_int() {
return field->val_int(); }
2132 String *val_str(
String *str) {
return field->val_str(str); }
2134 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2136 return field->get_date(ltime, fuzzydate);
2140 return field->get_time(ltime);
2144 {
return (
CHARSET_INFO *)field->charset_for_protocol(); }
2154 void set_field(
Field *field);
2156 Field *field,*result_field;
2158 bool no_const_subst;
2163 uint have_privileges;
2165 bool any_privileges;
2167 const char *db_arg,
const char *table_name_arg,
2168 const char *field_name_arg);
2185 enum Type type()
const {
return FIELD_ITEM; }
2186 bool eq(
const Item *item,
bool binary_cmp)
const;
2193 double val_result();
2194 longlong val_int_result();
2199 bool val_bool_result();
2200 bool is_null_result();
2207 table_map used_tables()
const;
2209 enum Item_result result_type ()
const
2211 return field->result_type();
2217 Item_result cast_to_int_type()
const
2219 return field->cast_to_int_type();
2221 enum_field_types field_type()
const
2223 return field->type();
2225 enum_monotonicity_info get_monotonicity_info()
const
2227 return MONOTONIC_STRICT_INCREASING;
2229 longlong val_int_endpoint(
bool left_endp,
bool *incl_endp);
2230 Field *get_tmp_table_field() {
return result_field; }
2231 Field *tmp_table_field(
TABLE *t_arg) {
return result_field; }
2232 bool get_date(
MYSQL_TIME *ltime,uint fuzzydate);
2233 bool get_date_result(
MYSQL_TIME *ltime,uint fuzzydate);
2236 bool is_null() {
return field->is_null(); }
2237 void update_null_value();
2238 Item *get_tmp_table_item(THD *thd);
2240 bool add_field_to_set_processor(uchar * arg);
2243 bool register_field_in_read_map(uchar *arg);
2244 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
2251 inline uint32 max_disp_length() {
return field->max_display_length(); }
2252 Item_field *field_for_view_update() {
return this; }
2255 virtual Item *update_value_transformer(uchar *select_arg);
2258 virtual void print(
String *str, enum_query_type query_type);
2259 bool is_outer_field()
const
2262 return field->table->pos_in_table_list->outer_join ||
2265 Field::geometry_type get_geometry_type()
const
2267 DBUG_ASSERT(field_type() == MYSQL_TYPE_GEOMETRY);
2268 return field->get_geometry_type();
2271 {
return field->charset_for_protocol(); }
2276 fprintf(DBUG_FILE,
"<field ");
2279 fprintf(DBUG_FILE,
"'%s.%s': ", field->table->alias, field->field_name);
2280 field->dbug_print();
2283 fprintf(DBUG_FILE,
"NULL");
2285 fprintf(DBUG_FILE,
", result_field: ");
2288 fprintf(DBUG_FILE,
"'%s.%s': ",
2289 result_field->table->alias, result_field->field_name);
2290 result_field->dbug_print();
2293 fprintf(DBUG_FILE,
"NULL");
2294 fprintf(DBUG_FILE,
">\n");
2303 friend class st_select_lex_unit;
2310 maybe_null= null_value= TRUE;
2313 collation.set(&my_charset_bin, DERIVATION_IGNORABLE);
2319 item_name= NAME_STRING(
"NULL");
2324 item_name= name_par;
2326 enum Type type()
const {
return NULL_ITEM; }
2327 bool eq(
const Item *item,
bool binary_cmp)
const;
2334 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2345 enum Item_result result_type ()
const {
return STRING_RESULT; }
2346 enum_field_types field_type()
const {
return MYSQL_TYPE_NULL; }
2347 bool basic_const_item()
const {
return 1; }
2349 bool is_null() {
return 1; }
2353 str->append(STRING_WITH_LEN(
"NULL"));
2357 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
2372 enum_field_types fld_type;
2374 Item_result res_type;
2377 Field *result_field;
2379 :
Item_null(), fld_type(fld_type), res_type(res_type), result_field(0) {}
2380 bool is_result_field() {
return result_field != 0; }
2381 void save_in_result_field(
bool no_conversions)
2385 bool check_partition_func_processor(uchar *int_arg) {
return TRUE;}
2386 enum_field_types field_type()
const {
return fld_type; }
2387 Item_result result_type()
const {
return res_type; }
2395 char cnvbuf[MAX_FIELD_WIDTH];
2400 enum enum_item_param_state
2402 NO_VALUE, NULL_VALUE, INT_VALUE, REAL_VALUE,
2403 STRING_VALUE, TIME_VALUE, LONG_DATA_VALUE,
2429 struct CONVERSION_INFO
2445 enum Item_result item_result_type;
2446 enum Type item_type;
2456 enum enum_field_types param_type;
2465 enum Item_result result_type ()
const {
return item_result_type; }
2466 enum Type type()
const {
return item_type; }
2467 enum_field_types field_type()
const {
return param_type; }
2474 bool get_date(
MYSQL_TIME *tm, uint fuzzydate);
2475 type_conversion_status save_in_field(
Field *field,
bool no_conversions);
2478 void set_int(longlong
i, uint32 max_length_arg);
2479 void set_double(
double i);
2482 bool set_str(
const char *str, ulong length);
2483 bool set_longdata(
const char *str, ulong length);
2493 void (*set_param_func)(
Item_param *param, uchar **pos, ulong len);
2504 virtual table_map used_tables()
const
2505 {
return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; }
2506 virtual void print(
String *str, enum_query_type query_type);
2508 { DBUG_ASSERT(state != NO_VALUE);
return state == NULL_VALUE; }
2509 bool basic_const_item()
const;
2527 bool eq(
const Item *item,
bool binary_cmp)
const;
2534 get_settable_routine_parameter()
2541 virtual void set_out_param_info(
Send_field *info);
2557 Item_int(int32
i,uint length= MY_INT32_NUM_DECIMAL_DIGITS)
2558 :value((longlong) i)
2559 { max_length=length; fixed= 1; }
2560 Item_int(longlong i,uint length= MY_INT64_NUM_DECIMAL_DIGITS)
2562 { max_length=length; fixed= 1; }
2563 Item_int(ulonglong i, uint length= MY_INT64_NUM_DECIMAL_DIGITS)
2565 { max_length=length; fixed= 1; unsigned_flag= 1; }
2568 value= item_arg->value;
2569 item_name= item_arg->item_name;
2570 max_length= item_arg->max_length;
2576 item_name= name_arg;
2579 Item_int(
const char *str_arg, uint length);
2580 enum Type type()
const {
return INT_ITEM; }
2581 enum Item_result result_type ()
const {
return INT_RESULT; }
2582 enum_field_types field_type()
const {
return MYSQL_TYPE_LONGLONG; }
2583 longlong val_int() { DBUG_ASSERT(fixed == 1);
return value; }
2584 double val_real() { DBUG_ASSERT(fixed == 1);
return (
double) value; }
2587 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2596 bool basic_const_item()
const {
return 1; }
2598 virtual void print(
String *str, enum_query_type query_type);
2599 Item_num *neg() { value= -value;
return this; }
2600 uint decimal_precision()
const
2601 {
return (uint)(max_length -
test(value < 0)); }
2602 bool eq(
const Item *,
bool binary_cmp)
const;
2603 bool check_partition_func_processor(uchar *bool_arg) {
return FALSE;}
2631 enum_field_types cached_field_type;
2634 cached_field_type(field_type_arg)
2636 DBUG_ASSERT(is_temporal_type(field_type_arg));
2639 longlong i, uint length):
Item_int(i),
2640 cached_field_type(field_type_arg)
2642 DBUG_ASSERT(is_temporal_type(field_type_arg));
2644 item_name= name_arg;
2651 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2661 enum_field_types field_type()
const
2663 return cached_field_type;
2671 Item_uint(
const char *str_arg, uint length)
2672 :
Item_int(str_arg, length) { unsigned_flag= 1; }
2675 :
Item_int(name_arg, i, length) { unsigned_flag= 1; }
2677 { DBUG_ASSERT(fixed == 1);
return ulonglong2double((ulonglong)value); }
2680 Item *clone_item() {
return new Item_uint(item_name, value, max_length); }
2682 virtual void print(
String *str, enum_query_type query_type);
2684 uint decimal_precision()
const {
return max_length; }
2685 bool check_partition_func_processor(uchar *bool_arg) {
return FALSE;}
2697 const my_decimal *val_arg, uint decimal_par, uint length);
2701 Item_decimal(
const uchar *bin,
int precision,
int scale);
2703 enum Type type()
const {
return DECIMAL_ITEM; }
2704 enum Item_result result_type ()
const {
return DECIMAL_RESULT; }
2705 enum_field_types field_type()
const {
return MYSQL_TYPE_NEWDECIMAL; }
2710 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2719 bool basic_const_item()
const {
return 1; }
2722 return new Item_decimal(item_name, &decimal_value, decimals, max_length);
2724 virtual void print(
String *str, enum_query_type query_type);
2727 my_decimal_neg(&decimal_value);
2728 unsigned_flag= !decimal_value.sign();
2731 uint decimal_precision()
const {
return decimal_value.precision(); }
2732 bool eq(
const Item *,
bool binary_cmp)
const;
2733 void set_decimal_value(
my_decimal *value_par);
2734 bool check_partition_func_processor(uchar *bool_arg) {
return FALSE;}
2744 Item_float(
const char *str_arg, uint length);
2746 double val_arg, uint decimal_par, uint length)
2749 presentation= name_arg;
2750 item_name= name_arg;
2751 decimals= (uint8) decimal_par;
2755 Item_float(
double value_par, uint decimal_par) :value(value_par)
2757 decimals= (uint8) decimal_par;
2761 enum Type type()
const {
return REAL_ITEM; }
2762 enum_field_types field_type()
const {
return MYSQL_TYPE_DOUBLE; }
2763 double val_real() { DBUG_ASSERT(fixed == 1);
return value; }
2766 DBUG_ASSERT(fixed == 1);
2767 if (value <= (
double) LONGLONG_MIN)
2769 return LONGLONG_MIN;
2771 else if (value >= (
double) (ulonglong) LONGLONG_MAX)
2773 return LONGLONG_MAX;
2775 return (longlong) rint(value);
2779 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2787 bool basic_const_item()
const {
return 1; }
2789 {
return new Item_float(item_name, value, decimals, max_length); }
2790 Item_num *neg() { value= -value;
return this; }
2791 virtual void print(
String *str, enum_query_type query_type);
2792 bool eq(
const Item *,
bool binary_cmp)
const;
2801 double val_arg, uint decimal_par, uint length)
2803 val_arg, decimal_par, length), func_name(name_arg)
2808 str->append(func_name);
2820 const CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
2821 uint repertoire= MY_REPERTOIRE_UNICODE30)
2822 : m_cs_specified(FALSE)
2824 str_value.set_or_copy_aligned(str, length, cs);
2825 collation.set(cs, dv, repertoire);
2833 max_length= str_value.numchars()*cs->mbmaxlen;
2834 item_name.
copy(str, length, cs);
2835 decimals=NOT_FIXED_DEC;
2841 : m_cs_specified(FALSE)
2843 collation.set(cs, dv);
2845 decimals= NOT_FIXED_DEC;
2850 const CHARSET_INFO *cs, Derivation dv= DERIVATION_COERCIBLE,
2851 uint repertoire= MY_REPERTOIRE_UNICODE30)
2852 : m_cs_specified(FALSE)
2854 str_value.set_or_copy_aligned(str, length, cs);
2855 collation.set(cs, dv, repertoire);
2856 max_length= str_value.numchars()*cs->mbmaxlen;
2857 item_name= name_par;
2858 decimals=NOT_FIXED_DEC;
2866 void set_str_with_copy(
const char *str_arg, uint length_arg)
2868 str_value.copy(str_arg, length_arg, collation.collation);
2869 max_length= str_value.numchars() * collation.collation->mbmaxlen;
2871 void set_repertoire_from_value()
2873 collation.repertoire= my_string_repertoire(str_value.charset(),
2875 str_value.length());
2877 enum Type type()
const {
return STRING_ITEM; }
2882 DBUG_ASSERT(fixed == 1);
2883 return (
String*) &str_value;
2886 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
2895 enum Item_result result_type ()
const {
return STRING_RESULT; }
2896 enum_field_types field_type()
const {
return MYSQL_TYPE_VARCHAR; }
2897 bool basic_const_item()
const {
return 1; }
2898 bool eq(
const Item *item,
bool binary_cmp)
const;
2901 return new Item_string(static_cast<Name_string>(item_name), str_value.ptr(),
2902 str_value.length(), collation.collation);
2906 inline void append(
char *str, uint length)
2908 str_value.append(str, length);
2909 max_length= str_value.numchars() * collation.collation->mbmaxlen;
2911 virtual void print(
String *str, enum_query_type query_type);
2912 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
2935 return m_cs_specified;
2950 m_cs_specified= cs_specified;
2954 bool m_cs_specified;
2959 longlong_from_string_with_check (
const CHARSET_INFO *cs,
2960 const char *cptr,
char *end);
2963 const char *cptr,
char *end);
2971 Derivation dv= DERIVATION_COERCIBLE)
2972 :
Item_string(null_name_string, str, length, cs, dv), func_name(name_par)
2978 str->append(func_name);
2981 bool check_partition_func_processor(uchar *int_arg) {
return TRUE;}
3003 length, &my_charset_bin)
3005 enum Type type()
const {
return TYPE_HOLDER; }
3006 enum_field_types field_type()
const {
return MYSQL_TYPE_BLOB; }
3022 0, cs ? cs : &my_charset_utf8_general_ci)
3024 max_length= length * collation.collation->mbmaxlen;
3032 enum_field_types int_field_type;
3035 enum_field_types field_type_arg, longlong value= 0)
3037 value, length), int_field_type(field_type_arg)
3041 enum_field_types field_type()
const {
return int_field_type; }
3050 enum Type type()
const {
return VARBIN_ITEM; }
3053 DBUG_ASSERT(fixed == 1);
3054 return (
double) (ulonglong) Item_hex_string::val_int();
3057 bool basic_const_item()
const {
return 1; }
3058 String *val_str(
String*) { DBUG_ASSERT(fixed == 1);
return &str_value; }
3060 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
3069 enum Item_result result_type ()
const {
return STRING_RESULT; }
3070 enum Item_result cast_to_int_type()
const {
return INT_RESULT; }
3071 enum_field_types field_type()
const {
return MYSQL_TYPE_VARCHAR; }
3072 virtual void print(
String *str, enum_query_type query_type);
3073 bool eq(
const Item *item,
bool binary_cmp)
const;
3075 bool check_partition_func_processor(uchar *int_arg) {
return FALSE;}
3077 void hex_string_init(
const char *str, uint str_length);
3090 Field *result_field;
3094 Item(thd, item), result_field(item->result_field)
3097 Field *get_tmp_table_field() {
return result_field; }
3098 Field *tmp_table_field(
TABLE *t_arg) {
return result_field; }
3099 table_map used_tables()
const {
return 1; }
3100 virtual void fix_length_and_dec()=0;
3101 void set_result_field(
Field *field) { result_field= field; }
3102 bool is_result_field() {
return 1; }
3103 void save_in_result_field(
bool no_conversions)
3124 virtual const char *func_name()
const= 0;
3131 void set_properties();
3133 enum Ref_Type { REF, DIRECT_REF, VIEW_REF, OUTER_REF, AGGREGATE_REF };
3134 Field *result_field;
3137 const char *db_arg,
const char *table_name_arg,
3138 const char *field_name_arg)
3139 :
Item_ident(context_arg, db_arg, table_name_arg, field_name_arg),
3140 result_field(0), ref(0) {}
3156 const char *table_name_arg,
const char *field_name_arg,
3157 bool alias_name_used_arg= FALSE);
3161 :
Item_ident(thd, item), result_field(item->result_field), ref(item->ref) {}
3162 enum Type type()
const {
return REF_ITEM; }
3163 bool eq(
const Item *item,
bool binary_cmp)
const
3165 Item *it= ((
Item *) item)->real_item();
3166 return ref && (*ref)->
eq(it, binary_cmp);
3176 bool get_date(
MYSQL_TIME *ltime,uint fuzzydate);
3177 double val_result();
3178 longlong val_int_result();
3181 bool val_bool_result();
3182 bool is_null_result();
3187 st_select_lex *removed_select);
3189 void save_org_in_field(
Field *field);
3190 enum Item_result result_type ()
const {
return (*ref)->result_type(); }
3191 enum_field_types field_type()
const {
return (*ref)->field_type(); }
3192 Field *get_tmp_table_field()
3193 {
return result_field ? result_field : (*ref)->get_tmp_table_field(); }
3194 Item *get_tmp_table_item(THD *thd);
3195 bool const_item()
const
3197 return (*ref)->const_item() && (used_tables() == 0);
3199 table_map used_tables()
const
3201 return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->used_tables();
3203 void update_used_tables()
3206 (*ref)->update_used_tables();
3210 {
return (*ref)->resolved_used_tables(); }
3212 table_map not_null_tables()
const
3220 return depended_from ? OUTER_REF_TABLE_BIT : (*ref)->not_null_tables();
3222 void set_result_field(
Field *field) { result_field= field; }
3223 bool is_result_field() {
return 1; }
3224 void save_in_result_field(
bool no_conversions)
3226 (*ref)->save_in_field(result_field, no_conversions);
3230 return ref ? (*ref)->real_item() :
this;
3232 bool walk(Item_processor processor,
bool walk_subquery, uchar *arg)
3234 return (*ref)->walk(processor, walk_subquery, arg) ||
3235 (this->*processor)(arg);
3238 virtual Item*
compile(Item_analyzer analyzer, uchar **arg_p,
3239 Item_transformer transformer, uchar *arg_t);
3240 virtual bool explain_subquery_checker(uchar **arg)
3250 virtual void print(
String *str, enum_query_type query_type);
3253 {
return (*ref)->field_for_view_update(); }
3254 virtual Ref_Type ref_type() {
return REF; }
3259 return ref && result_type() == ROW_RESULT ? (*ref)->cols() : 1;
3261 Item* element_index(uint
i)
3263 return ref && result_type() == ROW_RESULT ? (*ref)->element_index(i) :
this;
3267 return ref && result_type() == ROW_RESULT ? (*ref)->addr(i) : 0;
3269 bool check_cols(uint c)
3271 return ref && result_type() == ROW_RESULT ? (*ref)->check_cols(c)
3272 : Item::check_cols(c);
3276 return ref && result_type() == ROW_RESULT ? (*ref)->null_inside() : 0;
3280 if (ref && result_type() == ROW_RESULT)
3281 (*ref)->bring_value();
3286 return (*ref)->get_time(ltime);
3288 virtual bool basic_const_item()
const {
return ref && (*ref)->basic_const_item(); }
3289 bool is_outer_field()
const
3293 return (*ref)->is_outer_field();
3302 return (*ref)->has_subquery();
3311 return (*ref)->has_stored_program();
3316 return (*ref)->created_by_in2exists();
3329 const char *table_name_arg,
3330 const char *field_name_arg,
3331 bool alias_name_used_arg= FALSE)
3332 :
Item_ref(context_arg, item, table_name_arg,
3333 field_name_arg, alias_name_used_arg)
3346 bool get_date(
MYSQL_TIME *ltime,uint fuzzydate);
3347 virtual Ref_Type ref_type() {
return DIRECT_REF; }
3359 const char *alias_name_arg,
3360 const char *table_name_arg,
3361 const char *field_name_arg)
3364 orig_table_name= table_name_arg;
3376 virtual bool subst_argument_checker(uchar **arg)
3382 bool eq(
const Item *item,
bool binary_cmp)
const;
3383 Item *get_tmp_table_item(THD *thd)
3385 Item *item= Item_ref::get_tmp_table_item(thd);
3386 item->item_name= item_name;
3389 virtual Ref_Type ref_type() {
return VIEW_REF; }
3415 bool found_in_select_list;
3419 outer_field_arg->field_name),
3420 outer_ref(outer_field_arg), in_sum_func(0),
3421 found_in_select_list(0)
3428 const char *table_name_arg,
const char *field_name_arg,
3429 bool alias_name_used_arg)
3431 alias_name_used_arg),
3432 outer_ref(0), in_sum_func(0), found_in_select_list(1)
3434 void save_in_result_field(
bool no_conversions)
3436 outer_ref->save_org_in_field(result_field);
3440 st_select_lex *removed_select);
3441 table_map used_tables()
const
3443 return (*ref)->const_item() ? 0 : OUTER_REF_TABLE_BIT;
3445 table_map not_null_tables()
const {
return 0; }
3447 virtual Ref_Type ref_type() {
return OUTER_REF; }
3470 const char *table_name_arg,
const char *field_name_arg)
3471 :
Item_ref(context_arg, item, table_name_arg, field_name_arg),
3480 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
3481 virtual void print(
String *str, enum_query_type query_type);
3485 table_map used_tables()
const
3487 return (depended_from ?
3488 OUTER_REF_TABLE_BIT :
3489 (*ref)->used_tables() | RAND_TABLE_BIT);
3510 unsigned_flag= unsigned_arg;
3517 virtual Item *real_item() {
return ref; }
3527 enum_field_types cached_field_type;
3530 uint8 decimals_arg, longlong i,
Item *ref_arg,
3531 bool unsigned_flag):
3533 cached_field_type(field_type_arg)
3535 decimals= decimals_arg;
3537 enum_field_types field_type()
const {
return cached_field_type; }
3538 void print(
String *str, enum_query_type query_type);
3539 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
3562 enum_field_types cached_field_type;
3572 uint8 decimals_arg, longlong i,
Item *ref_arg):
3574 cached_field_type(field_type_arg)
3617 #include "gstream.h"
3618 #include "spatial.h"
3619 #include "item_sum.h"
3620 #include "item_func.h"
3621 #include "item_row.h"
3622 #include "item_cmpfunc.h"
3623 #include "item_strfunc.h"
3624 #include "item_geofunc.h"
3625 #include "item_timefunc.h"
3626 #include "item_subselect.h"
3627 #include "item_xmlfunc.h"
3628 #include "item_create.h"
3679 null_value=maybe_null=item->maybe_null;
3680 decimals=item->decimals;
3681 max_length=item->max_length;
3682 item_name= item->item_name;
3685 unsigned_flag= item->unsigned_flag;
3687 collation.set(item->collation);
3706 virtual void copy() = 0;
3710 enum Type
type()
const {
return COPY_STR_ITEM; }
3714 void make_field(
Send_field *field) { item->make_field(field); }
3715 table_map used_tables()
const {
return (table_map) 1L; }
3716 bool const_item()
const {
return 0; }
3717 bool is_null() {
return null_value; }
3719 virtual void no_rows_in_result()
3721 item->no_rows_in_result();
3731 virtual double val_real() = 0;
3732 virtual longlong val_int() = 0;
3733 virtual bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)= 0;
3736 bool no_conversions) = 0;
3753 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
3763 longlong cached_value;
3770 virtual double val_real()
3772 return null_value ? 0.0 : (double) cached_value;
3774 virtual longlong val_int()
3776 return null_value ? LL(0) : cached_value;
3778 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
3786 virtual void copy();
3801 return null_value ? 0.0 : (double) (ulonglong) cached_value;
3809 double cached_value;
3818 return null_value ? 0.0 : cached_value;
3822 return (longlong) rint(val_real());
3824 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
3834 cached_value= item->val_real();
3835 null_value= item->null_value;
3851 return null_value ? NULL: &cached_value;
3855 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
3872 virtual bool cmp(
void)=0;
3879 uint32 value_max_length;
3936 org_ptr= field->ptr;
3937 fprintf(DBUG_FILE,
"new: ");
3938 field->dbug_print();
3940 fprintf(DBUG_FILE,
", old: ");
3941 field->dbug_print();
3942 field->ptr= org_ptr;
3943 fprintf(DBUG_FILE,
"\n");
3950 buff= (uchar*) sql_calloc(length=field->pack_length());
3960 :
Item_field(context_arg, (
const char *)NULL, (
const char *)NULL,
3961 (
const char *)NULL),
3964 :
Item_field(context_arg, (
const char *)NULL, (
const char *)NULL,
3965 (
const char *)NULL),
3967 enum Type type()
const {
return DEFAULT_VALUE_ITEM; }
3968 bool eq(
const Item *item,
bool binary_cmp)
const;
3970 virtual void print(
String *str, enum_query_type query_type);
3972 table_map used_tables()
const {
return (table_map)0L; }
3973 Item *get_tmp_table_item(THD *thd) {
return copy_or_same(thd); }
3975 bool walk(Item_processor processor,
bool walk_subquery, uchar *args)
3977 if (arg && arg->walk(processor, walk_subquery, args))
3980 return (this->*processor)(args);
4001 :
Item_field(context_arg, (
const char *)NULL, (
const char *)NULL,
4002 (
const char *)NULL),
4004 bool eq(
const Item *item,
bool binary_cmp)
const;
4006 virtual void print(
String *str, enum_query_type query_type);
4015 table_map used_tables()
const {
return RAND_TABLE_BIT; }
4017 bool walk(Item_processor processor,
bool walk_subquery, uchar *args)
4019 return arg->walk(processor, walk_subquery, args) ||
4020 (this->*processor)(args);
4043 enum row_version_type {OLD_ROW, NEW_ROW};
4044 row_version_type row_version;
4053 row_version_type row_ver_arg,
4054 const char *field_name_arg,
4055 ulong priv,
const bool ro)
4057 (
const char *)NULL, (
const char *)NULL, field_name_arg),
4058 row_version(row_ver_arg), field_idx((uint)-1), original_privilege(priv),
4059 want_privilege(priv), table_grants(NULL), read_only (ro)
4062 enum Type type()
const {
return TRIGGER_FIELD_ITEM; }
4063 bool eq(
const Item *item,
bool binary_cmp)
const;
4064 bool fix_fields(THD *,
Item **);
4065 virtual void print(
String *str, enum_query_type query_type);
4066 table_map used_tables()
const {
return (table_map)0L; }
4067 Field *get_tmp_table_field() {
return 0; }
4068 Item *copy_or_same(THD *thd) {
return this; }
4069 Item *get_tmp_table_item(THD *thd) {
return copy_or_same(thd); }
4073 void set_required_privilege(
bool rw);
4079 return (read_only ? 0 :
this);
4082 bool set_value(THD *thd,
Item **it)
4084 return set_value(thd, NULL, it);
4098 ulong original_privilege;
4099 ulong want_privilege;
4113 table_map used_table_map;
4120 enum enum_field_types cached_field_type;
4132 cached_field_type(MYSQL_TYPE_STRING),
4140 cached_field_type(field_type_arg),
4147 void set_used_tables(table_map map) { used_table_map= map; }
4154 virtual bool allocate(uint i) {
return 0; }
4155 virtual bool setup(
Item *item)
4158 max_length= item->max_length;
4159 decimals= item->decimals;
4160 collation.set(item->collation);
4161 unsigned_flag= item->unsigned_flag;
4162 if (item->type() == FIELD_ITEM)
4166 enum Type type()
const {
return CACHE_ITEM; }
4167 enum_field_types field_type()
const {
return cached_field_type; }
4169 static Item_cache* get_cache(
const Item* item,
const Item_result type);
4170 table_map used_tables()
const {
return used_table_map; }
4171 virtual void keep_array() {}
4172 virtual void print(
String *str, enum_query_type query_type);
4173 bool eq_def(
Field *field)
4177 bool eq(
const Item *item,
bool binary_cmp)
const
4179 return this == item;
4188 return (value_cached || cache_value()) && !null_value;
4198 virtual void store(
Item *item);
4199 virtual bool cache_value()= 0;
4200 bool basic_const_item()
const
4201 {
return test(example && example->basic_const_item());}
4202 bool walk (Item_processor processor,
bool walk_subquery, uchar *argument);
4203 virtual void clear() { null_value= TRUE; value_cached= FALSE; }
4204 bool is_null() {
return value_cached ? null_value : example->is_null(); }
4205 Item_result result_type()
const
4224 virtual void store(
Item *item){ Item_cache::store(item); }
4225 void store(
Item *item, longlong val_arg);
4232 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4240 enum Item_result result_type()
const {
return INT_RESULT; }
4256 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4264 enum Item_result result_type()
const {
return REAL_RESULT; }
4280 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4288 enum Item_result result_type()
const {
return DECIMAL_RESULT; }
4295 char buffer[STRING_BUFFER_USUAL_SIZE];
4296 String *value, value_buff;
4302 is_varbinary(item->type() == FIELD_ITEM &&
4303 cached_field_type == MYSQL_TYPE_VARCHAR &&
4304 !((
const Item_field *) item)->field->has_charset())
4306 collation.set(const_cast<DTCollation&>(item->collation));
4312 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4320 enum Item_result result_type()
const {
return STRING_RESULT; }
4321 const CHARSET_INFO *charset()
const {
return value->charset(); };
4340 bool allocate(uint num);
4345 bool setup(
Item *item);
4346 void store(
Item *item);
4347 void illegal_method_call(
const char *);
4350 illegal_method_call((
const char*)
"make_field");
4354 illegal_method_call((
const char*)
"val");
4359 illegal_method_call((
const char*)
"val_int");
4364 illegal_method_call((
const char*)
"val_str");
4369 illegal_method_call((
const char*)
"val_decimal");
4372 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4374 illegal_method_call((
const char *)
"get_date");
4379 illegal_method_call((
const char *)
"get_time");
4383 enum Item_result result_type()
const {
return ROW_RESULT; }
4385 uint cols() {
return item_count; }
4386 Item *element_index(uint i) {
return values[
i]; }
4387 Item **addr(uint i) {
return (
Item **) (values +
i); }
4388 bool check_cols(uint c);
4391 void keep_array() { save_array= 1; }
4394 DBUG_ENTER(
"Item_cache_row::cleanup");
4395 Item_cache::cleanup();
4397 memset(values, 0, item_count*
sizeof(
Item**));
4411 bool str_value_cached;
4414 Item_cache(field_type_arg), int_value(0), str_value_cached(0)
4416 cmp_context= STRING_RESULT;
4419 void store(
Item *item, longlong val_arg);
4420 void store(
Item *item);
4427 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate);
4429 enum Item_result result_type()
const {
return STRING_RESULT; }
4437 bool cache_value_int();
4439 void clear() { Item_cache::clear(); str_value_cached= FALSE; }
4454 enum_field_types fld_type;
4455 Field::geometry_type geometry_type;
4460 int prev_decimal_int_part;
4465 enum_field_types field_type()
const {
return fld_type; };
4466 enum Type type()
const {
return TYPE_HOLDER; }
4471 bool get_date(
MYSQL_TIME *ltime, uint fuzzydate)
4485 Field::geometry_type get_geometry_type()
const {
return geometry_type; };
4489 class st_select_lex;
4490 void mark_select_range_as_dependent(THD *thd,
4491 st_select_lex *last_select,
4492 st_select_lex *current_sel,
4497 bool use_result_field);
4498 extern Item_result item_cmp_type(Item_result a,Item_result b);
4500 extern int stored_field_cmp_to_item(THD *thd,
Field *field,
Item *item);
4502 extern const String my_null_string;