diff options
author | Gleb Shchepa <gshchepa@mysql.com> | 2008-10-10 15:13:12 +0500 |
---|---|---|
committer | Gleb Shchepa <gshchepa@mysql.com> | 2008-10-10 15:13:12 +0500 |
commit | 8bfbcbd98172ac936ff13ef97f2662cd6bc9a2c7 (patch) | |
tree | 2efe1de3ae86c64e7cf0f0a286c7979d507d7d64 /mysql-test/t/metadata.test | |
parent | 5a3086221d79fc1b6b2c9c2b9bdb154759649063 (diff) | |
download | mariadb-git-8bfbcbd98172ac936ff13ef97f2662cd6bc9a2c7.tar.gz |
Bug #39283: Date returned as VARBINARY to client for queries
with COALESCE and JOIN
The server returned to a client the VARBINARY column type
instead of the DATE type for a result of the COALESCE,
IFNULL, IF, CASE, GREATEST or LEAST functions if that result
was filesorted in an anonymous temporary table during
the query execution.
For example:
SELECT COALESCE(t1.date1, t2.date2) AS result
FROM t1 JOIN t2 ON t1.id = t2.id ORDER BY result;
To create a column of various date/time types in a
temporary table the create_tmp_field_from_item() function
uses the Item::tmp_table_field_from_field_type() method
call. However, fields of the MYSQL_TYPE_NEWDATE type were
missed there, and the VARBINARY columns were created
by default.
Necessary condition has been added.
mysql-test/r/metadata.result:
Added test case for bug #39283.
mysql-test/t/metadata.test:
Added test case for bug #39283.
sql/sql_select.cc:
Bug #39283: Date returned as VARBINARY to client for queries
with COALESCE and JOIN
To create a column of various date/time types in a
temporary table the create_tmp_field_from_item() function
uses the Item::tmp_table_field_from_field_type() method
call. However, fields of the MYSQL_TYPE_NEWDATE type were
missed there, and the VARBINARY columns were created
by default.
Necessary condition has been added.
Diffstat (limited to 'mysql-test/t/metadata.test')
-rw-r--r-- | mysql-test/t/metadata.test | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/mysql-test/t/metadata.test b/mysql-test/t/metadata.test index 65c062399b7..a10767579fb 100644 --- a/mysql-test/t/metadata.test +++ b/mysql-test/t/metadata.test @@ -112,4 +112,21 @@ SELECT v1.c1, v2.c2 FROM v1 JOIN v2 ON c1=c2 GROUP BY v1.c1 ORDER BY v2.c2; DROP VIEW v1,v2; DROP TABLE t1,t2; +# +# Bug #39283: Date returned as VARBINARY to client for queries +# with COALESCE and JOIN +# + +CREATE TABLE t1 (i INT, d DATE); +INSERT INTO t1 VALUES (1, '2008-01-01'), (2, '2008-01-02'), (3, '2008-01-03'); + +--enable_metadata +--sorted_result +SELECT COALESCE(d, d), IFNULL(d, d), IF(i, d, d), + CASE i WHEN i THEN d ELSE d END, GREATEST(d, d), LEAST(d, d) + FROM t1 ORDER BY RAND(); # force filesort +--disable_metadata + +DROP TABLE t1; + --echo End of 5.0 tests |