1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-16930 Crash when VALUES in derived table contains expressions

This patch always provides columns of the temporary table used for
materialization of a table value constructor with some names.
Before this patch these names were always borrowed from the items
of the first row of the table value constructor. When this row
contained expressions and expressions were not named then it could cause
different kinds of problems. In particular if the TVC is used as the
specification of a derived table this could cause a crash.
The names given to the expressions used in a TVC are the same as those
given to the columns of the result set from the corresponding SELECT.
This commit is contained in:
Igor Babaev
2018-08-21 12:01:25 -07:00
parent a1fd25c22b
commit c43d11b96e
4 changed files with 138 additions and 2 deletions

View File

@@ -2154,3 +2154,38 @@ id select_type table type possible_keys key key_len ref rows Extra
3 UNION t1 ALL NULL NULL NULL NULL 3
NULL UNION RESULT <union2,3> ALL NULL NULL NULL NULL NULL
drop table t1;
#
# MDEV-16930: expression in the first row of TVC specifying derived table
#
SELECT 1 + 1, 2, "abc";
1 + 1 2 abc
2 2 abc
SELECT * FROM (SELECT 1 + 1, 2, "abc") t;
1 + 1 2 abc
2 2 abc
WITH cte AS (SELECT 1 + 1, 2, "abc") SELECT * FROM cte;
1 + 1 2 abc
2 2 abc
SELECT 1 + 1, 2, "abc" UNION SELECT 3+4, 3, "abc";
1 + 1 2 abc
2 2 abc
7 3 abc
CREATE VIEW v1 AS SELECT 1 + 1, 2, "abc";
SELECT * FROM v1;
1 + 1 2 abc
2 2 abc
DROP VIEW v1;
VALUES(1 + 1,2,"abc");
1 + 1 2 abc
2 2 abc
SELECT * FROM (VALUES(1 + 1,2,"abc")) t;
1 + 1 2 abc
2 2 abc
PREPARE stmt FROM "SELECT * FROM (VALUES(1 + 1,2,'abc')) t";
EXECUTE stmt;
1 + 1 2 abc
2 2 abc
EXECUTE stmt;
1 + 1 2 abc
2 2 abc
DEALLOCATE PREPARE stmt;