Bug #36790 | Inappropriate 1406 error generated by stored procedure on INSERT | ||
---|---|---|---|
Submitted: | 18 May 2008 23:26 | Modified: | 19 May 2008 3:34 |
Reporter: | David Wyllie | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Stored Routines | Severity: | S2 (Serious) |
Version: | 5.1.24 | OS: | Windows |
Assigned to: | CPU Architecture: | Any |
[18 May 2008 23:26]
David Wyllie
[19 May 2008 3:34]
Valeriy Kravchuk
Thank you for a problem report. This is not a bug though. CHAR in MySQL's SP declaration is interpreted as CHAR(1). If you declare procedure with var1 CHAR(16), it will just work: C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot test -P3308 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.0.60-enterprise-gpl-nt-log MySQL Enterprise Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> exit Bye C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot -proot test -P3310 ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: Y ES) C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -uroot test -P3310 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.24-rc-community MySQL Community Server (GPL) Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> DROP TABLE IF EXISTS `test`.`testtable`; Query OK, 0 rows affected, 1 warning (0.02 sec) mysql> CREATE TABLE `test`.`testtable` ( -> `testfield` char(16) NOT NULL DEFAULT "default_value" -> ) ENGINE=InnoDB; Query OK, 0 rows affected (0.22 sec) mysql> delimiter // mysql> create PROCEDURE `testproc`(IN var1 CHAR) -> BEGIN -> -> # insert variables into the testtable table. -> -> INSERT INTO testtable (testfield) VALUES (var1); -> -> END// Query OK, 0 rows affected (0.41 sec) mysql> delimiter ; mysql> INSERT INTO test.testtable (testfield) VALUES ("1"); Query OK, 1 row affected (0.09 sec) mysql> call testproc("1"); Query OK, 1 row affected (0.08 sec) mysql> call testproc("11"); ERROR 1406 (22001): Data too long for column 'var1' at row 1 mysql> DROP PROCEDURE IF EXISTS `test`.`testproc`; Query OK, 0 rows affected (0.41 sec) mysql> delimiter // mysql> create PROCEDURE `testproc`(IN var1 CHAR(16)) -> BEGIN -> # insert variables into the testtable table. -> INSERT INTO testtable (testfield) VALUES (var1); -> END// Query OK, 0 rows affected (0.00 sec) mysql> delimiter ; mysql> call testproc("11"); Query OK, 1 row affected (0.02 sec)