Bug #20778 strange characters in warning message 1366 when called in SP
Submitted: 29 Jun 2006 14:56 Modified: 4 Oct 2006 2:10
Reporter: Carsten Segieth Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S1 (Critical)
Version:5.0.23-bk OS:Linux (Linux (Suse 9.3))
Assigned to: Chad MILLER

[29 Jun 2006 14:56] Carsten Segieth
Description:
Set to P1 / S1 as the problem was seen in the funcs_1 test suite:

Calling the following procedure shows strange characters in the warning message:

CREATE PROCEDURE sp1()
BEGIN
 declare x numeric unsigned zerofill;
 SELECT f1 into x from t2 limit 1;
END//
delimiter ;//

CALL sp1();
Warnings:
Warning        1366    Incorrect decimal value: 'a`                  a`                       !?x???a`                       x???ar/tmp' for column 'x' at row 1

The content and the size of the 'value' in the warning message changes from the number of columns of the table 't2'.

How to repeat:
include the attached file into an existing test 
or 
run "./mysql-test-run.pl --suite=funcs_1 --do-test=innodb_storedproc" and check the .result file starting line:12941

Suggested fix:
fix the difference ...
[29 Jun 2006 14:58] Carsten Segieth
test file with table and procedure definition

Attachment: cs_095.inc (application/octet-stream, text), 1.72 KiB.

[27 Sep 2006 22:08] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/12667

ChangeSet@1.2297, 2006-09-27 18:10:41-04:00, cmiller@zippy.cornsilk.net +3 -0
  Bug #20778: strange characters in warning message 1366 when called in SP
  
  The function receives an exactly-sized buffer (not a C NUL-terminated string)
  and passes it into a printf function to be interpreted with "%s".
  
  Instead, create an intermediate String object, and copy the data into it, 
  and pass in a pointer to the String's NUL-terminated buffer.
[27 Sep 2006 23:24] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/12670

ChangeSet@1.2276, 2006-09-27 19:26:25-04:00, cmiller@zippy.cornsilk.net +3 -0
  Bug #20778: strange characters in warning message 1366 when called in SP
  
  The function receives an exactly-sized buffer (not a C NUL-terminated string)
  and passes it into a printf function to be interpreted with "%s".
  
  Instead, create an intermediate String object, and copy the data into it, 
  and pass in a pointer to the String's NUL-terminated buffer.
[3 Oct 2006 20:02] Chad MILLER
Available in 5.0.26.
[3 Oct 2006 20:09] Chad MILLER
Available in 5.1.12-beta.
[4 Oct 2006 2:10] Paul Dubois
Noted in 5.0.26, 5.1.12 changelog.

Within stored routines, some error messages were printed incorrectly.
A non-null-terminated string was passed to a message-printing routine
that expected a null-terminated string.