summaryrefslogtreecommitdiff
path: root/regex
diff options
context:
space:
mode:
authorNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2013-01-12 11:13:37 +0530
committerNisha Gopalakrishnan <nisha.gopalakrishnan@oracle.com>2013-01-12 11:13:37 +0530
commit3d9d0e7766d4195bbe40dbac8d85abcfe343beb0 (patch)
treea5d55ed844d1f9fd1c08f0e0cd4a6834b5eab058 /regex
parent01094a4b13095175080b073e804866621377a16e (diff)
downloadmariadb-git-3d9d0e7766d4195bbe40dbac8d85abcfe343beb0.tar.gz
BUG#11757250: REPLACE(...) INSIDE A STORED PROCEDURE.
Analysis: -------- REPLACE operation provides incorrect output when user variable is supplied as an argument and there are multiple rows on which the operation is performed. Consider the example below: SET @var='(( 00000000 ++ 00000000 ))'; SELECT REPLACE(@var, '00000000', table_name) AS a FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA='mysql'; Invalid output: +---------------------------------------+ | REPLACE(@var, '00000000', TABLE_NAME) | +---------------------------------------+ | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | ...... ...... | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | | (( columns_priv ++ columns_priv )) | +---------------------------------------+ The user argument supplied as the string to REPLACE operation is overwritten after the first iteration to '(( columns_priv ++ columns_priv ))'. The overwritten string after the first iteration is used for the subsequent REPLACE iteration. Since the pattern string is not found, it returns invalid output as mentioned above. Fix: --- If the Alloced_length is zero, realloc() and create a copy of the string which is then used for the REPLACE operation for every iteration.
Diffstat (limited to 'regex')
0 files changed, 0 insertions, 0 deletions