Commit adaafcf5 authored by Oleksandr Byelkin's avatar Oleksandr Byelkin

MDEV-16930: Crash when VALUES in derived table contains expressions

Give names to the value constructor columns as in SELECT-list.
parent 8716bb3b
...@@ -11,7 +11,7 @@ values (1,2), (3,4), (5.6,0); ...@@ -11,7 +11,7 @@ values (1,2), (3,4), (5.6,0);
3.0 4 3.0 4
5.6 0 5.6 0
values ("abc", "def"); values ("abc", "def");
abc def "abc" "def"
abc def abc def
# UNION that uses VALUES structure(s) # UNION that uses VALUES structure(s)
select 1,2 select 1,2
...@@ -92,7 +92,7 @@ we q ...@@ -92,7 +92,7 @@ we q
values ("ab", "cdf") values ("ab", "cdf")
union union
select "ab","cdf"; select "ab","cdf";
ab cdf "ab" "cdf"
ab cdf ab cdf
values (1,2) values (1,2)
union union
...@@ -2097,3 +2097,21 @@ v ...@@ -2097,3 +2097,21 @@ v
# #
with t as (values (),()) select 1 from t; with t as (values (),()) select 1 from t;
ERROR HY000: Row with no elements is not allowed in table value constructor in this context ERROR HY000: Row with no elements is not allowed in table value constructor in this context
#
# MDEV-16930: expression in the first row of TVC specifying derived table
#
VALUES(1+1,2);
1+1 2
2 2
SELECT * FROM (VALUES(1+1,2)) t;
1+1 2
2 2
PREPARE stmt FROM "SELECT * FROM (VALUES(1+1,2)) t";
EXECUTE stmt;
1+1 2
2 2
EXECUTE stmt;
1+1 2
2 2
DEALLOCATE PREPARE stmt;
# End of 10.3 tests
...@@ -1075,3 +1075,16 @@ DELIMITER ;| ...@@ -1075,3 +1075,16 @@ DELIMITER ;|
--error ER_EMPTY_ROW_IN_TVC --error ER_EMPTY_ROW_IN_TVC
with t as (values (),()) select 1 from t; with t as (values (),()) select 1 from t;
--echo #
--echo # MDEV-16930: expression in the first row of TVC specifying derived table
--echo #
VALUES(1+1,2);
SELECT * FROM (VALUES(1+1,2)) t;
PREPARE stmt FROM "SELECT * FROM (VALUES(1+1,2)) t";
EXECUTE stmt;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
--echo # End of 10.3 tests
...@@ -13306,15 +13306,20 @@ opt_values: ...@@ -13306,15 +13306,20 @@ opt_values:
; ;
values: values:
values ',' expr_or_default values ',' remember_name expr_or_default remember_end
{ {
if (unlikely(Lex->insert_list->push_back($3, thd->mem_root))) if (unlikely(Lex->insert_list->push_back($4, thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
// give some name in case of using in table value constuctor (TVC)
$4->set_name(thd, $3, (uint) ($5 - $3), thd->charset());
} }
| expr_or_default | remember_name expr_or_default remember_end
{ {
if (unlikely(Lex->insert_list->push_back($1, thd->mem_root))) if (unlikely(Lex->insert_list->push_back($2, thd->mem_root)))
MYSQL_YYABORT; MYSQL_YYABORT;
// give some name in case of using in table value constuctor (TVC)
$2->set_name(thd, $1, (uint) ($3 - $1), thd->charset());
} }
; ;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment