summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_concat.test
diff options
context:
space:
mode:
authorevgen@moonbone.local <>2006-05-26 01:24:14 +0400
committerevgen@moonbone.local <>2006-05-26 01:24:14 +0400
commit40ea30253f2a5a1681d314d73a42a054f6a6a33d (patch)
tree6e1b9eb367edcd90dca823ba0b7d3ad11335e93b /mysql-test/t/func_concat.test
parentcc1dc76c666f3022132d5673eef8ee79c92f219d (diff)
downloadmariadb-git-40ea30253f2a5a1681d314d73a42a054f6a6a33d.tar.gz
Fixed bug#16716: subselect in concat() may lead to a wrong result.
The Item_func_concat::val_str() function tries to make as less re-allocations as possible. This results in appending strings returned by 2nd and next arguments to the string returned by 1st argument if the buffer for the first argument has enough free space. A constant subselect is evaluated only once and its result is stored in an Item_cache_str. In the case when the first argument of the concat() function is such a subselect Item_cache_str returns the stored value and Item_func_concat::val_str() append values of other arguments to it. But for the next row the value in the Item_cache_str isn't restored because the subselect is a constant one and it isn't evaluated second time. This results in appending string values of 2nd and next arguments to the result of the previous Item_func_concat::val_str() call. The Item_func_concat::val_str() function now checks whether the first argument is a constant one and if so it doesn't append values of 2nd and next arguments to the string value returned by it.
Diffstat (limited to 'mysql-test/t/func_concat.test')
-rw-r--r--mysql-test/t/func_concat.test7
1 files changed, 7 insertions, 0 deletions
diff --git a/mysql-test/t/func_concat.test b/mysql-test/t/func_concat.test
index 69ce10c83c9..f546a25f647 100644
--- a/mysql-test/t/func_concat.test
+++ b/mysql-test/t/func_concat.test
@@ -50,4 +50,11 @@ select 'a' union select concat('a', -0);
--replace_result 'a-0.0' good 'a0.0' good
select 'a' union select concat('a', -0.0);
+#
+# Bug#16716: subselect in concat() may lead to a wrong result
+#
+select concat((select x from (select 'a' as x) as t1 ),
+ (select y from (select 'b' as y) as t2 )) from (select 1 union select 2 )
+ as t3;
+
# End of 4.1 tests