summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h73
1 files changed, 69 insertions, 4 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index f6b1100ec26..210f9c26fb3 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1,4 +1,4 @@
-/* Copyright 2000-2008 MySQL AB, 2008 Sun Microsystems, Inc.
+/* Copyright (c) 2000, 2010, 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 as published by
@@ -64,6 +64,7 @@ public:
allowed_arg_cols(1), arg_count(0)
{
with_sum_func= 0;
+ with_field= 0;
}
Item_func(Item *a):
allowed_arg_cols(1), arg_count(1)
@@ -71,6 +72,7 @@ public:
args= tmp_arg;
args[0]= a;
with_sum_func= a->with_sum_func;
+ with_field= a->with_field;
}
Item_func(Item *a,Item *b):
allowed_arg_cols(1), arg_count(2)
@@ -78,6 +80,7 @@ public:
args= tmp_arg;
args[0]= a; args[1]= b;
with_sum_func= a->with_sum_func || b->with_sum_func;
+ with_field= a->with_field || b->with_field;
}
Item_func(Item *a,Item *b,Item *c):
allowed_arg_cols(1)
@@ -88,6 +91,7 @@ public:
arg_count= 3;
args[0]= a; args[1]= b; args[2]= c;
with_sum_func= a->with_sum_func || b->with_sum_func || c->with_sum_func;
+ with_field= a->with_field || b->with_field || c->with_field;
}
}
Item_func(Item *a,Item *b,Item *c,Item *d):
@@ -100,6 +104,8 @@ public:
args[0]= a; args[1]= b; args[2]= c; args[3]= d;
with_sum_func= a->with_sum_func || b->with_sum_func ||
c->with_sum_func || d->with_sum_func;
+ with_field= a->with_field || b->with_field ||
+ c->with_field || d->with_field;
}
}
Item_func(Item *a,Item *b,Item *c,Item *d,Item* e):
@@ -111,6 +117,8 @@ public:
args[0]= a; args[1]= b; args[2]= c; args[3]= d; args[4]= e;
with_sum_func= a->with_sum_func || b->with_sum_func ||
c->with_sum_func || d->with_sum_func || e->with_sum_func ;
+ with_field= a->with_field || b->with_field ||
+ c->with_field || d->with_field || e->with_field;
}
}
Item_func(List<Item> &list);
@@ -118,6 +126,7 @@ public:
Item_func(THD *thd, Item_func *item);
bool fix_fields(THD *, Item **ref);
void fix_after_pullout(st_select_lex *new_parent, Item **ref);
+ void quick_fix_field();
table_map used_tables() const;
table_map not_null_tables() const;
void update_used_tables();
@@ -191,6 +200,7 @@ public:
null_value=1;
return 0.0;
}
+
bool has_timestamp_args()
{
DBUG_ASSERT(fixed == TRUE);
@@ -202,6 +212,45 @@ public:
}
return FALSE;
}
+
+ bool has_date_args()
+ {
+ DBUG_ASSERT(fixed == TRUE);
+ for (uint i= 0; i < arg_count; i++)
+ {
+ if (args[i]->type() == Item::FIELD_ITEM &&
+ (args[i]->field_type() == MYSQL_TYPE_DATE ||
+ args[i]->field_type() == MYSQL_TYPE_DATETIME))
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ bool has_time_args()
+ {
+ DBUG_ASSERT(fixed == TRUE);
+ for (uint i= 0; i < arg_count; i++)
+ {
+ if (args[i]->type() == Item::FIELD_ITEM &&
+ (args[i]->field_type() == MYSQL_TYPE_TIME ||
+ args[i]->field_type() == MYSQL_TYPE_DATETIME))
+ return TRUE;
+ }
+ return FALSE;
+ }
+
+ bool has_datetime_args()
+ {
+ DBUG_ASSERT(fixed == TRUE);
+ for (uint i= 0; i < arg_count; i++)
+ {
+ if (args[i]->type() == Item::FIELD_ITEM &&
+ args[i]->field_type() == MYSQL_TYPE_DATETIME)
+ return TRUE;
+ }
+ return FALSE;
+ }
+
/*
We assume the result of any function that has a TIMESTAMP argument to be
timezone-dependent, since a TIMESTAMP value in both numeric and string
@@ -210,7 +259,7 @@ public:
representation of a TIMESTAMP argument verbatim, and thus does not depend on
the timezone.
*/
- virtual bool is_timezone_dependent_processor(uchar *bool_arg)
+ virtual bool check_valid_arguments_processor(uchar *bool_arg)
{
return has_timestamp_args();
}
@@ -219,6 +268,21 @@ public:
{
return functype() == *(Functype *) arg;
}
+
+ void no_rows_in_result()
+ {
+ bool_func_call_args info;
+ info.original_func_item= this;
+ info.bool_function= &Item::no_rows_in_result;
+ walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info);
+ }
+ void restore_to_before_no_rows_in_result()
+ {
+ bool_func_call_args info;
+ info.original_func_item= this;
+ info.bool_function= &Item::restore_to_before_no_rows_in_result;
+ walk(&Item::call_bool_func_processor, FALSE, (uchar*) &info);
+ }
};
@@ -1393,6 +1457,7 @@ public:
my_decimal *val_decimal(my_decimal *);
double val_result();
longlong val_int_result();
+ bool val_bool_result();
String *str_result(String *str);
my_decimal *val_decimal_result(my_decimal *);
bool is_null_result();
@@ -1505,7 +1570,7 @@ class Item_func_get_system_var :public Item_func
longlong cached_llval;
double cached_dval;
String cached_strval;
- my_bool cached_null_value;
+ bool cached_null_value;
query_id_t used_query_id;
uchar cache_present;
@@ -1570,7 +1635,7 @@ public:
join_key(0), ft_handler(0), table(0), master(0), concat_ws(0) { }
void cleanup()
{
- DBUG_ENTER("Item_func_match");
+ DBUG_ENTER("Item_func_match::cleanup");
Item_real_func::cleanup();
if (!master && ft_handler)
ft_handler->please->close_search(ft_handler);