diff options
-rw-r--r-- | mysql-test/r/group_by.result | 9 | ||||
-rw-r--r-- | mysql-test/t/group_by.test | 15 | ||||
-rw-r--r-- | sql/field.h | 2 |
3 files changed, 25 insertions, 1 deletions
diff --git a/mysql-test/r/group_by.result b/mysql-test/r/group_by.result index ee4b6a31f2f..e279fca2a9d 100644 --- a/mysql-test/r/group_by.result +++ b/mysql-test/r/group_by.result @@ -732,3 +732,12 @@ SELECT DISTINCT a, b FROM t1 GROUP BY 'const'; a b 1 2 DROP TABLE t1; +CREATE TABLE t1 (id INT, dt DATETIME); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; +f id +20050501123000 1 +DROP TABLE t1; diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index f9d113a9c50..382580cbd4e 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -543,7 +543,7 @@ SELECT hostname, COUNT(DISTINCT user_id) as no FROM t1 DROP TABLE t1; # -# Test for bug #8614: GROUP BY 'const with DISTINCT +# Test for bug #8614: GROUP BY 'const' with DISTINCT # CREATE TABLE t1 (a int, b int); @@ -552,3 +552,16 @@ SELECT a, b FROM t1 GROUP BY 'const'; SELECT DISTINCT a, b FROM t1 GROUP BY 'const'; DROP TABLE t1; + +# +# Test for bug #11385: GROUP BY for datetime converted to decimals +# + +CREATE TABLE t1 (id INT, dt DATETIME); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +INSERT INTO t1 VALUES ( 1, '2005-05-01 12:30:00' ); +SELECT dt DIV 1 AS f, id FROM t1 GROUP BY f; + +DROP TABLE t1; diff --git a/sql/field.h b/sql/field.h index 1d7669d540d..ba963418c7a 100644 --- a/sql/field.h +++ b/sql/field.h @@ -25,6 +25,7 @@ #endif #define NOT_FIXED_DEC 31 +#define DATETIME_DEC 6 class Send_field; class Protocol; @@ -861,6 +862,7 @@ public: enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; } #endif enum Item_result cmp_type () const { return INT_RESULT; } + uint decimals() const { return DATETIME_DEC; } int store(const char *to,uint length,CHARSET_INFO *charset); int store(double nr); int store(longlong nr); |