-
-
Notifications
You must be signed in to change notification settings - Fork 238
Closed
Labels
Description
Using UNION ALL with SELECT-Statements containing binary (BLOB-Type) columns yields the expected result. However, if one SELECT specifies a NULL or empty bianry value (UNHEX("")), The resulting column will contain NULL for all values.
That is, two tables:
CREATE TABLE a(name VARCHAR(255), data BLOB);
CREATE TABLE b(name VARCHAR(255), data BLOB);
INSERT INTO a VALEUS ("a-data", UNHEX("deadbeef"));
INSERT INTO b VALEUS ("b-nodata", NULL);
SELECT name, data FROM a
UNION ALL
SELECT name, data FROM b;
/* Correct, yields
a-data | <binary>
b-nodata | NULL
*/
SELECT name, data FROM a
UNION ALL
SELECT name, NULL FROM b;
/* Incorrect, yields
a-data | NULL
b-nodata | NULL
*/
SELECT name, data FROM a
UNION ALL
SELECT name, UNHEX("") FROM b;
/* Incorrect, yields
a-data | NULL
b-nodata |
*/A live example can be viewed at aschnappauf/view-union-blob-bug at DoltHub. There are three views demonstrating the bug. All three views should yield the same result for rows of tablename and tablename2