Bug #20788 exeption when call stored proc with args in utf8
Submitted: 30 Jun 2006 7:35 Modified: 1 Jul 2006 7:02
Reporter: Saken Sultanbekov Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.0.21 OS:Windows (Win32)
Assigned to: CPU Architecture:Any

[30 Jun 2006 7:35] Saken Sultanbekov
Description:
Can't call stored procedures from PHP with mysqli library.
Cause when I use parameter that containing non latin characters,
I get exception "Data too long for column xxx at row 1".

How to repeat:
Create stored proc with character arg. For example:

'create procedure test_proc(name varchar(30))
begin
   insert into test_table values (name);
end;'

Connect from PHP with mysqli library. 
Before connect set character set to utf8.
Like this: 'set character set utf8; set names utf8;'
Try to call created procedure with argument that consist only latin chars.

For example: 'call test_proc("John");'
It's ok.

Now try to call created procedure with argument that consist non latin chars.
For example: 'call test_proc("Иван");'

You'll get exeption: "Data too long for column 'name' at row 1"

Default character set of database is utf8;

Suggested fix:
Uknown
[30 Jun 2006 9:28] Sveta Smirnova
Can you reproduce this bug using mysql command line client?
[30 Jun 2006 9:42] Sveta Smirnova
I can not repeat this using last 5.0.23 bk sourses and php 5.1.3-dev.

Please, read carefully how to handle encodings and collations here: http://dev.mysql.com/doc/refman/5.0/en/charset.html, especcially troubleshooting chapters.

Thank you for the interest in MySQL.
[1 Jul 2006 6:38] Saken Sultanbekov
this what I have in command line

Attachment: command_line.JPG (image/jpeg, text), 49.59 KiB.

[1 Jul 2006 6:52] Saken Sultanbekov
database was created by:

CREATE DATABASE `test` /*!40100 DEFAULT CHARACTER SET utf8 */

table was created with following script:

CREATE TABLE `test_table` (
  `name` varchar(20) default NULL,
  `age` int(11) default NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

and this script of stored procedure:

CREATE PROCEDURE `test_proc`(name VARCHAR(20), age INTEGER(11))
    NOT DETERMINISTIC
    SQL SECURITY DEFINER
    COMMENT ''
BEGIN
  insert into `test_table` values(name, age);
END;

possible, I must try 5.0.23 too?
[1 Jul 2006 7:02] Saken Sultanbekov
I'v reproduce this bug in command line and attaching screenshot of cmd session.

Thank you for support.