diff options
-rw-r--r-- | mysql-test/r/group_by.result | 7 | ||||
-rw-r--r-- | mysql-test/t/group_by.test | 10 | ||||
-rw-r--r-- | sql/item_timefunc.h | 6 |
3 files changed, 23 insertions, 0 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index 295663fe1d3..8287a042d60 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -757,3 +757,10 @@ SELECT n+1 AS n FROM t1 GROUP BY n; n 2 DROP TABLE t1; +create table t1 (f1 date); +insert into t1 values('2005-06-06'); +insert into t1 values('2005-06-06'); +select date(left(f1+0,8)) from t1 group by 1; +date(left(f1+0,8)) +2005-06-06 +drop table t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index c07d309005e..815da66c717 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -590,4 +590,14 @@ INSERT INTO t1 VALUES (1); SELECT n+1 AS n FROM t1 GROUP BY n; DROP TABLE t1; +# +# Bug #12266 GROUP BY expression on DATE column produces result with +# reduced length +# +create table t1 (f1 date); +insert into t1 values('2005-06-06'); +insert into t1 values('2005-06-06'); +select date(left(f1+0,8)) from t1 group by 1; +drop table t1; + # End of 4.1 tests diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 1a30b24b7ce..0df84d14bea 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -709,6 +709,12 @@ public: { return (new Field_date(maybe_null, name, t_arg, &my_charset_bin)); } + void fix_length_and_dec() + { + collation.set(&my_charset_bin); + max_length= 10; + maybe_null= 1; + } }; |