diff options
author | unknown <pem@mysql.com> | 2005-07-08 16:33:15 +0200 |
---|---|---|
committer | unknown <pem@mysql.com> | 2005-07-08 16:33:15 +0200 |
commit | accdff5114b99a3703e73d513db59a33e7da0371 (patch) | |
tree | 59891a3bd36cf547f491c456308d16aac95330bf | |
parent | 7672befa72781ff2bdd11edd36e20efdbd8b3560 (diff) | |
download | mariadb-git-accdff5114b99a3703e73d513db59a33e7da0371.tar.gz |
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.
-rw-r--r-- | mysql-test/r/sp-error.result | 4 | ||||
-rw-r--r-- | mysql-test/t/sp-error.test | 4 | ||||
-rw-r--r-- | scripts/mysql_create_system_tables.sh | 12 | ||||
-rw-r--r-- | scripts/mysql_fix_privilege_tables.sql | 45 | ||||
-rw-r--r-- | sql/sp.cc | 2 |
5 files changed, 41 insertions, 26 deletions
diff --git a/mysql-test/r/sp-error.result b/mysql-test/r/sp-error.result index 0d624b30d9e..b5f6a7837fa 100644 --- a/mysql-test/r/sp-error.result +++ b/mysql-test/r/sp-error.result @@ -604,10 +604,10 @@ flush tables; return 5; end| ERROR 0A000: FLUSH is not allowed in stored procedures -create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() begin end| -ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890' is too long +ERROR 42000: Identifier name 'bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890' is too long drop procedure if exists bug10969| create procedure bug10969() begin diff --git a/mysql-test/t/sp-error.test b/mysql-test/t/sp-error.test index a61c082fb30..34300cc4737 100644 --- a/mysql-test/t/sp-error.test +++ b/mysql-test/t/sp-error.test @@ -874,9 +874,9 @@ end| # # BUG#9529: Stored Procedures: No Warning on truncation of procedure name # during creation. -# +# Note: When using utf8 for mysql.proc, this limit is much higher than before --error ER_TOO_LONG_IDENT -create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890() +create procedure bug9529_90123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123() begin end| diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index bc07d857c4b..a3036b5c10b 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -669,7 +669,7 @@ fi if test ! -f $mdata/proc.frm then 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 type enum('FUNCTION','PROCEDURE') NOT NULL," c_p="$c_p specific_name char(64) DEFAULT '' NOT NULL," @@ -684,7 +684,7 @@ then c_p="$c_p param_list blob 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 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 modified timestamp," c_p="$c_p sql_mode set(" @@ -718,10 +718,12 @@ then c_p="$c_p 'TRADITIONAL'," c_p="$c_p 'NO_AUTO_CREATE_USER'," c_p="$c_p 'HIGH_NOT_PRECEDENCE'" - c_p="$c_p ) DEFAULT 0 NOT NULL," - c_p="$c_p comment char(64) binary DEFAULT '' NOT NULL," + c_p="$c_p ) 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 ) comment='Stored Procedures';" + c_p="$c_p ) engine=MyISAM" + c_p="$c_p character set utf8" + c_p="$c_p comment='Stored Procedures';" fi cat << END_OF_DATA diff --git a/scripts/mysql_fix_privilege_tables.sql b/scripts/mysql_fix_privilege_tables.sql index 3da2f7504a1..b93e0a47b1b 100644 --- a/scripts/mysql_fix_privilege_tables.sql +++ b/scripts/mysql_fix_privilege_tables.sql @@ -412,22 +412,22 @@ PRIMARY KEY TranTime (Transition_time) # 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, type enum('FUNCTION','PROCEDURE') NOT NULL, specific_name char(64) DEFAULT '' NOT NULL, language enum('SQL') DEFAULT 'SQL' NOT NULL, sql_data_access enum('CONTAINS_SQL', - 'NO_SQL', - 'READS_SQL_DATA', - 'MODIFIES_SQL_DATA' - ) DEFAULT 'CONTAINS_SQL' NOT NULL, + 'NO_SQL', + 'READS_SQL_DATA', + 'MODIFIES_SQL_DATA' + ) DEFAULT 'CONTAINS_SQL' NOT NULL, is_deterministic enum('YES','NO') DEFAULT 'NO' NOT NULL, security_type enum('INVOKER','DEFINER') DEFAULT 'DEFINER' NOT NULL, param_list blob DEFAULT '' NOT NULL, returns char(64) 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, modified timestamp, sql_mode set( @@ -461,20 +461,22 @@ CREATE TABLE IF NOT EXISTS proc ( 'TRADITIONAL', 'NO_AUTO_CREATE_USER', 'HIGH_NOT_PRECEDENCE' - ) DEFAULT 0 NOT NULL, - comment char(64) binary DEFAULT '' NOT NULL, + ) DEFAULT '' NOT NULL, + comment char(64) collate utf8_bin DEFAULT '' NOT NULL, 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 ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL, MODIFY specific_name char(64) DEFAULT '' NOT NULL, - MODIFY sql_data_access - enum('CONTAINS_SQL', - 'NO_SQL', - 'READS_SQL_DATA', - 'MODIFIES_SQL_DATA' - ) DEFAULT 'CONTAINS_SQL' NOT NULL, + MODIFY sql_data_access + enum('CONTAINS_SQL', + 'NO_SQL', + 'READS_SQL_DATA', + 'MODIFIES_SQL_DATA' + ) DEFAULT 'CONTAINS_SQL' NOT NULL, MODIFY sql_mode set('REAL_AS_FLOAT', 'PIPES_AS_CONCAT', @@ -506,4 +508,15 @@ ALTER TABLE proc MODIFY name char(64) DEFAULT '' NOT NULL, 'TRADITIONAL', 'NO_AUTO_CREATE_USER', '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; diff --git a/sql/sp.cc b/sql/sp.cc index 456248db66b..2452b9f6453 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -67,7 +67,7 @@ db_find_routine_aux(THD *thd, int type, sp_name *name, enum thr_lock_type ltype, TABLE **tablep, bool *opened) { 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_PRINT("enter", ("type: %d name: %*s", type, name->m_name.length, name->m_name.str)); |