summaryrefslogtreecommitdiff
path: root/sql/sql_rename.cc
diff options
context:
space:
mode:
authorunknown <bell@sanja.is.com.ua>2004-04-06 00:10:43 +0300
committerunknown <bell@sanja.is.com.ua>2004-04-06 00:10:43 +0300
commitffb47ca01e00cffd3546ed055f3220166d618a21 (patch)
treeb51ab1109db18dafb90a051c6f065a77f542adab /sql/sql_rename.cc
parent036656e74befc0ccf07b644d59857b97808bddd9 (diff)
downloadmariadb-git-ffb47ca01e00cffd3546ed055f3220166d618a21.tar.gz
reverting table list to be able to use it in next PS call (BUG#2811)
sql/sql_parse.cc: reverting table list to be able to use it in next PS call sql/sql_rename.cc: reverting table list to be able to use it in next PS call tests/client_test.c: typo fixed test of crete/drop/rename commands
Diffstat (limited to 'sql/sql_rename.cc')
-rw-r--r--sql/sql_rename.cc44
1 files changed, 34 insertions, 10 deletions
diff --git a/sql/sql_rename.cc b/sql/sql_rename.cc
index 7793e7236c0..d2b575c0838 100644
--- a/sql/sql_rename.cc
+++ b/sql/sql_rename.cc
@@ -24,6 +24,8 @@
static TABLE_LIST *rename_tables(THD *thd, TABLE_LIST *table_list,
bool skip_error);
+static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list);
+
/*
Every second entry in the table_list is the original name and every
second entry is the new name.
@@ -56,17 +58,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
if ((ren_table=rename_tables(thd,table_list,0)))
{
/* Rename didn't succeed; rename back the tables in reverse order */
- TABLE_LIST *prev=0,*table;
- /* Reverse the table list */
+ TABLE_LIST *table;
- while (table_list)
- {
- TABLE_LIST *next=table_list->next;
- table_list->next=prev;
- prev=table_list;
- table_list=next;
- }
- table_list=prev;
+ /* Reverse the table list */
+ table_list= reverse_table_list(table_list);
/* Find the last renamed table */
for (table=table_list ;
@@ -75,6 +70,10 @@ bool mysql_rename_tables(THD *thd, TABLE_LIST *table_list)
table=table->next->next; // Skip error table
/* Revert to old names */
rename_tables(thd, table, 1);
+
+ /* Revert the table list (for prepared statements) */
+ table_list= reverse_table_list(table_list);
+
error= 1;
}
@@ -101,6 +100,31 @@ err:
/*
+ reverse table list
+
+ SYNOPSIS
+ reverse_table_list()
+ table_list pointer to table _list
+
+ RETURN
+ pointer to new (reversed) list
+*/
+static TABLE_LIST *reverse_table_list(TABLE_LIST *table_list)
+{
+ TABLE_LIST *prev= 0;
+
+ while (table_list)
+ {
+ TABLE_LIST *next= table_list->next;
+ table_list->next= prev;
+ prev= table_list;
+ table_list= next;
+ }
+ return (prev);
+}
+
+
+/*
Rename all tables in list; Return pointer to wrong entry if something goes
wrong. Note that the table_list may be empty!
*/