summaryrefslogtreecommitdiff
path: root/sql/item_func.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/item_func.h')
-rw-r--r--sql/item_func.h14
1 files changed, 13 insertions, 1 deletions
diff --git a/sql/item_func.h b/sql/item_func.h
index d8fa45fb9c0..ccbbbab1df4 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -1421,9 +1421,21 @@ public:
String *val_str(String *str)
{
+ String buf;
+ char buff[20];
+ buf.set(buff, 20, str->charset());
+ buf.length(0);
if (execute(&result_field))
return NULL;
- return result_field->val_str(str);
+ /*
+ result_field will set buf pointing to internal buffer
+ of the resul_field. Due to this it will change any time
+ when SP is executed. In order to prevent occasional
+ corruption of returned value, we make here a copy.
+ */
+ result_field->val_str(&buf);
+ str->copy(buf);
+ return str;
}
virtual bool change_context_processor(byte *cntx)