Commit graph

14 commits

Author SHA1 Message Date
Gleb Shchepa
e2a546aef4 Bug #40625: Concat fails on DOUBLE values in a Stored
Procedure, while DECIMAL works

Selecting of the CONCAT(...<SP variable>...) result into
a user variable may return wrong data.


Item_func_concat::val_str contains a number of memory
allocation-saving tricks. One of them concatenates
strings inplace inserting the value of one string
at the beginning of the other string. However,
this trick didn't care about strings those points
to the same data buffer: this is possible when
a CONCAT() parameter is a stored procedure variable -
Item_sp_variable::val_str() uses the intermediate
Item_sp_variable::str_value field, where it may
store a reference to an external buffer.


The Item_func_concat::val_str function has been
modified to take into account val_str functions
(such as Item_sp_variable::val_str) that return
a pointer to an internal Item member variable
that may reference to a buffer provided.


mysql-test/r/func_concat.result:
  Test case for the bug #40625.
mysql-test/t/func_concat.test:
  Test case for the bug #40625.
sql/item_strfunc.cc:
  Bug #40625: Concat fails on DOUBLE values in a Stored
              Procedure, while DECIMAL works
  
  The Item_func_concat::val_str function has been
  modified to take into account val_str functions
  (such as Item_sp_variable::val_str) that return
  a pointer to an internal Item member variable
  that may reference to a buffer provided.
2010-04-03 00:30:22 +04:00
Gleb Shchepa
71fd38e488 Bug #50096: CONCAT_WS inside procedure returning wrong data
Selecting of the CONCAT_WS(...<PS parameter>...) result into
a user variable may return wrong data.

Item_func_concat_ws::val_str contains a number of memory
allocation-saving optimization tricks. After the fix
for bug 46815 the control flow has been changed to a
branch that is commented as "This is quite uncommon!":
one of places where we are trying to concatenate
strings inplace. However, that "uncommon" place
didn't care about PS parameters, that have another
trick in Item_sp_variable::val_str(): they use the
intermediate Item_sp_variable::str_value field,
where they may store a reference to an external
argument's buffer.

The Item_func_concat_ws::val_str function has been
modified to take into account val_str functions
(such as Item_sp_variable::val_str) that return a
pointer to an internal Item member variable that
may reference to a buffer provided.


mysql-test/r/func_concat.result:
  Added test case for bug #50096.
mysql-test/t/func_concat.test:
  Added test case for bug #50096.
sql/item_strfunc.cc:
  Bug #50096: CONCAT_WS inside procedure returning wrong data
  
  The Item_func_concat_ws::val_str function has been
  modified to take into account val_str functions
  (such as Item_sp_variable::val_str) that return a
  pointer to an internal Item member variable that
  may reference to a buffer provided.
2010-01-13 08:16:36 +04:00
Ramil Kalimullin
985df4dcdc Fix for bug#44743: Join in combination with concat does not always work
bug#44766: valgrind error when using convert() in a subquery

Problem: input and output buffers may be the same 
converting a string to some charset. 
That may lead to wrong results/valgrind warnings.  

Fix: use different buffers.


mysql-test/r/cast.result:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test result.
mysql-test/r/func_concat.result:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test result.
mysql-test/t/cast.test:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test case.
mysql-test/t/func_concat.test:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - test case.
sql/item.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - comment added.
sql/item_strfunc.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - '&args[0]->str_value' used as a parameter of args[0]->val_str(),
      as 'str' may be equal to 'str_value' which we use as the output buffer
      converting strings.
sql/sql_string.cc:
  Fix for bug#44743: Join in combination with concat does not always work
          bug#44766: valgrind error when using convert() in a subquery
    - input and output buffers must NOT be the same.
2009-05-21 13:06:43 +05:00
unknown
66367aeea8 Fixed bug #36488: regexp returns false matches, concatenating
with previous rows.

The WHERE clause containing expression:
  CONCAT(empty_field1, empty_field2, ..., 'literal constant', ...)
    REGEXP 'regular expression'
may return wrong matches.

Optimization of the CONCAT function has been fixed.



mysql-test/r/func_concat.result:
  Added test case for bug #36488.
mysql-test/t/func_concat.test:
  Added test case for bug #36488.
sql/item_strfunc.cc:
  Fixed bug #36488.
  The Item_func_concat::val_str method is optimized to
  use first non-empty argument of the CONCAT function for in-place
  result accumulation. This optimization is acceptable if that
  first argument is not a constant.
  However, current implementation checks this condition only for
  the first actual argument of the CONCAT function.
  So, the Item_func_concat::val_str method can corrupt values
  of, for example, literal strings by appending random data.
  
  The Item_func_concat::val_str method has been modified to take
  into account the ability to be modified in-place for the first
  non-empty argument.
2008-05-13 20:27:46 +05:00
unknown
b2f308160b Many files:
After merge fix


mysql-test/r/func_time.result:
  After merge fix
mysql-test/r/func_concat.result:
  After merge fix
mysql-test/r/cast.result:
  After merge fix
sql/item_cmpfunc.h:
  After merge fix
sql/item_cmpfunc.cc:
  After merge fix
sql/field.cc:
  After merge fix
2006-06-15 01:48:41 +04:00
unknown
9936533be9 Manually merged
mysql-test/r/cast.result:
  Auto merged
mysql-test/t/func_time.test:
  Auto merged
sql/item_cmpfunc.h:
  Auto merged
sql/item_strfunc.cc:
  Auto merged
sql/item_timefunc.cc:
  Auto merged
sql/item_timefunc.h:
  Auto merged
sql/opt_sum.cc:
  Auto merged
sql/structs.h:
  Auto merged
2006-06-14 23:54:08 +04:00
unknown
6e80e9a4f9 Fixed bug#15962: CONCAT() in UNION may lead to a data trucation.
To calculate its max_length the CONCAT() function is simply sums max_lengths
of its arguments but when the collation of an argument differs from the 
collation of the CONCAT() max_length will be wrong. This may lead to a data
truncation when a tmp table is used, in UNIONS for example.

The Item_func_concat::fix_length_and_dec() function now recalculates the 
max_length of an argument when the mbmaxlen of the argument differs from the
mbmaxlen of the CONCAT().


mysql-test/t/func_concat.test:
  Added test case for bug#15962:CONCAT() in UNION may lead to a data trucation.
mysql-test/r/func_concat.result:
  Added test case for bug#15962:CONCAT() in UNION may lead to a data trucation.
sql/item_strfunc.cc:
  Fixed bug#15962: CONCAT() in UNION may lead to a data trucation.
  The Item_func_concat::fix_length_and_dec() function now recalculates the 
  max_length of an argument when the mbmaxlen of the argument differs from the
  mbmaxlen of the CONCAT().
2006-06-07 01:10:23 +04:00
unknown
1991a87d83 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.
2006-05-26 01:24:14 +04:00
unknown
c1f1732f37 Fix func_concat.result: allow -0.00 to be converted to string both with and without leading minus 2004-12-30 14:56:31 +03:00
unknown
665f6b6875 incorrect result fixed 2004-12-23 17:32:29 +01:00
unknown
f7193b9254 Fix for BUG#6825: When calculating Item_func_neg::max_length, add 1 for '-'.
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
2004-12-17 12:14:45 +03:00
unknown
b87892265c A fix (bug #5540: CONCAT function and 'double' type). 2004-09-15 15:13:17 +05:00
unknown
a34e76c66a Fixes for gcc 3.1
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
2002-05-21 20:35:58 +03:00
unknown
c2504d86b3 Fix bug in CONCAT_WS()
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
2002-05-17 10:50:57 +03:00