diff options
author | unknown <mhansson/martin@linux-st28.site> | 2007-12-11 20:15:03 +0100 |
---|---|---|
committer | unknown <mhansson/martin@linux-st28.site> | 2007-12-11 20:15:03 +0100 |
commit | 8870d01554bd507136eebe5d7e6fbd640487611f (patch) | |
tree | 9615a0eaca93ca19b59f1a93f0a77b7875a88468 /mysql-test/t/union.test | |
parent | a48ed6c99b7f63d2724d8d385faa4d6e2fa048c5 (diff) | |
download | mariadb-git-8870d01554bd507136eebe5d7e6fbd640487611f.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.
mysql-test/r/union.result:
Bug#32848: Test result
mysql-test/t/union.test:
Bug#32848: Test case
sql/field.cc:
Bug#32848: Initialization of new field
sql/field.h:
Bug#32848: New member to record when a field was created from a NULL value.
sql/item.cc:
Bug#32848:
A field created from a NULL value will submit NULL as type to the
type coercion procedure.
If Item_type_holder has not inferred the correct type after processing all
SELECTs in a UNION, a string field is created.
sql/sql_select.cc:
Bug#32848: Recording when a field is created from a NULL value.
Diffstat (limited to 'mysql-test/t/union.test')
-rw-r--r-- | mysql-test/t/union.test | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 22f09466b1c..84616aa281d 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -877,4 +877,28 @@ DROP TABLE t1; select @var; --error 1172 (select 2) union (select 1 into @var); + +# +# Bug#32848: Data type conversion bug in union subselects in MySQL 5.0.38 +# +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; + +CREATE TABLE t3 SELECT a FROM t1 UNION SELECT * FROM (SELECT NULL) a; +DESC t3; + +CREATE TABLE t4 SELECT NULL; +DESC t4; + +CREATE TABLE t5 SELECT NULL UNION SELECT NULL; +DESC t5; + +CREATE TABLE t6 +SELECT * FROM (SELECT * FROM (SELECT NULL)a) b UNION SELECT a FROM t1; +DESC t6; + +DROP TABLE t1, t2, t3, t4, t5, t6; --echo End of 5.0 tests |