From: Date: July 6 2005 12:51am Subject: bk commit into 5.0 tree (jimw:1.1890) BUG#5906 List-Archive: http://lists.mysql.com/internals/26694 X-Bug: 5906 Message-Id: <20050705225150.EA587A8489@rama.trainedmonkey.com> Below is the list of changes that have just been committed into a local 5.0 repository of jimw. When jimw 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.1890 05/07/05 15:51:42 jimw@stripped +3 -0 Fix checking of month or day being set to 0 when converting to a DATE field from an integer or double. (Bug #5906) sql/field.cc 1.272 05/07/05 15:51:36 jimw@stripped +9 -0 Check that we don't set month or day to 0 when MODE_NO_ZERO_IN_DATE is in effect. mysql-test/t/strict.test 1.14 05/07/05 15:51:36 jimw@stripped +15 -0 Add regression test for Bug #5906 mysql-test/r/strict.result 1.19 05/07/05 15:51:36 jimw@stripped +13 -0 Add results # 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: jimw # Host: rama.(none) # Root: /home/jimw/my/mysql-5.0-5906 --- 1.271/sql/field.cc 2005-07-03 17:44:30 -07:00 +++ 1.272/sql/field.cc 2005-07-05 15:51:36 -07:00 @@ -5427,6 +5427,15 @@ MYSQL_TIMESTAMP_DATE, 1); error= 1; } + else if (table->in_use->variables.sql_mode & MODE_NO_ZERO_IN_DATE && + (month == 0 || day == 0)) + { + tmp=0L; // Don't allow date to change + set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, + ER_WARN_DATA_OUT_OF_RANGE, nr, + MYSQL_TIMESTAMP_DATE, 1); + error= 1; + } else tmp= day + month*32 + (tmp/10000)*16*32; } --- 1.18/mysql-test/r/strict.result 2005-05-13 01:22:21 -07:00 +++ 1.19/mysql-test/r/strict.result 2005-07-05 15:51:36 -07:00 @@ -1235,3 +1235,16 @@ ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead create table t1(a varbinary(65537)); ERROR 42000: Column length too big for column 'a' (max = 65535); use BLOB or TEXT instead +set @@sql_mode='traditional'; +create table t1 (d date); +insert into t1 values ('2000-10-00'); +ERROR 22007: Incorrect date value: '2000-10-00' for column 'd' at row 1 +insert into t1 values (1000); +ERROR 22007: Incorrect date value: '1000' for column 'd' at row 1 +insert into t1 values ('2000-10-01'); +update t1 set d = 1100; +ERROR 22007: Incorrect date value: '1100' for column 'd' at row 1 +select * from t1; +d +2000-10-01 +drop table t1; --- 1.13/mysql-test/t/strict.test 2005-05-13 01:22:21 -07:00 +++ 1.14/mysql-test/t/strict.test 2005-07-05 15:51:36 -07:00 @@ -1093,3 +1093,18 @@ create table t1(a varchar(65537)); --error 1074 create table t1(a varbinary(65537)); + +# +# Bug #5906: handle invalid date due to conversion +# +set @@sql_mode='traditional'; +create table t1 (d date); +--error 1292 +insert into t1 values ('2000-10-00'); +--error 1292 +insert into t1 values (1000); +insert into t1 values ('2000-10-01'); +--error 1292 +update t1 set d = 1100; +select * from t1; +drop table t1;