From 445198c10e588183f5db591cfd8c3829d0004ec2 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Thu, 25 Jul 2024 22:14:59 +0200 Subject: [PATCH] pos-fixes for rename --- mysql-test/main/vector.result | 4 ++-- mysql-test/main/vector.test | 4 ++-- sql/sql_table.cc | 1 + storage/myisam/mi_rename.c | 6 ++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mysql-test/main/vector.result b/mysql-test/main/vector.result index 67f0f1090db..117980ef4ed 100644 --- a/mysql-test/main/vector.result +++ b/mysql-test/main/vector.result @@ -344,8 +344,8 @@ t1#i#01.MYI t1.MYD t1.MYI t1.frm -rename table test1.t2 to test1.t1; -ERROR 42S02: Table 'test1.t2' doesn't exist +rename table test1.t1 to test1.t2; +ERROR HY000: Error on rename of './test1/t1#i#01.MYD' to './test1/t2#i#01.MYD' (Errcode: 2 "No such file or directory") db.opt t1#i#01.MYI t1.MYD diff --git a/mysql-test/main/vector.test b/mysql-test/main/vector.test index f4e81940718..f03fe632b31 100644 --- a/mysql-test/main/vector.test +++ b/mysql-test/main/vector.test @@ -132,8 +132,8 @@ rename table test.t2 to test1.t1; list_files $datadir/test1; remove_file $datadir/test1/t1#i#01.MYD; ---error ER_NO_SUCH_TABLE -rename table test1.t2 to test1.t1; +--error 7 +rename table test1.t1 to test1.t2; list_files $datadir/test1; drop database test1; list_files $datadir/test; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index be0c76ffd3c..9e13c30376c 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -5415,6 +5415,7 @@ mysql_rename_table(handlerton *base, const LEX_CSTRING *old_db, } file->ha_rename_table(to_base, from_base); rename_file_ext(to, from, reg_ext); + break; } } } diff --git a/storage/myisam/mi_rename.c b/storage/myisam/mi_rename.c index 13cf8c60897..30a1206f5f9 100644 --- a/storage/myisam/mi_rename.c +++ b/storage/myisam/mi_rename.c @@ -36,10 +36,8 @@ int mi_rename(const char *old_name, const char *new_name) save_errno= my_errno; fn_format(from,old_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); fn_format(to,new_name,"",MI_NAME_DEXT,MY_UNPACK_FILENAME|MY_APPEND_EXT); - if (mysql_file_rename_with_symlink(mi_key_file_dfile, - from, to, - MYF(MY_WME))) - if (save_errno) + if (mysql_file_rename_with_symlink(mi_key_file_dfile, from, to, MYF(MY_WME))) + if (!save_errno) save_errno= my_errno; DBUG_RETURN(save_errno); }