summaryrefslogtreecommitdiff
path: root/sql/sql_table.cc
diff options
context:
space:
mode:
authorunknown <monty@donna.mysql.com>2000-08-21 03:00:52 +0300
committerunknown <monty@donna.mysql.com>2000-08-21 03:00:52 +0300
commit55c5016f92383fdf7cd14de4ef3ec5afbb89fd5a (patch)
treef46edbbf41f400440bde25519820b29885305b1b /sql/sql_table.cc
parent259c7ea0f84f25d82ec7b818e5b770f0bc7917d3 (diff)
downloadmariadb-git-55c5016f92383fdf7cd14de4ef3ec5afbb89fd5a.tar.gz
RENAME TABLE table_name TO new_table_name ; Faster Alloc
Small bug fixes myisammrg/myrg_rfirst.c: Change mode to -rw-rw-r-- myisammrg/myrg_rlast.c: Change mode to -rw-rw-r-- myisammrg/myrg_rnext.c: Change mode to -rw-rw-r-- myisammrg/myrg_rprev.c: Change mode to -rw-rw-r-- Docs/manual.texi: Update of RENAME configure.in: Portability fix include/global.h: Fix for ODBC and Intel Ia64 include/mysqld_error.h: RENAME TABLE myisam/myisamchk.c: Faster --fast myisammrg/myrg_queue.c: Bug fix myisammrg/myrg_rkey.c: Portability fix sql-bench/test-insert.sh: Fix for duplicate key test sql/ChangeLog: Changelog sql/Makefile.am: RENAME TABLE sql/item_sum.cc: Fix for COUNT(DISTINCT) sql/lock.cc: RENAME TABLE sql/share/czech/errmsg.sys: RENAME TABLE sql/share/czech/errmsg.txt: RENAME TABLE sql/share/danish/errmsg.sys: RENAME TABLE sql/share/danish/errmsg.txt: RENAME TABLE sql/share/dutch/errmsg.sys: RENAME TABLE sql/share/dutch/errmsg.txt: RENAME TABLE sql/share/english/errmsg.sys: RENAME TABLE sql/share/english/errmsg.txt: RENAME TABLE sql/share/estonia/errmsg.sys: RENAME TABLE sql/share/estonia/errmsg.txt: RENAME TABLE sql/share/french/errmsg.sys: RENAME TABLE sql/share/french/errmsg.txt: RENAME TABLE sql/share/german/errmsg.sys: RENAME TABLE sql/share/german/errmsg.txt: RENAME TABLE sql/share/greek/errmsg.sys: RENAME TABLE sql/share/greek/errmsg.txt: RENAME TABLE sql/share/hungarian/errmsg.sys: RENAME TABLE sql/share/hungarian/errmsg.txt: RENAME TABLE sql/share/italian/errmsg.sys: RENAME TABLE sql/share/italian/errmsg.txt: RENAME TABLE sql/share/japanese/errmsg.sys: RENAME TABLE sql/share/japanese/errmsg.txt: RENAME TABLE sql/share/korean/errmsg.sys: RENAME TABLE sql/share/korean/errmsg.txt: RENAME TABLE sql/share/norwegian-ny/errmsg.txt: RENAME TABLE sql/share/norwegian/errmsg.txt: RENAME TABLE sql/share/polish/errmsg.sys: RENAME TABLE sql/share/polish/errmsg.txt: RENAME TABLE sql/share/portuguese/errmsg.sys: RENAME TABLE sql/share/portuguese/errmsg.txt: RENAME TABLE sql/share/romania/errmsg.sys: RENAME TABLE sql/share/romania/errmsg.txt: RENAME TABLE sql/share/romanian/errmsg.txt: ***MISSING WEAVE*** sql/share/russian/errmsg.sys: RENAME TABLE sql/share/russian/errmsg.txt: RENAME TABLE sql/share/slovak/errmsg.sys: RENAME TABLE sql/share/slovak/errmsg.txt: RENAME TABLE sql/share/spanish/errmsg.sys: RENAME TABLE sql/share/spanish/errmsg.txt: RENAME TABLE sql/share/swedish/errmsg.OLD: RENAME TABLE sql/share/swedish/errmsg.sys: RENAME TABLE sql/share/swedish/errmsg.txt: RENAME TABLE sql/slave.cc: Faster alloc sql/sql_base.cc: RENAME TABLE sql/sql_class.cc: Faster alloc sql/sql_class.h: Faster alloc sql/sql_insert.cc: Fix bug in INSERT ... SELECT to BDB table sql/sql_lex.h: RENAME TABLE sql/sql_select.cc: Faster alloc sql/sql_show.cc: Faster alloc sql/sql_table.cc: RENAME TABLE sql/sql_yacc.yy: RENAME TABLE sql/thr_malloc.cc: Faster alloc sql/unireg.h: RENAME TABLE strings/ctype-sjis.c: Portability fix
Diffstat (limited to 'sql/sql_table.cc')
-rw-r--r--sql/sql_table.cc16
1 files changed, 12 insertions, 4 deletions
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index d9e14014189..1440929c98b 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -644,7 +644,7 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
** Alter a table definition
****************************************************************************/
-static bool
+bool
mysql_rename_table(enum db_type base,
const char *old_db,
const char * old_name,
@@ -659,9 +659,17 @@ mysql_rename_table(enum db_type base,
(void) sprintf(to,"%s/%s/%s",mysql_data_home,new_db,new_name);
fn_format(from,from,"","",4);
fn_format(to,to, "","",4);
- if (file->rename_table((const char*) from,(const char *) to) ||
- rename_file_ext(from,to,reg_ext))
+ if (file->rename_table((const char*) from,(const char *) to))
error=1;
+ else
+ {
+ if (rename_file_ext(from,to,reg_ext))
+ {
+ error=1;
+ /* Restore old file name */
+ file->rename_table((const char*) to,(const char *) from);
+ }
+ }
delete file;
DBUG_RETURN(error);
}
@@ -1412,7 +1420,7 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
#ifdef __WIN__
// Win32 can't rename an open table, so we must close the org table!
- table_name=sql_strdup(table_name); // must be saved
+ table_name=thd->strdup(table_name); // must be saved
if (close_cached_table(thd,table))
{ // Aborted
VOID(quick_rm_table(new_db_type,new_db,tmp_name));