Commit accdff51 authored by unknown's avatar unknown

Fixed BUG#11365: Stored Procedure: Crash on Procedure operation

  Two separate problems. A key buffer was too small in sp.cc for multi-byte
  fields, and the creation and fixing of mysql.proc in the scripts hadn't been
  updated with the correct character sets and collations (like the other
  system tables had).
  Note: No special test case, as the use of utf8 for mysql.proc will make
  any existing crash (if the buffer overrrun wasn't fixed).


mysql-test/r/sp-error.result:
  Updated test case for too long SP names (as the limit has increased with the use of utf8).
mysql-test/t/sp-error.test:
  Updated test case for too long SP names (as the limit has increased with the use of utf8).
scripts/mysql_create_system_tables.sh:
  Use utf8 for mysql.proc, just like for the other system tables.
scripts/mysql_fix_privilege_tables.sql:
  Use utf8 for mysql.proc, just like for the other system tables.
  (Some tabs also replaced by space)
sql/sp.cc:
  Use a larger key buffer for stored procedures to avoid stack overrun with multi-byte keys.
parent 7672befa
...@@ -604,10 +604,10 @@ flush tables; ...@@ -604,10 +604,10 @@ flush tables;
return 5; return 5;
end| end|
ERROR 0A000: FLUSH is not allowed in stored procedures ERROR 0A000: FLUSH is not allowed in stored procedures
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123()
begin begin
end| end|
ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' is too long
drop procedure if exists bug10969| drop procedure if exists bug10969|
create procedure bug10969() create procedure bug10969()
begin begin
......
...@@ -874,9 +874,9 @@ end| ...@@ -874,9 +874,9 @@ 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
--error ER_TOO_LONG_IDENT --error ER_TOO_LONG_IDENT
create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123()
begin begin
end| end|
......
...@@ -669,7 +669,7 @@ fi ...@@ -669,7 +669,7 @@ fi
if test ! -f $mdata/proc.frm if test ! -f $mdata/proc.frm
then then
c_p="$c_p CREATE TABLE proc (" c_p="$c_p CREATE TABLE proc ("
c_p="$c_p db char(64) binary DEFAULT '' NOT NULL," c_p="$c_p db char(64) collate utf8_bin DEFAULT '' NOT NULL,"
c_p="$c_p name char(64) DEFAULT '' NOT NULL," c_p="$c_p name char(64) DEFAULT '' NOT NULL,"
c_p="$c_p type enum('FUNCTION','PROCEDURE') NOT NULL," c_p="$c_p type enum('FUNCTION','PROCEDURE') NOT NULL,"
c_p="$c_p specific_name char(64) DEFAULT '' NOT NULL," c_p="$c_p specific_name char(64) DEFAULT '' NOT NULL,"
...@@ -684,7 +684,7 @@ then ...@@ -684,7 +684,7 @@ then
c_p="$c_p param_list blob DEFAULT '' NOT NULL," c_p="$c_p param_list blob DEFAULT '' NOT NULL,"
c_p="$c_p returns char(64) DEFAULT '' NOT NULL," c_p="$c_p returns char(64) DEFAULT '' NOT NULL,"
c_p="$c_p body blob DEFAULT '' NOT NULL," c_p="$c_p body blob DEFAULT '' NOT NULL,"
c_p="$c_p definer char(77) binary DEFAULT '' NOT NULL," c_p="$c_p definer char(77) collate utf8_bin DEFAULT '' NOT NULL,"
c_p="$c_p created timestamp," c_p="$c_p created timestamp,"
c_p="$c_p modified timestamp," c_p="$c_p modified timestamp,"
c_p="$c_p sql_mode set(" c_p="$c_p sql_mode set("
...@@ -718,10 +718,12 @@ then ...@@ -718,10 +718,12 @@ then
c_p="$c_p 'TRADITIONAL'," c_p="$c_p 'TRADITIONAL',"
c_p="$c_p 'NO_AUTO_CREATE_USER'," c_p="$c_p 'NO_AUTO_CREATE_USER',"
c_p="$c_p 'HIGH_NOT_PRECEDENCE'" c_p="$c_p 'HIGH_NOT_PRECEDENCE'"
c_p="$c_p ) DEFAULT 0 NOT NULL," c_p="$c_p ) DEFAULT '' NOT NULL,"
c_p="$c_p comment char(64) binary DEFAULT '' NOT NULL," c_p="$c_p comment char(64) collate utf8_bin DEFAULT '' NOT NULL,"
c_p="$c_p PRIMARY KEY (db,name,type)" c_p="$c_p PRIMARY KEY (db,name,type)"
c_p="$c_p ) comment='Stored Procedures';" c_p="$c_p ) engine=MyISAM"
c_p="$c_p character set utf8"
c_p="$c_p comment='Stored Procedures';"
fi fi
cat << END_OF_DATA cat << END_OF_DATA
......
...@@ -412,22 +412,22 @@ PRIMARY KEY TranTime (Transition_time) ...@@ -412,22 +412,22 @@ PRIMARY KEY TranTime (Transition_time)
# #
CREATE TABLE IF NOT EXISTS proc ( CREATE TABLE IF NOT EXISTS proc (
db char(64) binary DEFAULT '' NOT NULL, db char(64) collate utf8_bin DEFAULT '' NOT NULL,
name char(64) DEFAULT '' NOT NULL, name char(64) DEFAULT '' NOT NULL,
type enum('FUNCTION','PROCEDURE') NOT NULL, type enum('FUNCTION','PROCEDURE') NOT NULL,
specific_name char(64) DEFAULT '' NOT NULL, specific_name char(64) DEFAULT '' NOT NULL,
language enum('SQL') DEFAULT 'SQL' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL,
sql_data_access enum('CONTAINS_SQL', sql_data_access enum('CONTAINS_SQL',
'NO_SQL', 'NO_SQL',
'READS_SQL_DATA', 'READS_SQL_DATA',
'MODIFIES_SQL_DATA' 'MODIFIES_SQL_DATA'
) DEFAULT 'CONTAINS_SQL' NOT NULL, ) DEFAULT 'CONTAINS_SQL' NOT NULL,
is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL,
security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL,
param_list blob DEFAULT '' NOT NULL, param_list blob DEFAULT '' NOT NULL,
returns char(64) DEFAULT '' NOT NULL, returns char(64) DEFAULT '' NOT NULL,
body blob DEFAULT '' NOT NULL, body blob DEFAULT '' NOT NULL,
definer char(77) binary DEFAULT '' NOT NULL, definer char(77) collate utf8_bin DEFAULT '' NOT NULL,
created timestamp, created timestamp,
modified timestamp, modified timestamp,
sql_mode set( sql_mode set(
...@@ -461,20 +461,22 @@ CREATE TABLE IF NOT EXISTS proc ( ...@@ -461,20 +461,22 @@ CREATE TABLE IF NOT EXISTS proc (
'TRADITIONAL', 'TRADITIONAL',
'NO_AUTO_CREATE_USER', 'NO_AUTO_CREATE_USER',
'HIGH_NOT_PRECEDENCE' 'HIGH_NOT_PRECEDENCE'
) DEFAULT 0 NOT NULL, ) DEFAULT '' NOT NULL,
comment char(64) binary DEFAULT '' NOT NULL, comment char(64) collate utf8_bin DEFAULT '' NOT NULL,
PRIMARY KEY (db,name,type) PRIMARY KEY (db,name,type)
) comment='Stored Procedures'; ) engine=MyISAM
character set utf8
comment='Stored Procedures';
# Correct the name fields to not binary, and expand sql_data_access # Correct the name fields to not binary, and expand sql_data_access
ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL, ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
MODIFY specific_name char(64) DEFAULT '' NOT NULL, MODIFY specific_name char(64) DEFAULT '' NOT NULL,
MODIFY sql_data_access MODIFY sql_data_access
enum('CONTAINS_SQL', enum('CONTAINS_SQL',
'NO_SQL', 'NO_SQL',
'READS_SQL_DATA', 'READS_SQL_DATA',
'MODIFIES_SQL_DATA' 'MODIFIES_SQL_DATA'
) DEFAULT 'CONTAINS_SQL' NOT NULL, ) DEFAULT 'CONTAINS_SQL' NOT NULL,
MODIFY sql_mode MODIFY sql_mode
set('REAL_AS_FLOAT', set('REAL_AS_FLOAT',
'PIPES_AS_CONCAT', 'PIPES_AS_CONCAT',
...@@ -506,4 +508,15 @@ ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL, ...@@ -506,4 +508,15 @@ ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL,
'TRADITIONAL', 'TRADITIONAL',
'NO_AUTO_CREATE_USER', 'NO_AUTO_CREATE_USER',
'HIGH_NOT_PRECEDENCE' 'HIGH_NOT_PRECEDENCE'
) DEFAULT 0 NOT NULL; ) DEFAULT '' NOT NULL
DEFAULT CHARACTER SET utf8;
# Correct the character set and collation
ALTER TABLE proc CONVERT TO CHARACTER SET utf8;
# Reset some fields after the conversion
ALTER TABLE proc MODIFY db
char(64) collate utf8_bin DEFAULT '' NOT NULL,
MODIFY definer
char(77) collate utf8_bin DEFAULT '' NOT NULL,
MODIFY comment
char(64) collate utf8_bin DEFAULT '' NOT NULL;
...@@ -67,7 +67,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, ...@@ -67,7 +67,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name,
enum thr_lock_type ltype, TABLE **tablep, bool *opened) enum thr_lock_type ltype, TABLE **tablep, bool *opened)
{ {
TABLE *table; TABLE *table;
byte key[NAME_LEN*2+4+1]; // db, name, optional key length type byte key[MAX_KEY_LENGTH]; // db, name, optional key length type
DBUG_ENTER("db_find_routine_aux"); DBUG_ENTER("db_find_routine_aux");
DBUG_PRINT("enter", ("type: %d name: %*s", DBUG_PRINT("enter", ("type: %d name: %*s",
type, name->m_name.length, name->m_name.str)); type, name->m_name.length, name->m_name.str));
......
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