summaryrefslogtreecommitdiff
path: root/mysql-test/r
diff options
context:
space:
mode:
authorunknown <evgen@moonbone.local>2006-03-10 13:53:00 +0300
committerunknown <evgen@moonbone.local>2006-03-10 13:53:00 +0300
commit50c8c206fca3ea3b7ca6978ba1fe283f9777db4d (patch)
tree6c05e6aa6a49c9c2619900213286e323e74e1da4 /mysql-test/r
parent58bf749f439e7eb828206b3d39da42372c7b178b (diff)
downloadmariadb-git-50c8c206fca3ea3b7ca6978ba1fe283f9777db4d.tar.gz
Fixed bug#13575: SP funcs in select with distinct/group and order by can
produce wrong data By default Item_sp_func::val_str() returns string from it's result_field internal buffer. When grouping is present Item_copy_string is used to store SP function result, but it doesn't additionally buffer the result. When the next record is read, internal buffer is overwritten, due to this Item_copy_string::val_str() will have wrong data. Thus producing weird query result. The Item_func_sp::val_str() now makes a copy of returned value to prevent occasional corruption. mysql-test/t/sp.test: Added test case for bug#13575: SP funcs in select with distinct/group and order by can produce wrong data mysql-test/r/sp.result: Added test case for bug#13575: SP funcs in select with distinct/group and order by can produce wrong data sql/item_func.h: Fixed bug#13575: SP funcs in select with distinct/group and order by can produce wrong data The Item_func_sp::val_str() now makes a copy of returned value to prevent occasinal corruption.
Diffstat (limited to 'mysql-test/r')
-rw-r--r--mysql-test/r/sp.result16
1 files changed, 16 insertions, 0 deletions
diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result
index 45e8e0ce55a..fd09e9c8e94 100644
--- a/mysql-test/r/sp.result
+++ b/mysql-test/r/sp.result
@@ -4786,4 +4786,20 @@ i
0
drop table t3|
drop procedure bug16887|
+create table t3 (f1 int, f2 varchar(3), primary key(f1)) engine=innodb|
+insert into t3 values (1,'aaa'),(2,'bbb'),(3,'ccc')|
+CREATE FUNCTION bug13575 ( p1 integer )
+returns varchar(3)
+BEGIN
+DECLARE v1 VARCHAR(10) DEFAULT null;
+SELECT f2 INTO v1 FROM t3 WHERE f1 = p1;
+RETURN v1;
+END|
+select distinct f1, bug13575(f1) from t3 order by f1|
+f1 bug13575(f1)
+1 aaa
+2 bbb
+3 ccc
+drop function bug13575;
+drop table t3|
drop table t1,t2;