summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authorSergei Golubchik <sergii@pisem.net>2013-04-09 15:35:07 +0200
committerSergei Golubchik <sergii@pisem.net>2013-04-09 15:35:07 +0200
commit87a9d60ec625c8f1e8563de648105b36add9e940 (patch)
treec652d83dd0ae47c0f2910183ff21508e9668e34a /sql/sql_rename.cc
parentb9f42f4b7a08d4f6d46ecaba3595b38af0a6525d (diff)
downloadmariadb-git-87a9d60ec625c8f1e8563de648105b36add9e940.tar.gz
revert
" revision-id: sanja@askmonty.org-20110511110948-4kdevwzomvk56y1w committer: sanja@askmonty.org branch nick: work-maria-5.1-CREATE-merge timestamp: Wed 2011-05-11 14:09:48 +0300 Bugfix: New table creation/renaming block added if old encoded table present " the old behavior was less inconsistent than the new one. In the new one the error message was sometimes different (under LOCK TABLES e.g.), and there were race conditions (if this CREATE happened when a concurrent ALTER has renamed the old table away but haven't put the new table in place) The old one was like "(when using old table names) for DML #mysql50# prefix is optional, for DDL it's required".
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc16
1 files changed, 8 insertions, 8 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index c91623cee6e..cf9810db445 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -241,7 +241,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
char *new_table_alias, bool skip_error)
{
int rc= 1;
- char new_name[FN_REFLEN + 1], old_name[FN_REFLEN + 1];
+ char name[FN_REFLEN + 1];
const char *new_alias, *old_alias;
frm_type_enum frm_type;
enum legacy_db_type table_type;
@@ -260,17 +260,17 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
}
DBUG_ASSERT(new_alias);
- build_table_filename(new_name, sizeof(new_name) - 1,
+ build_table_filename(name, sizeof(name) - 1,
new_db, new_alias, reg_ext, 0);
- build_table_filename(old_name, sizeof(old_name) - 1,
- ren_table->db, old_alias, reg_ext, 0);
- if (check_table_file_presence(old_name,
- new_name, new_db, new_alias, new_alias, TRUE))
+ if (!access(name,F_OK))
{
+ my_error(ER_TABLE_EXISTS_ERROR, MYF(0), new_alias);
DBUG_RETURN(1); // This can't be skipped
}
+ build_table_filename(name, sizeof(name) - 1,
+ ren_table->db, old_alias, reg_ext, 0);
- frm_type= dd_frm_type(thd, old_name, &table_type);
+ frm_type= dd_frm_type(thd, name, &table_type);
switch (frm_type)
{
case FRMTYPE_TABLE:
@@ -322,7 +322,7 @@ do_rename(THD *thd, TABLE_LIST *ren_table, char *new_db, char *new_table_name,
default:
DBUG_ASSERT(0); // should never happen
case FRMTYPE_ERROR:
- my_error(ER_FILE_NOT_FOUND, MYF(0), old_name, my_errno);
+ my_error(ER_FILE_NOT_FOUND, MYF(0), name, my_errno);
break;
}
if (rc && !skip_error)