summaryrefslogtreecommitdiff
path: root/mysql-test/r/union.result
diff options
context:
space:
mode:
authormhansson/martin@linux-st28.site <>2007-12-11 20:15:03 +0100
committermhansson/martin@linux-st28.site <>2007-12-11 20:15:03 +0100
commit867a78654946c7c7ebed430b2b8437e837a0455d (patch)
tree9615a0eaca93ca19b59f1a93f0a77b7875a88468 /mysql-test/r/union.result
parent7f67efccef94449ef6c797583a2695b27a9b7376 (diff)
downloadmariadb-git-867a78654946c7c7ebed430b2b8437e837a0455d.tar.gz
Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38
There were two problems when inferring the correct field types resulting from UNION queries. - If the type is NULL for all corresponding fields in the UNION, the resulting type would be NULL, while the type is BINARY(0) if there is just a single SELECT NULL. - If one SELECT in the UNION uses a subselect, a temporary table is created to represent the subselect, and the result type defaults to a STRING type, hiding the fact that the type was unknown(just a NULL value). Fixed by remembering whenever a field was created from a NULL value and pass type NULL to the type coercion if that is the case, and creating a string field as result of UNION only if the type would otherwise be NULL.
Diffstat (limited to 'mysql-test/r/union.result')
-rw-r--r--mysql-test/r/union.result24
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result
index efdd8195fb5..0b77459e02f 100644
--- a/mysql-test/r/union.result
+++ b/mysql-test/r/union.result
@@ -1389,4 +1389,28 @@ select @var;
1
(select 2) union (select 1 into @var);
ERROR 42000: Result consisted of more than one row
+CREATE TABLE t1 (a INT);
+INSERT INTO t1 VALUES (1), (2), (3);
+CREATE TABLE t2 SELECT * FROM (SELECT NULL) a UNION SELECT a FROM t1;
+DESC t2;
+Field Type Null Key Default Extra
+NULL int(11) YES NULL
+CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a;
+DESC t3;
+Field Type Null Key Default Extra
+a int(11) YES NULL
+CREATE TABLE t4 SELECT NULL;
+DESC t4;
+Field Type Null Key Default Extra
+NULL binary(0) YES NULL
+CREATE TABLE t5 SELECT NULL UNION SELECT NULL;
+DESC t5;
+Field Type Null Key Default Extra
+NULL binary(0) YES NULL
+CREATE TABLE t6
+SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1;
+DESC t6;
+Field Type Null Key Default Extra
+NULL int(11) YES NULL
+DROP TABLE t1, t2, t3, t4, t5, t6;
End of 5.0 tests