summaryrefslogtreecommitdiff
path: root/sql/sql_base.cc
diff options
context:
space:
mode:
authoraelkin@mysql.com <>2006-06-19 20:26:36 +0300
committeraelkin@mysql.com <>2006-06-19 20:26:36 +0300
commit201f8e04790090b0485100bfb3a1d2bb0023cac5 (patch)
treed6dd4cbab8916d93b0c6143ffd69064cb4283c3e /sql/sql_base.cc
parent9bf46d4844fdbec1ab57eca1b5ab714c40e124af (diff)
parentd30425a148acef2438a8cbb238650b5fac66609a (diff)
downloadmariadb-git-201f8e04790090b0485100bfb3a1d2bb0023cac5.tar.gz
Merge aelkin@bk-internal.mysql.com:/home/bk/mysql-5.1-new-rpl
into mysql.com:/usr_rh9/home/elkin.rh9/MySQL/TEAM/BARE/mysql-5.1-new-rpl
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r--sql/sql_base.cc36
1 files changed, 29 insertions, 7 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc
index 1b448a3ba18..f8ec4531995 100644
--- a/sql/sql_base.cc
+++ b/sql/sql_base.cc
@@ -1526,17 +1526,37 @@ bool close_temporary_table(THD *thd, TABLE_LIST *table_list)
}
/*
- Close temporary table and unlink from thd->temporary tables
+ unlink from thd->temporary tables and close temporary table
*/
void close_temporary_table(THD *thd, TABLE *table,
bool free_share, bool delete_table)
{
- TABLE **prev= table->open_prev;
- if ((*table->open_prev= table->next))
- table->next->open_prev= prev;
+ if (table->prev)
+ {
+ table->prev->next= table->next;
+ if (table->prev->next)
+ table->next->prev= table->prev;
+ }
+ else
+ {
+ /* removing the item from the list */
+ DBUG_ASSERT(table == thd->temporary_tables);
+ /*
+ slave must reset its temporary list pointer to zero to exclude
+ passing non-zero value to end_slave via rli->save_temporary_tables
+ when no temp tables opened, see an invariant below.
+ */
+ thd->temporary_tables= table->next;
+ if (thd->temporary_tables)
+ table->next->prev= 0;
+ }
if (thd->slave_thread)
+ {
+ /* natural invariant of temporary_tables */
+ DBUG_ASSERT(slave_open_temp_tables || !thd->temporary_tables);
slave_open_temp_tables--;
+ }
close_temporary(table, free_share, delete_table);
}
@@ -3504,10 +3524,12 @@ TABLE *open_temporary_table(THD *thd, const char *path, const char *db,
if (link_in_list)
{
- tmp_table->open_prev= &thd->temporary_tables;
- if ((tmp_table->next= thd->temporary_tables))
- thd->temporary_tables->open_prev= &tmp_table->next;
+ /* growing temp list at the head */
+ tmp_table->next= thd->temporary_tables;
+ if (tmp_table->next)
+ tmp_table->next->prev= tmp_table;
thd->temporary_tables= tmp_table;
+ thd->temporary_tables->prev= 0;
if (thd->slave_thread)
slave_open_temp_tables++;
}