summaryrefslogtreecommitdiff
path: root/storage/innobase/row
diff options
context:
space:
mode:
authorAnnamalai Gurusami <annamalai.gurusami@oracle.com>2013-05-06 19:57:49 +0530
committerAnnamalai Gurusami <annamalai.gurusami@oracle.com>2013-05-06 19:57:49 +0530
commit1b26d59192f8c9ec6adf49f1d40a8658a7b1d61d (patch)
treeb6b12d03101e07f8bb8be846adc44567a4ec32e5 /storage/innobase/row
parent05ca7f082327fc3d4cfb240598e9c04117c522bf (diff)
parentbf7325bb6b1efbe5802fa3bf13154a28dbbffd1a (diff)
downloadmariadb-git-1b26d59192f8c9ec6adf49f1d40a8658a7b1d61d.tar.gz
Merge from mysql-5.1 to mysql-5.5
Diffstat (limited to 'storage/innobase/row')
-rw-r--r--storage/innobase/row/row0mysql.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/storage/innobase/row/row0mysql.c b/storage/innobase/row/row0mysql.c
index d97476dcdb1..ff8f79f4f3f 100644
--- a/storage/innobase/row/row0mysql.c
+++ b/storage/innobase/row/row0mysql.c
@@ -53,7 +53,7 @@ Created 9/17/2000 Heikki Tuuri
#include "ibuf0ibuf.h"
#include "m_string.h"
#include "my_sys.h"
-
+#include "ha_prototypes.h"
/** Provide optional 4.x backwards compatibility for 5.0 and above */
UNIV_INTERN ibool row_rollback_on_timeout = FALSE;
@@ -3956,12 +3956,29 @@ row_rename_table_for_mysql(
goto end;
} else if (!new_is_tmp) {
/* Rename all constraints. */
+ char new_table_name[MAX_TABLE_NAME_LEN] = "";
+ uint errors = 0;
info = pars_info_create();
pars_info_add_str_literal(info, "new_table_name", new_name);
pars_info_add_str_literal(info, "old_table_name", old_name);
+ strncpy(new_table_name, new_name, MAX_TABLE_NAME_LEN);
+ innobase_convert_to_system_charset(
+ strchr(new_table_name, '/') + 1,
+ strchr(new_name, '/') +1,
+ MAX_TABLE_NAME_LEN, &errors);
+
+ if (errors) {
+ /* Table name could not be converted from charset
+ my_charset_filename to UTF-8. This means that the
+ table name is already in UTF-8 (#mysql#50). */
+ strncpy(new_table_name, new_name, MAX_TABLE_NAME_LEN);
+ }
+
+ pars_info_add_str_literal(info, "new_table_utf8", new_table_name);
+
err = que_eval_sql(
info,
"PROCEDURE RENAME_CONSTRAINT_IDS () IS\n"
@@ -3973,6 +3990,7 @@ row_rename_table_for_mysql(
"old_t_name_len INT;\n"
"new_db_name_len INT;\n"
"id_len INT;\n"
+ "offset INT;\n"
"found INT;\n"
"BEGIN\n"
"found := 1;\n"
@@ -3981,8 +3999,6 @@ row_rename_table_for_mysql(
"new_db_name := SUBSTR(:new_table_name, 0,\n"
" new_db_name_len);\n"
"old_t_name_len := LENGTH(:old_table_name);\n"
- "gen_constr_prefix := CONCAT(:old_table_name,\n"
- " '_ibfk_');\n"
"WHILE found = 1 LOOP\n"
" SELECT ID INTO foreign_id\n"
" FROM SYS_FOREIGN\n"
@@ -3999,12 +4015,13 @@ row_rename_table_for_mysql(
" id_len := LENGTH(foreign_id);\n"
" IF (INSTR(foreign_id, '/') > 0) THEN\n"
" IF (INSTR(foreign_id,\n"
- " gen_constr_prefix) > 0)\n"
+ " '_ibfk_') > 0)\n"
" THEN\n"
+ " offset := INSTR(foreign_id, '_ibfk_') - 1;\n"
" new_foreign_id :=\n"
- " CONCAT(:new_table_name,\n"
- " SUBSTR(foreign_id, old_t_name_len,\n"
- " id_len - old_t_name_len));\n"
+ " CONCAT(:new_table_utf8,\n"
+ " SUBSTR(foreign_id, offset,\n"
+ " id_len - offset));\n"
" ELSE\n"
" new_foreign_id :=\n"
" CONCAT(new_db_name,\n"