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.
For numeric constants we only need to add, since the parser doesn't produce
negative numbers.
For strings we only add (we actually could substract 1 if given string is a constant
and it has '-number' form but we're not doing that because
* we set max_length bigger then necessary in other cases as well.
* the current solution is simpler and safer (bigger max_length is better then cutting out)
mysql-test/r/func_concat.result:
Test for BUG#6825
mysql-test/r/metadata.result:
Ajusted results according to fix of bug BUG#6825:length(-1) = 2 , not 1
mysql-test/t/func_concat.test:
Test for BUG#6825
Fixed bug in new code for regexp LIKE NULL
BUILD/SETUP.sh:
Fixes for gcc 3.1
BUILD/compile-solaris-sparc-debug:
Fixes for gcc 3.1
BUILD/compile-solaris-sparc-purify:
Fixes for gcc 3.1
BUILD/compile-solaris-sparc:
Fixes for gcc 3.1
Docs/manual.texi:
Fixed typo
include/violite.h:
Fixes for gcc 3.1
mysql-test/r/func_concat.result:
Updated test results
sql/item_cmpfunc.cc:
Fixed bug in new code for regexp LIKE NULL
Update of glibc patch from MySQL 4.0
Docs/glibc-2.2.5.patch:
Update of patch from MySQL 4.0
Docs/manual.texi:
ChangeLog
sql/item_strfunc.cc:
Fix bug in CONCAT_WS()
sql/share/italian/errmsg.txt:
Update of new error messages