summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMattias Jonsson <mattias.jonsson@oracle.com>2011-03-16 11:59:01 +0100
committerMattias Jonsson <mattias.jonsson@oracle.com>2011-03-16 11:59:01 +0100
commitd53906e3872016cb06f48a80557fb8edda59b691 (patch)
treecea140d8d7b63bf9d57e1b8efda833a7a008cc7d /sql
parent378091e434d66dcc7081f991a07db2244dbb8cda (diff)
downloadmariadb-git-d53906e3872016cb06f48a80557fb8edda59b691.tar.gz
Bug#11746819:
Bug#28928: UNIX_TIMESTAMP() should be considered unary monotonic by partition pruning Made UNIX_TIMESTAMP MONOTONIC_INCREASING when it have TIMESTAMP argument (only).
Diffstat (limited to 'sql')
-rw-r--r--sql/item_timefunc.cc20
-rw-r--r--sql/item_timefunc.h2
2 files changed, 22 insertions, 0 deletions
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 6335199b8de..c986ec6c00b 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -1316,6 +1316,26 @@ longlong Item_func_unix_timestamp::val_int()
return (longlong) TIME_to_timestamp(current_thd, &ltime, &not_used);
}
+enum_monotonicity_info Item_func_unix_timestamp::get_monotonicity_info() const
+{
+ if (args[0]->type() == Item::FIELD_ITEM &&
+ (args[0]->field_type() == MYSQL_TYPE_TIMESTAMP))
+ return MONOTONIC_INCREASING;
+ return NON_MONOTONIC;
+}
+
+
+longlong Item_func_unix_timestamp::val_int_endpoint(bool left_endp, bool *incl_endp)
+{
+ DBUG_ASSERT(fixed == 1);
+ DBUG_ASSERT(arg_count == 1 &&
+ args[0]->type() == Item::FIELD_ITEM &&
+ args[0]->field_type() == MYSQL_TYPE_TIMESTAMP);
+ Field *field=((Item_field*) args[0])->field;
+ /* Leave the incl_endp intact */
+ return ((Field_timestamp*) field)->get_timestamp(&null_value);
+}
+
longlong Item_func_time_to_sec::val_int()
{
diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h
index 9c1ac512bcb..c366c824f13 100644
--- a/sql/item_timefunc.h
+++ b/sql/item_timefunc.h
@@ -349,6 +349,8 @@ public:
Item_func_unix_timestamp(Item *a) :Item_int_func(a) {}
longlong val_int();
const char *func_name() const { return "unix_timestamp"; }
+ enum_monotonicity_info get_monotonicity_info() const;
+ longlong val_int_endpoint(bool left_endp, bool *incl_endp);
bool check_partition_func_processor(uchar *int_arg) {return FALSE;}
/*
UNIX_TIMESTAMP() depends on the current timezone