diff options
author | unknown <monty@mashka.mysql.fi> | 2002-09-03 16:28:01 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-09-03 16:28:01 +0300 |
commit | 3307f95554d9bca2736d79b970c2f118c66a27ed (patch) | |
tree | 650f91f79bff10451cbe33bcc4e21fe27fd3916f /sql/sql_base.cc | |
parent | 35115d9a509933f141ec835d5da7930233e9e3a3 (diff) | |
download | mariadb-git-3307f95554d9bca2736d79b970c2f118c66a27ed.tar.gz |
Fixed bug introduces by last changeset
(Fixing of problem with ALTER TABLE on BDB tables)
mysql-test/r/distinct.result:
Fixed results after bug fix
sql/mysql_priv.h:
Split close_thread_tables() into two functions.
(Needed for bug fix from 4.0)
sql/sql_base.cc:
Split close_thread_tables() into two functions.
(Needed for bug fix from 4.0)
Diffstat (limited to 'sql/sql_base.cc')
-rw-r--r-- | sql/sql_base.cc | 80 |
1 files changed, 45 insertions, 35 deletions
diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 31d6f16ef72..bc98a7cd83d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -428,7 +428,6 @@ void close_thread_tables(THD *thd, bool locked) DBUG_VOID_RETURN; // LOCK TABLES in use } - TABLE *table,*next; bool found_old_table=0; if (thd->lock) @@ -441,41 +440,10 @@ void close_thread_tables(THD *thd, bool locked) DBUG_PRINT("info", ("thd->open_tables=%p", thd->open_tables)); - for (table=thd->open_tables ; table ; table=next) - { - next=table->next; - if (table->version != refresh_version || - thd->version != refresh_version || !table->db_stat) - { - VOID(hash_delete(&open_cache,(byte*) table)); - found_old_table=1; - } - else - { - if (table->flush_version != flush_version) - { - table->flush_version=flush_version; - table->file->extra(HA_EXTRA_FLUSH); - } - else - { - // Free memory and reset for next loop - table->file->extra(HA_EXTRA_RESET); - } - table->in_use=0; - if (unused_tables) - { - table->next=unused_tables; /* Link in last */ - table->prev=unused_tables->prev; - unused_tables->prev=table; - table->prev->next=table; - } - else - unused_tables=table->next=table->prev=table; - } - } + while (thd->open_tables) + found_old_table|=close_thread_table(thd, &thd->open_tables); thd->some_tables_deleted=0; - thd->open_tables=0; + /* Free tables to hold down open files */ while (open_cache.records > table_cache_size && unused_tables) VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */ @@ -491,6 +459,48 @@ void close_thread_tables(THD *thd, bool locked) DBUG_VOID_RETURN; } +/* move one table to free list */ + +bool close_thread_table(THD *thd, TABLE **table_ptr) +{ + DBUG_ENTER("close_thread_table"); + + bool found_old_table=0; + TABLE *table=*table_ptr; + + *table_ptr=table->next; + if (table->version != refresh_version || + thd->version != refresh_version || !table->db_stat) + { + VOID(hash_delete(&open_cache,(byte*) table)); + found_old_table=1; + } + else + { + if (table->flush_version != flush_version) + { + table->flush_version=flush_version; + table->file->extra(HA_EXTRA_FLUSH); + } + else + { + // Free memory and reset for next loop + table->file->extra(HA_EXTRA_RESET); + } + table->in_use=0; + if (unused_tables) + { + table->next=unused_tables; /* Link in last */ + table->prev=unused_tables->prev; + unused_tables->prev=table; + table->prev->next=table; + } + else + unused_tables=table->next=table->prev=table; + } + DBUG_RETURN(found_old_table); +} + /* Close and delete temporary tables */ void close_temporary(TABLE *table,bool delete_table) |