List:Commits« Previous MessageNext Message »
From:Mattias Jonsson Date:February 4 2011 2:02pm
Subject:bzr commit into mysql-5.1 branch (mattias.jonsson:3576)
View as plain text  
#At file:///Users/mattiasj/mysql-bzr/b28928-51/ based on revid:dmitry.shulga@stripped

 3576 Mattias Jonsson	2011-02-04
      Preliminary patch for supporting range pruning of UNIX_TIMESTAMP

    modified:
      mysql-test/t/partition.test
      sql/item_timefunc.cc
      sql/item_timefunc.h
=== modified file 'mysql-test/t/partition.test'
--- a/mysql-test/t/partition.test	2010-12-22 09:50:36 +0000
+++ b/mysql-test/t/partition.test	2011-02-04 14:02:33 +0000
@@ -112,10 +112,16 @@ INSERT INTO t1 VALUES ('2009-07-14 17:35
 INSERT INTO t1 VALUES ('2009-09-21 17:31:42', 'pmax');
 
 SELECT * FROM t1;
+SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01';
+EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01';
+EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48';
 ALTER TABLE t1 REORGANIZE PARTITION pmax INTO (
  PARTITION p3 VALUES LESS THAN (1247688000),
  PARTITION pmax VALUES LESS THAN MAXVALUE);
 SELECT * FROM t1;
+SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01';
+EXPLAIN PARTITIONS SELECT * FROM t1 where a between '2007-01-01' and '2007-08-01';
+EXPLAIN PARTITIONS SELECT * FROM t1 where a = '2007-07-30 17:35:48';
 SHOW CREATE TABLE t1;
 DROP TABLE t1;
 

=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc	2010-11-12 10:12:15 +0000
+++ b/sql/item_timefunc.cc	2011-02-04 14:02:33 +0000
@@ -1316,6 +1316,26 @@ longlong Item_func_unix_timestamp::val_i
   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()
 {

=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h	2011-01-28 12:37:39 +0000
+++ b/sql/item_timefunc.h	2011-02-04 14:02:33 +0000
@@ -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


Attachment: [text/bzr-bundle] bzr/mattias.jonsson@oracle.com-20110204140233-knce6bra5rc9jfs1.bundle
Thread
bzr commit into mysql-5.1 branch (mattias.jonsson:3576) Mattias Jonsson4 Feb