Commit 05826af9 authored by pem@mysql.com's avatar pem@mysql.com

Fixed BUG#17015: Routine name truncation not an error

  The name length was checked "the old way", not taking charsets into account,
  when creating a stored routine.
  Fixing this enforces the real limit (64 characters) again, and no truncation
  is possible.
parent d67b0a6b
...@@ -647,10 +647,18 @@ flush tables; ...@@ -647,10 +647,18 @@ flush tables;
return 5; return 5;
end| end|
ERROR 0A000: FLUSH is not allowed in stored function or trigger ERROR 0A000: FLUSH is not allowed in stored function or trigger
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() create procedure bug9529_901234567890123456789012345678901234567890123456789012345()
begin begin
end| end|
ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' is too long ERROR 42000: Identifier name 'bug9529_901234567890123456789012345678901234567890123456789012345' is too long
drop procedure if exists bug17015_0123456789012345678901234567890123456789012345678901234|
create procedure bug17015_0123456789012345678901234567890123456789012345678901234()
begin
end|
show procedure status like 'bug17015%'|
Db Name Type Definer Modified Created Security_type Comment
test bug17015_0123456789012345678901234567890123456789012345678901234 PROCEDURE root@localhost 0000-00-00 00:00:00 0000-00-00 00:00:00 DEFINER
drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|
drop procedure if exists bug10969| drop procedure if exists bug10969|
create procedure bug10969() create procedure bug10969()
begin begin
......
...@@ -926,12 +926,26 @@ end| ...@@ -926,12 +926,26 @@ end|
# #
# BUG#9529: Stored Procedures: No Warning on truncation of procedure name # BUG#9529: Stored Procedures: No Warning on truncation of procedure name
# during creation. # during creation.
# Note: When using utf8 for mysql.proc, this limit is much higher than before # BUG#17015: Routine name truncation not an error
# When we started using utf8 for mysql.proc, this limit appeared
# to be higher, but in reality the names were truncated.
--error ER_TOO_LONG_IDENT --error ER_TOO_LONG_IDENT
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() create procedure bug9529_901234567890123456789012345678901234567890123456789012345()
begin begin
end| end|
--disable_warnings
drop procedure if exists bug17015_0123456789012345678901234567890123456789012345678901234|
--enable_warnings
# Check the upper limit, just to make sure.
create procedure bug17015_0123456789012345678901234567890123456789012345678901234()
begin
end|
--replace_column 5 '0000-00-00 00:00:00' 6 '0000-00-00 00:00:00'
show procedure status like 'bug17015%'|
drop procedure bug17015_0123456789012345678901234567890123456789012345678901234|
# #
# BUG#10969: Stored procedures: crash if default() function # BUG#10969: Stored procedures: crash if default() function
...@@ -1721,4 +1735,3 @@ create aggregate function bug16896() returns int return 1; ...@@ -1721,4 +1735,3 @@ create aggregate function bug16896() returns int return 1;
#drop procedure if exists bugNNNN| #drop procedure if exists bugNNNN|
#--enable_warnings #--enable_warnings
#create procedure bugNNNN... #create procedure bugNNNN...
...@@ -508,7 +508,12 @@ db_create_routine(THD *thd, int type, sp_head *sp) ...@@ -508,7 +508,12 @@ db_create_routine(THD *thd, int type, sp_head *sp)
ret= SP_GET_FIELD_FAILED; ret= SP_GET_FIELD_FAILED;
goto done; goto done;
} }
if (sp->m_name.length > table->field[MYSQL_PROC_FIELD_NAME]->field_length)
if ((system_charset_info->cset->numchars(system_charset_info,
sp->m_name.str,
sp->m_name.str+sp->m_name.length) *
table->field[MYSQL_PROC_FIELD_NAME]->charset()->mbmaxlen) >
table->field[MYSQL_PROC_FIELD_NAME]->field_length)
{ {
ret= SP_BAD_IDENTIFIER; ret= SP_BAD_IDENTIFIER;
goto done; goto done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment