1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

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
This commit is contained in:
unknown
2004-04-06 00:10:43 +03:00
parent 036656e74b
commit ffb47ca01e
3 changed files with 162 additions and 29 deletions

View File

@ -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;
}
@ -100,6 +99,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!