summaryrefslogtreecommitdiff
path: root/mysql-test/t/func_concat.test
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-05-26 01:24:14 +0400
committerunknown <evgen@moonbone.local>2006-05-26 01:24:14 +0400
commit1991a87d831bb48b31989c622e35acda11df7fef (patch)
tree6e1b9eb367edcd90dca823ba0b7d3ad11335e93b /mysql-test/t/func_concat.test
parent625e582481499ee62cc78165584980c7099a33cb (diff)
downloadmariadb-git-1991a87d831bb48b31989c622e35acda11df7fef.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. mysql-test/t/func_concat.test: Added test case for bug#16716: subselect in concat() may lead to a wrong result. mysql-test/r/func_concat.result: Added test case for bug#16716: subselect in concat() may lead to a wrong result. sql/item_strfunc.cc: Fixed bug#16716: subselect in concat() may lead to a wrong result. 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