summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2006-12-21 13:53:34 +0400
committerunknown <ramil/ram@mysql.com/ramil.myoffice.izhnet.ru>2006-12-21 13:53:34 +0400
commit2f11f1d3a9b4138315d4f0bcf3e8725dbfb25e02 (patch)
tree1945856d27ead313a33083898b2e5fc0f98b6f65
parent6cf0571a97b9d9381c650b96e039c0c0aba955a5 (diff)
downloadmariadb-git-2f11f1d3a9b4138315d4f0bcf3e8725dbfb25e02.tar.gz
Fix for bug #22824: strict, datetime, NULL, wrong warning
During optimization we replace NULL with 0 for not null date{time} fields, so uset MODE_NO_ZERO_DATE flag for a while as we don't want to give extra warnings. mysql-test/r/strict.result: Fix for bug #22824: strict, datetime, NULL, wrong warning - test result. mysql-test/t/strict.test: Fix for bug #22824: strict, datetime, NULL, wrong warning - test case. sql/item_cmpfunc.cc: Fix for bug #22824: strict, datetime, NULL, wrong warning - turn off MODE_NO_ZERO_DATE in order not to get extra warinings in the save_in_field().
-rw-r--r--mysql-test/r/strict.result7
-rw-r--r--mysql-test/t/strict.test11
-rw-r--r--sql/item_cmpfunc.cc3
3 files changed, 20 insertions, 1 deletions
diff --git a/mysql-test/r/strict.result b/mysql-test/r/strict.result
index 702fc68bb25..4a85b5e483c 100644
--- a/mysql-test/r/strict.result
+++ b/mysql-test/r/strict.result
@@ -1352,3 +1352,10 @@ t1 CREATE TABLE `t1` (
`i` int(11) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COMMENT='123456789*123456789*123456789*123456789*123456789*123456789*'
drop table t1;
+set @@sql_mode='NO_ZERO_DATE';
+create table t1(a datetime not null);
+select count(*) from t1 where a is null;
+count(*)
+0
+drop table t1;
+End of 5.0 tests
diff --git a/mysql-test/t/strict.test b/mysql-test/t/strict.test
index 6ebbb53ed8e..0c38385c508 100644
--- a/mysql-test/t/strict.test
+++ b/mysql-test/t/strict.test
@@ -1208,3 +1208,14 @@ create table t1 (i int)
comment '123456789*123456789*123456789*123456789*123456789*123456789*';
show create table t1;
drop table t1;
+
+#
+# Bug #22824: strict, datetime, NULL, wrong warning
+#
+
+set @@sql_mode='NO_ZERO_DATE';
+create table t1(a datetime not null);
+select count(*) from t1 where a is null;
+drop table t1;
+
+--echo End of 5.0 tests
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 9a400d60ae6..256d2d11af8 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -241,7 +241,8 @@ static bool convert_constant_item(THD *thd, Field *field, Item **item)
{
/* For comparison purposes allow invalid dates like 2000-01-32 */
ulong orig_sql_mode= thd->variables.sql_mode;
- thd->variables.sql_mode|= MODE_INVALID_DATES;
+ thd->variables.sql_mode= (orig_sql_mode & ~MODE_NO_ZERO_DATE) |
+ MODE_INVALID_DATES;
if (!(*item)->save_in_field(field, 1) && !((*item)->null_value))
{
Item *tmp=new Item_int_with_ref(field->val_int(), *item,