From: Date: June 30 2006 4:14pm Subject: bk commit into 5.0 tree (kroki:1.2216) BUG#17226 List-Archive: http://lists.mysql.com/commits/8558 X-Bug: 17226 Message-Id: <200606301414.k5UEETNx009905@moonlight.intranet> Below is the list of changes that have just been committed into a local 5.0 repository of tomash. When tomash does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet 1.2216 06/06/30 18:14:22 kroki@stripped +3 -0 Bug#17226: Variable set in cursor on first iteration is assigned second iterations value During assignment to the BLOB variable in routine body the value wasn't copied. sql/field_conv.cc 1.56 06/06/30 18:14:16 kroki@stripped +8 -3 Honor copy_blobs flag. mysql-test/t/sp-vars.test 1.3 06/06/30 18:14:16 kroki@stripped +36 -0 Add test case for bug#17226. mysql-test/r/sp-vars.result 1.3 06/06/30 18:14:16 kroki@stripped +15 -0 Add result for bug#17226. # This is a BitKeeper patch. What follows are the unified diffs for the # set of deltas contained in the patch. The rest of the patch, the part # that BitKeeper cares about, is below these diffs. # User: kroki # Host: moonlight.intranet # Root: /home/tomash/src/mysql_ab/mysql-5.0-bug17226 --- 1.55/sql/field_conv.cc 2006-05-10 23:16:27 +04:00 +++ 1.56/sql/field_conv.cc 2006-06-30 18:14:16 +04:00 @@ -675,9 +675,14 @@ { // Be sure the value is stored Field_blob *blob=(Field_blob*) to; from->val_str(&blob->value); - if (!blob->value.is_alloced() && - from->real_type() != MYSQL_TYPE_STRING && - from->real_type() != MYSQL_TYPE_VARCHAR) + /* + Copy value if copy_blobs is set, or source is not a string and + we have a pointer to its internal string conversion buffer. + */ + if (to->table->copy_blobs || + (!blob->value.is_alloced() && + from->real_type() != MYSQL_TYPE_STRING && + from->real_type() != MYSQL_TYPE_VARCHAR)) blob->value.copy(); blob->store(blob->value.ptr(),blob->value.length(),from->charset()); return; --- 1.2/mysql-test/r/sp-vars.result 2006-05-12 20:58:48 +04:00 +++ 1.3/mysql-test/r/sp-vars.result 2006-06-30 18:14:16 +04:00 @@ -1075,3 +1075,18 @@ f1() abc DROP FUNCTION f1; +DROP PROCEDURE IF EXISTS p1; +CREATE PROCEDURE p1() +BEGIN +DECLARE v_char VARCHAR(255); +DECLARE v_text TEXT DEFAULT ''; +SET v_char = 'abc'; +SET v_text = v_char; +SET v_char = 'def'; +SET v_text = concat(v_text, '|', v_char); +SELECT v_text; +END| +CALL p1(); +v_text +abc|def +DROP PROCEDURE p1; --- 1.2/mysql-test/t/sp-vars.test 2005-12-07 22:04:52 +03:00 +++ 1.3/mysql-test/t/sp-vars.test 2006-06-30 18:14:16 +04:00 @@ -1271,3 +1271,39 @@ # DROP FUNCTION f1; + + +# +# Bug#17226: Variable set in cursor on first iteration is assigned +# second iterations value +# +# The problem was in incorrect handling of local variables of type +# TEXT (BLOB). +# +--disable_warnings +DROP PROCEDURE IF EXISTS p1; +--enable_warnings + +delimiter |; +CREATE PROCEDURE p1() +BEGIN + DECLARE v_char VARCHAR(255); + DECLARE v_text TEXT DEFAULT ''; + + SET v_char = 'abc'; + + SET v_text = v_char; + + SET v_char = 'def'; + + SET v_text = concat(v_text, '|', v_char); + + SELECT v_text; +END| +delimiter ;| + +CALL p1(); + +DROP PROCEDURE p1; + +# End of 5.0 tests.