Below is the list of changes that have just been committed into a local
5.1 repository of anozdrin. When anozdrin 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, 2008-03-20 11:06:59+03:00, anozdrin@quad. +3 -0
Fix for Bug#34274: Invalid handling of 'DEFAULT 0'
for YEAR data type.
The problem was that for some unknown reason 0 was not allowed
as a default value for YEAR data type. That was coded before BK.
However the Manual does not say a word about such a limitation.
Also, it looks inconsistent with other data types.
The fix is to allow 0 as a default value.
mysql-test/r/create.result@stripped, 2008-03-20 11:06:58+03:00, anozdrin@quad. +41 -0
Update result file.
mysql-test/t/create.test@stripped, 2008-03-20 11:06:58+03:00, anozdrin@quad. +49 -1
Add a test case for Bug#34274: Invalid handling of 'DEFAULT 0'
for YEAR data type.
sql/unireg.cc@stripped, 2008-03-20 11:06:58+03:00, anozdrin@quad. +1 -3
Allow 0 as a default value for YEAR data type.
diff -Nrup a/mysql-test/r/create.result b/mysql-test/r/create.result
--- a/mysql-test/r/create.result 2008-03-12 11:13:18 +03:00
+++ b/mysql-test/r/create.result 2008-03-20 11:06:58 +03:00
@@ -1847,4 +1847,45 @@ DROP TABLE t3;
# -- End of Bug#18834.
+# --
+# -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
+# --
+
+DROP TABLE IF EXISTS t1;
+
+CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
+
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` year(4) DEFAULT '2008',
+ `c2` year(4) DEFAULT '0000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+
+INSERT INTO t1 VALUES();
+
+SELECT * FROM t1;
+c1 c2
+2008 0000
+
+ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
+
+SHOW CREATE TABLE t1;
+Table Create Table
+t1 CREATE TABLE `t1` (
+ `c1` year(4) DEFAULT '0000',
+ `c2` year(4) DEFAULT '0000'
+) ENGINE=MyISAM DEFAULT CHARSET=latin1
+
+INSERT INTO t1 VALUES();
+
+SELECT * FROM t1;
+c1 c2
+2008 0000
+0000 0000
+
+DROP TABLE t1;
+
+# -- End of Bug#34274
+
End of 5.1 tests
diff -Nrup a/mysql-test/t/create.test b/mysql-test/t/create.test
--- a/mysql-test/t/create.test 2008-03-12 11:13:19 +03:00
+++ b/mysql-test/t/create.test 2008-03-20 11:06:58 +03:00
@@ -1365,6 +1365,8 @@ create table t1 like information_schema.
show create table t1;
drop table t1;
+###########################################################################
+
--echo
--echo # --
--echo # -- Bug#21380: DEFAULT definition not always transfered by CREATE
@@ -1407,8 +1409,10 @@ DROP TABLE t2;
--echo
--echo # -- End of test case for Bug#21380.
---echo
+###########################################################################
+
+--echo
--echo # --
--echo # -- Bug#18834: ALTER TABLE ADD INDEX on table with two timestamp fields
--echo # --
@@ -1471,6 +1475,50 @@ DROP TABLE t3;
--echo
--echo # -- End of Bug#18834.
+
+###########################################################################
+
+--echo
+--echo # --
+--echo # -- Bug#34274: Invalid handling of 'DEFAULT 0' for YEAR data type.
+--echo # --
+--echo
+
+--disable_warnings
+DROP TABLE IF EXISTS t1;
+--enable_warnings
+
+--echo
+CREATE TABLE t1(c1 YEAR DEFAULT 2008, c2 YEAR DEFAULT 0);
+
+--echo
+SHOW CREATE TABLE t1;
+
+--echo
+INSERT INTO t1 VALUES();
+
+--echo
+SELECT * FROM t1;
+
+--echo
+ALTER TABLE t1 MODIFY c1 YEAR DEFAULT 0;
+
+--echo
+SHOW CREATE TABLE t1;
+
--echo
+INSERT INTO t1 VALUES();
+--echo
+SELECT * FROM t1;
+
+--echo
+DROP TABLE t1;
+
+--echo
+--echo # -- End of Bug#34274
+
+###########################################################################
+
+--echo
--echo End of 5.1 tests
diff -Nrup a/sql/unireg.cc b/sql/unireg.cc
--- a/sql/unireg.cc 2008-01-19 22:32:45 +03:00
+++ b/sql/unireg.cc 2008-03-20 11:06:58 +03:00
@@ -979,9 +979,7 @@ static bool make_empty_rec(THD *thd, Fil
type= (Field::utype) MTYP_TYPENR(field->unireg_check);
- if (field->def &&
- (regfield->real_type() != MYSQL_TYPE_YEAR ||
- field->def->val_int() != 0))
+ if (field->def)
{
int res= field->def->save_in_field(regfield, 1);
/* If not ok or warning of level 'note' */
| Thread |
|---|
| • bk commit into 5.1 tree (anozdrin:1.2566) BUG#34274 | Alexander Nozdrin | 20 Mar |