summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authorunknown <georg@lmy002.wdf.sap.corp>2005-09-18 21:43:28 +0200
committerunknown <georg@lmy002.wdf.sap.corp>2005-09-18 21:43:28 +0200
commit458aa0e34b3f4f6f5ccac6b03502e88864a2a18b (patch)
tree4f40850583dc106a3d2244b93f21e79b9e792a6f /sql/sql_rename.cc
parentbf58b698e22efe0849fc8ee18fc30e3914d73409 (diff)
downloadmariadb-git-458aa0e34b3f4f6f5ccac6b03502e88864a2a18b.tar.gz
Changes after discussion/review with Sanja
sql/parse_file.cc: Fix after discussion/review with Sanja: removed rename_view from sql_view to general function rename_in_schema_file (so it can be used for other .frm types like triggers too) sql/parse_file.h: added prototype for rename_in_schema_file sql/sql_rename.cc: simplified code (thanks to Sanja) sql/sql_view.cc: moved rename_view_files to rename_in_schema_file (parse_file.cc) corrected MYF parameter from MY_WME to 0.
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc50
1 files changed, 25 insertions, 25 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index b848809ccc9..154e828b47e 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -138,7 +138,7 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
for (ren_table= table_list; ren_table; ren_table= new_table->next_local)
{
- db_type table_type;
+ int rc= 1;
char name[FN_REFLEN];
const char *new_alias, *old_alias;
@@ -165,36 +165,36 @@ rename_tables(THD *thd, TABLE_LIST *table_list, bool skip_error)
ren_table->db, old_alias,
reg_ext);
unpack_filename(name, name);
- if ((frm_type= mysql_frm_type(name)) == FRMTYPE_TABLE &&
- (table_type= get_table_type(thd, name)) == DB_TYPE_UNKNOWN)
+
+ frm_type= mysql_frm_type(name);
+ switch (frm_type)
{
- my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
- if (!skip_error)
- DBUG_RETURN(ren_table);
- }
- else {
- int rc= 1;
- switch (frm_type)
+ case FRMTYPE_TABLE:
{
- case FRMTYPE_TABLE:
+ db_type table_type;
+ if ((table_type= get_table_type(thd, name)) == DB_TYPE_UNKNOWN)
+ my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
+ else
rc= mysql_rename_table(table_type, ren_table->db, old_alias,
new_table->db, new_alias);
- break;
- case FRMTYPE_VIEW:
- /* change of schema is not allowed */
- if (strcmp(ren_table->db, new_table->db))
- my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db,
- new_table->db);
- else
- rc= mysql_rename_view(thd, new_alias, ren_table);
- break;
- case FRMTYPE_ERROR:
- default:
- my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
+ break;
}
- if (rc && !skip_error)
- DBUG_RETURN(ren_table);
+ case FRMTYPE_VIEW:
+ /* change of schema is not allowed */
+ if (strcmp(ren_table->db, new_table->db))
+ my_error(ER_FORBID_SCHEMA_CHANGE, MYF(0), ren_table->db,
+ new_table->db);
+ else
+ rc= mysql_rename_view(thd, new_alias, ren_table);
+ break;
+ default:
+ DBUG_ASSERT(0); // should never happen
+ case FRMTYPE_ERROR:
+ my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
+ break;
}
+ if (rc && !skip_error)
+ DBUG_RETURN(ren_table);
}
DBUG_RETURN(0);
}