summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h56
1 files changed, 43 insertions, 13 deletions
diff --git a/sql/item.h b/sql/item.h
index 26ee946f147..b13438b248f 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1,7 +1,7 @@
#ifndef SQL_ITEM_INCLUDED
#define SQL_ITEM_INCLUDED
-/* Copyright (c) 2000, 2010 Oracle and/or its affiliates. All rights reserved.
+/* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -70,6 +70,8 @@ char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg)
(i.e. constant).
MY_COLL_ALLOW_CONV - allow any kind of conversion
(combination of the above two)
+ MY_COLL_ALLOW_NUMERIC_CONV - if all items were numbers, convert to
+ @@character_set_connection
MY_COLL_DISALLOW_NONE - don't allow return DERIVATION_NONE
(e.g. when aggregating for comparison)
MY_COLL_CMP_CONV - combination of MY_COLL_ALLOW_CONV
@@ -79,6 +81,7 @@ char_to_byte_length_safe(uint32 char_length_arg, uint32 mbmaxlen_arg)
#define MY_COLL_ALLOW_SUPERSET_CONV 1
#define MY_COLL_ALLOW_COERCIBLE_CONV 2
#define MY_COLL_DISALLOW_NONE 4
+#define MY_COLL_ALLOW_NUMERIC_CONV 8
#define MY_COLL_ALLOW_CONV (MY_COLL_ALLOW_SUPERSET_CONV | MY_COLL_ALLOW_COERCIBLE_CONV)
#define MY_COLL_CMP_CONV (MY_COLL_ALLOW_CONV | MY_COLL_DISALLOW_NONE)
@@ -568,6 +571,10 @@ public:
*/
Item *next;
uint32 max_length; /* Maximum length, in bytes */
+ /*
+ TODO: convert name and name_length fields into String to keep them in sync
+ (see bug #11829681/60295 etc).
+ */
uint name_length; /* Length of name */
int8 marker;
uint8 decimals;
@@ -1188,11 +1195,11 @@ public:
virtual bool set_no_const_sub(uchar *arg) { return FALSE; }
virtual Item *replace_equal_field(uchar * arg) { return this; }
/*
- Check if an expression value depends on the current timezone. Used by
- partitioning code to reject timezone-dependent expressions in a
- (sub)partitioning function.
+ Check if an expression value has allowed arguments, like DATE/DATETIME
+ for date functions. Also used by partitioning code to reject
+ timezone-dependent expressions in a (sub)partitioning function.
*/
- virtual bool is_timezone_dependent_processor(uchar *bool_arg)
+ virtual bool check_valid_arguments_processor(uchar *bool_arg)
{
return FALSE;
}
@@ -1353,7 +1360,7 @@ public:
maybe_null= 1;
}
else
- max_length= max_result_length;
+ max_length= (uint32) max_result_length;
}
void fix_length_and_charset_datetime(uint32 max_char_length_arg)
{
@@ -1708,7 +1715,8 @@ agg_item_charsets_for_string_result(DTCollation &c, const char *name,
int item_sep= 1)
{
uint flags= MY_COLL_ALLOW_SUPERSET_CONV |
- MY_COLL_ALLOW_COERCIBLE_CONV;
+ MY_COLL_ALLOW_COERCIBLE_CONV |
+ MY_COLL_ALLOW_NUMERIC_CONV;
return agg_item_charsets(c, name, items, nitems, flags, item_sep);
}
inline bool
@@ -1721,6 +1729,19 @@ agg_item_charsets_for_comparison(DTCollation &c, const char *name,
MY_COLL_DISALLOW_NONE;
return agg_item_charsets(c, name, items, nitems, flags, item_sep);
}
+inline bool
+agg_item_charsets_for_string_result_with_comparison(DTCollation &c,
+ const char *name,
+ Item **items, uint nitems,
+ int item_sep= 1)
+{
+ uint flags= MY_COLL_ALLOW_SUPERSET_CONV |
+ MY_COLL_ALLOW_COERCIBLE_CONV |
+ MY_COLL_ALLOW_NUMERIC_CONV |
+ MY_COLL_DISALLOW_NONE;
+ return agg_item_charsets(c, name, items, nitems, flags, item_sep);
+}
+
class Item_num: public Item_basic_constant
{
@@ -1816,6 +1837,8 @@ public:
String *val_str(String *str) { return field->val_str(str); }
my_decimal *val_decimal(my_decimal *dec) { return field->val_decimal(dec); }
void make_field(Send_field *tmp_field);
+ CHARSET_INFO *charset_for_protocol(void) const
+ { return field->charset_for_protocol(); }
};
@@ -2785,7 +2808,7 @@ public:
DBUG_ASSERT(fixed);
return (*ref)->get_time(ltime);
}
- virtual bool basic_const_item() const { return (*ref)->basic_const_item(); }
+ virtual bool basic_const_item() const { return ref && (*ref)->basic_const_item(); }
bool is_outer_field() const
{
DBUG_ASSERT(fixed);
@@ -3564,11 +3587,10 @@ class Item_cache: public Item_basic_constant
protected:
Item *example;
table_map used_table_map;
- /*
- Field that this object will get value from. This is set/used by
+ /**
+ Field that this object will get value from. This is used by
index-based subquery engines to detect and remove the equality injected
by IN->EXISTS transformation.
- For all other uses of Item_cache, cached_field doesn't matter.
*/
Field *cached_field;
enum enum_field_types cached_field_type;
@@ -3642,6 +3664,14 @@ public:
{
return (value_cached || cache_value()) && !null_value;
}
+
+ /**
+ If this item caches a field value, return pointer to underlying field.
+
+ @return Pointer to field, or NULL if this is not a cache for a field value.
+ */
+ Field* field() { return cached_field; }
+
virtual void store(Item *item);
virtual bool cache_value()= 0;
bool basic_const_item() const
@@ -3809,7 +3839,7 @@ class Item_cache_datetime: public Item_cache
{
protected:
String str_value;
- ulonglong int_value;
+ longlong int_value;
bool str_value_cached;
public:
Item_cache_datetime(enum_field_types field_type_arg):
@@ -3818,8 +3848,8 @@ public:
cmp_context= STRING_RESULT;
}
- virtual void store(Item *item) { Item_cache::store(item); }
void store(Item *item, longlong val_arg);
+ void store(Item *item);
double val_real();
longlong val_int();
String* val_str(String *str);