Bug #17015 Routine name truncation not an error
Submitted: 1 Feb 2006 17:29 Modified: 11 Apr 2006 15:31
Reporter: Andrey Hristov
Status: Closed
Category:Server: SP Severity:S3 (Non-critical)
Version:5.1.6-alpha-debug/5.0.19 BK OS:Linux (SuSE 9.3)
Assigned to: Bugs System Target Version:

[1 Feb 2006 17:29] Andrey Hristov
Description:
When creating a SP with very long name (>64 chars latin1) the creation is successful but
the name is truncated on the hard disk. The SP code misuses the length of a field,
because it's in bytes, but because the len of the name field is 64 and the code page is
utf8, the max_len is 64*3. So if a procedure name is 100chars latin1, this will go
through.

mysql> create procedure
FuncCountVariableInTableItemResults_FuncCountVariableInTableItemResults_FuncCountVariableInTableItemResults()
begin end;
Query OK, 0 rows affected (0.00 sec)

mysql> show procedure status\G
*************************** 1. row ***************************
           Db: test
         Name: FuncCountVariableInTableItemResults_FuncCountVariableInTableItem
         Type: PROCEDURE
      Definer: root@localhost
     Modified: 2006-02-01 17:22:57
      Created: 2006-02-01 17:22:57
Security_type: DEFINER
      Comment:
1 row in set (0.00 sec)
mysql> select db, length(name) from mysql.proc;
+------+--------------+
| db   | length(name) |
+------+--------------+
| test |           64 |
+------+--------------+
1 row in set (0.01 sec)

How to repeat:
create procedure
FuncCountVariableInTableItemResults_FuncCountVariableInTableItemResults_FuncCountVariableInTableItemResults()
begin end;
select db, name, length(name) from mysql.proc;
[16 Feb 2006 13:42] 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/2726
[28 Mar 2006 13:22] Konstantin Osipov
Approved by email.
[28 Mar 2006 15:06] 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/4237
[29 Mar 2006 20:10] Konstantin Osipov
Pushed into 5.0.20, merged into 5.1.8
[30 Mar 2006 11:23] Per-Erik Martin
Before this fix, it appeared that routine names longer than 64 characters were possible,
but they were in fact silently truncated. The 64 character limit is now properly
enforced.
[11 Apr 2006 15:31] Paul DuBois
Noted in 5.0.20, 5.1.8 changelogs.

Stored routine names longer than 64 characters were silently
truncated. Now the limit is properly enforced and an error
occurs. (Bug #17015)