List:Commits« Previous MessageNext Message »
From:ramil Date:January 18 2006 1:02pm
Subject:bk commit into 5.0 tree (ramil:1.2035) BUG#14360
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of ram. When ram does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2035 06/01/18 17:02:17 ramil@stripped +4 -0
  Fix for bug #14360: Date Between Interval Broken.

  sql/item_timefunc.h
    1.64 06/01/18 17:02:10 ramil@stripped +1 -0
    Fix for bug #14360: Date Between Interval Broken.
    - Item_date_add_interval::eq() introduced.

  sql/item_timefunc.cc
    1.101 06/01/18 17:02:10 ramil@stripped +41 -0
    Fix for bug #14360: Date Between Interval Broken.
    - Item_date_add_interval::eq() introduced.

  mysql-test/t/innodb.test
    1.123 06/01/18 17:02:10 ramil@stripped +12 -0
    Fix for bug #14360: Date Between Interval Broken.

  mysql-test/r/innodb.result
    1.153 06/01/18 17:02:10 ramil@stripped +9 -0
    Fix for bug #14360: Date Between Interval Broken.

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	ramil
# Host:	myoffice.izhnet.ru
# Root:	/usr/home/ram/work/5.0.b14360

--- 1.100/sql/item_timefunc.cc	2005-11-21 23:15:41 +04:00
+++ 1.101/sql/item_timefunc.cc	2006-01-18 17:02:10 +04:00
@@ -2118,6 +2118,47 @@ longlong Item_date_add_interval::val_int
     ((date*100L + ltime.hour)*100L+ ltime.minute)*100L + ltime.second;
 }
 
+
+bool Item_date_add_interval::eq(const Item *item, bool binary_cmp) const
+{
+  INTERVAL interval, other_interval;
+  String val= value;   // Because of const
+
+  if (this == item)
+    return 1;
+
+  if (item->type() != FUNC_ITEM) 
+    return 0;
+
+  if (arg_count != ((Item_func*) item)->arg_count ||
+      func_name() != ((Item_func*) item)->func_name())
+    return 0;
+
+  Item_date_add_interval *other= (Item_date_add_interval*) item;
+
+  if (int_type != other->int_type)
+    return 0;
+
+  if (!args[0]->eq(other->args[0], binary_cmp))
+    return 0;
+
+  if (get_interval_value(args[1], int_type, &val, &interval))
+    return 0;   // get_interval_value null or failed
+
+  val= other->value;
+
+  if (get_interval_value(other->args[1], other->int_type, &val, 
+                         &other_interval))
+    return 0;   // get_interval_value null or failed
+
+  if ((date_sub_interval ^ interval.neg) ^
+      (other->date_sub_interval ^ other_interval.neg))
+    return 0;
+
+  // Assume comparing same types here due to earlier check
+  return memcmp(&interval, &other_interval, sizeof(INTERVAL)) ? 0 : 1;
+}
+
 static const char *interval_names[]=
 {
   "year", "quarter", "month", "day", "hour",

--- 1.63/sql/item_timefunc.h	2005-11-10 18:13:07 +04:00
+++ 1.64/sql/item_timefunc.h	2006-01-18 17:02:10 +04:00
@@ -656,6 +656,7 @@ public:
   double val_real() { DBUG_ASSERT(fixed == 1); return (double) val_int(); }
   longlong val_int();
   bool get_date(TIME *res, uint fuzzy_date);
+  bool eq(const Item *item, bool binary_cmp) const;
   void print(String *str);
 };
 

--- 1.152/mysql-test/r/innodb.result	2006-01-16 15:03:55 +04:00
+++ 1.153/mysql-test/r/innodb.result	2006-01-18 17:02:10 +04:00
@@ -3180,3 +3180,12 @@ a	hex(b)
 7	D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B1D0B2
 update t1 set b = 'three' where a = 6;
 drop table t1;
+create table t1(a date) engine=innodb;
+create table t2(a date, key(a)) engine=innodb;
+insert into t1 values('2005-10-01');
+insert into t2 values('2005-10-01');
+select * from t1, t2 
+where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
+a	a
+2005-10-01	2005-10-01
+drop table t1, t2;

--- 1.122/mysql-test/t/innodb.test	2006-01-16 15:03:55 +04:00
+++ 1.123/mysql-test/t/innodb.test	2006-01-18 17:02:10 +04:00
@@ -2047,3 +2047,15 @@ insert into t1 values(7,_utf8 0xD0B1D0B1
 select a,hex(b) from t1 order by b;
 update t1 set b = 'three' where a = 6;
 drop table t1;
+
+#
+# Bug #14360: problem with intervals
+#
+
+create table t1(a date) engine=innodb;
+create table t2(a date, key(a)) engine=innodb;
+insert into t1 values('2005-10-01');
+insert into t2 values('2005-10-01');
+select * from t1, t2 
+  where t2.a between t1.a - interval 2 day and t1.a + interval 2 day;
+drop table t1, t2;
Thread
bk commit into 5.0 tree (ramil:1.2035) BUG#14360ramil18 Jan