Below is the list of changes that have just been committed into a local
5.1 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@stripped, 2007-11-16 09:15:36+04:00, ramil@stripped +3 -0
Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
Problem: caching 00000000-00000099 dates as integer values we're
improperly shifting them up twice in the get_datetime_value().
Fix: don't shift cached values up for the second time.
mysql-test/r/type_date.result@stripped, 2007-11-16 09:15:34+04:00, ramil@stripped +7 -0
Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
- test result.
mysql-test/t/type_date.test@stripped, 2007-11-16 09:15:34+04:00, ramil@stripped +10 -0
Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
- test case.
sql/item_cmpfunc.cc@stripped, 2007-11-16 09:15:34+04:00, ramil@stripped +4 -2
Fix for bug #32021: Using Date 000-00-01 in WHERE causes wrong result
- don't shift cached values for the second time in the get_datetime_value().
diff -Nrup a/mysql-test/r/type_date.result b/mysql-test/r/type_date.result
--- a/mysql-test/r/type_date.result 2007-05-24 20:33:54 +05:00
+++ b/mysql-test/r/type_date.result 2007-11-16 09:15:34 +04:00
@@ -145,3 +145,10 @@ d dt ts
0000-00-00 0000-00-00 00:00:00 0000-00-00 00:00:00
2001-11-11 2001-11-11 00:00:00 2001-11-11 00:00:00
drop table t1;
+create table t1 (a date, primary key (a))engine=memory;
+insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01');
+select * from t1 where a between '0000-00-01' and '0000-00-02';
+a
+0000-00-01
+drop table t1;
+End of 5.1 tests
diff -Nrup a/mysql-test/t/type_date.test b/mysql-test/t/type_date.test
--- a/mysql-test/t/type_date.test 2007-05-24 20:33:54 +05:00
+++ b/mysql-test/t/type_date.test 2007-11-16 09:15:34 +04:00
@@ -139,3 +139,13 @@ insert into t1 values (9912101,9912101,9
insert into t1 values (11111,11111,11111);
select * from t1;
drop table t1;
+
+#
+# Bug#32021: Using Date 000-00-01 in WHERE causes wrong result
+#
+create table t1 (a date, primary key (a))engine=memory;
+insert into t1 values ('0000-01-01'), ('0000-00-01'), ('0001-01-01');
+select * from t1 where a between '0000-00-01' and '0000-00-02';
+drop table t1;
+
+--echo End of 5.1 tests
diff -Nrup a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
--- a/sql/item_cmpfunc.cc 2007-11-06 14:07:17 +04:00
+++ b/sql/item_cmpfunc.cc 2007-11-16 09:15:34 +04:00
@@ -900,9 +900,11 @@ get_datetime_value(THD *thd, Item ***ite
/*
Item_date_add_interval may return MYSQL_TYPE_STRING as the result
field type. To detect that the DATE value has been returned we
- compare it with 1000000L - any DATE value should be less than it.
+ compare it with 100000000L - any DATE value should be less than it.
+ Don't shift cached values up for the second time.
*/
- if (item->field_type() == MYSQL_TYPE_DATE || value < 100000000L)
+ if (item->field_type() == MYSQL_TYPE_DATE ||
+ (item->type() != Item::CACHE_ITEM && value < 100000000L))
value*= 1000000L;
}
else
| Thread |
|---|
| • bk commit into 5.1 tree (ramil:1.2619) BUG#32021 | ramil | 16 Nov |