summaryrefslogtreecommitdiff
path: root/sql/item_cmpfunc.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_cmpfunc.h')
-rw-r--r--sql/item_cmpfunc.h105
1 files changed, 77 insertions, 28 deletions
diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h
index 15ddab8b32e..de6c20420c3 100644
--- a/sql/item_cmpfunc.h
+++ b/sql/item_cmpfunc.h
@@ -798,6 +798,7 @@ public:
class in_longlong :public in_vector
{
+protected:
/*
Here we declare a temporary variable (tmp) of the same type as the
elements of this vector. tmp is used in finding if a given value is in
@@ -832,6 +833,30 @@ public:
friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
};
+
+/*
+ Class to represent a vector of constant DATE/DATETIME values.
+ Values are obtained with help of the get_datetime_value() function.
+ If the left item is a constant one then its value is cached in the
+ lval_cache variable.
+*/
+class in_datetime :public in_longlong
+{
+public:
+ THD *thd;
+ /* An item used to issue warnings. */
+ Item *warn_item;
+ /* Cache for the left item. */
+ Item *lval_cache;
+
+ in_datetime(Item *warn_item_arg, uint elements)
+ :in_longlong(elements), thd(current_thd), warn_item(warn_item_arg),
+ lval_cache(0) {};
+ void set(uint pos,Item *item);
+ byte *get_value(Item *item);
+ friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b);
+};
+
class in_double :public in_vector
{
double tmp;
@@ -964,6 +989,30 @@ public:
cmp_item *make_same();
};
+/*
+ Compare items in the DATETIME context.
+ Values are obtained with help of the get_datetime_value() function.
+ If the left item is a constant one then its value is cached in the
+ lval_cache variable.
+*/
+class cmp_item_datetime :public cmp_item
+{
+ ulonglong value;
+public:
+ THD *thd;
+ /* Item used for issuing warnings. */
+ Item *warn_item;
+ /* Cache for the left item. */
+ Item *lval_cache;
+
+ cmp_item_datetime(Item *warn_item_arg)
+ :thd(current_thd), warn_item(warn_item_arg), lval_cache(0) {}
+ void store_value(Item *item);
+ int cmp(Item *arg);
+ int compare(cmp_item *ci);
+ cmp_item *make_same();
+};
+
class cmp_item_real :public cmp_item
{
double value;
@@ -998,32 +1047,6 @@ public:
};
-class cmp_item_row :public cmp_item
-{
- cmp_item **comparators;
- uint n;
-public:
- cmp_item_row(): comparators(0), n(0) {}
- ~cmp_item_row();
- void store_value(Item *item);
- int cmp(Item *arg);
- int compare(cmp_item *arg);
- cmp_item *make_same();
- void store_value_by_template(cmp_item *tmpl, Item *);
-};
-
-
-class in_row :public in_vector
-{
- cmp_item_row tmp;
-public:
- in_row(uint elements, Item *);
- ~in_row();
- void set(uint pos,Item *item);
- uchar *get_value(Item *item);
- Item_result result_type() { return ROW_RESULT; }
-};
-
/*
cmp_item for optimized IN with row (right part string, which never
be changed)
@@ -1163,7 +1186,7 @@ public:
*/
bool arg_types_compatible;
Item_result left_result_type;
- cmp_item *cmp_items[5]; /* One cmp_item for each result type */
+ cmp_item *cmp_items[6]; /* One cmp_item for each result type */
DTCollation cmp_collation;
Item_func_in(List<Item> &list)
@@ -1184,7 +1207,7 @@ public:
Item_int_func::cleanup();
delete array;
array= 0;
- for (i= 0; i <= (uint)DECIMAL_RESULT; i++)
+ for (i= 0; i <= (uint)DECIMAL_RESULT + 1; i++)
{
delete cmp_items[i];
cmp_items[i]= 0;
@@ -1202,6 +1225,32 @@ public:
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
};
+class cmp_item_row :public cmp_item
+{
+ cmp_item **comparators;
+ uint n;
+public:
+ cmp_item_row(): comparators(0), n(0) {}
+ ~cmp_item_row();
+ void store_value(Item *item);
+ int cmp(Item *arg);
+ int compare(cmp_item *arg);
+ cmp_item *make_same();
+ void store_value_by_template(cmp_item *tmpl, Item *);
+};
+
+
+class in_row :public in_vector
+{
+ cmp_item_row tmp;
+public:
+ in_row(uint elements, Item *);
+ ~in_row();
+ void set(uint pos,Item *item);
+ uchar *get_value(Item *item);
+ Item_result result_type() { return ROW_RESULT; }
+};
+
/* Functions used by where clause */
class Item_func_isnull :public Item_bool_func