diff options
author | unknown <monty@mashka.mysql.fi> | 2002-09-03 16:48:37 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-09-03 16:48:37 +0300 |
commit | a040cf1eb25aaf905972cdf11e6aa762106fce7a (patch) | |
tree | 6bdf071925753548518010c1da84f4d3ce0f8de0 | |
parent | ffb97b49948b16ea9e53f544818dedf4b0f11697 (diff) | |
parent | 3307f95554d9bca2736d79b970c2f118c66a27ed (diff) | |
download | mariadb-git-a040cf1eb25aaf905972cdf11e6aa762106fce7a.tar.gz |
Merge
Docs/manual.texi:
SCCS merged
-rw-r--r-- | Docs/manual.texi | 4 | ||||
-rw-r--r-- | mysql-test/r/distinct.result | 3 | ||||
-rw-r--r-- | sql/item_cmpfunc.cc | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/sql_base.cc | 80 | ||||
-rw-r--r-- | sql/sql_table.cc | 16 |
6 files changed, 67 insertions, 39 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index ffefdc28409..c90cfc2c154 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46929,6 +46929,10 @@ not yet 100% confident in this code. @appendixsubsec Changes in release 3.23.53 @itemize @bullet @item +Changed @code{AND/OR} to report that they can return NULL. This fixes a +small problem in @code{GROUP BY} on @code{AND/OR} expression that return +@code{NULL}. +@item Fixed a bug that @code{OPTIMIZE} of locked and modified MyISAM table, reported table corruption. @item diff --git a/mysql-test/r/distinct.result b/mysql-test/r/distinct.result index 8f8770e5602..1d18fb4c75b 100644 --- a/mysql-test/r/distinct.result +++ b/mysql-test/r/distinct.result @@ -69,7 +69,8 @@ a max(id) b 0 0 NULL NULL NULL grp count(*) -0 7 +NULL 1 +0 6 1 6 FACILITY NULL diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index f17c8af3519..36ecde337a7 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -1097,6 +1097,8 @@ Item_cond::fix_fields(THD *thd,TABLE_LIST *tables) used_tables_cache|=item->used_tables(); with_sum_func= with_sum_func || item->with_sum_func; const_item_cache&=item->const_item(); + if (item->maybe_null) + maybe_null=1; } if (thd) thd->cond_count+=list.elements; diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 6b2721f4ab7..a5c2c3909d3 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -447,6 +447,7 @@ bool rm_temporary_table(enum db_type base, char *path); bool send_fields(THD *thd,List<Item> &item,uint send_field_count); void free_io_cache(TABLE *entry); void intern_close_table(TABLE *entry); +bool close_thread_table(THD *thd, TABLE **table_ptr); void close_thread_tables(THD *thd,bool locked=0); void close_temporary_tables(THD *thd); TABLE **find_temporary_table(THD *thd, const char *db, const char *table_name); 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) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 534b267403c..2bb46b5c47d 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -19,6 +19,9 @@ #include "mysql_priv.h" #include <hash.h> +#ifdef HAVE_BERKELEY_DB +#include <ha_berkeley.h> +#endif #include <myisam.h> #ifdef __WIN__ @@ -1675,11 +1678,18 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name, VOID(pthread_cond_broadcast(&COND_refresh)); VOID(pthread_mutex_unlock(&LOCK_open)); #ifdef HAVE_BERKELEY_DB - extern bool berkeley_flush_logs(void); if (old_db_type == DB_TYPE_BERKELEY_DB) { - (void)berkeley_flush_logs(); - table=open_ltable(thd,table_list,TL_READ); + (void) berkeley_flush_logs(); + /* + For the alter table to be properly flushed to the logs, we + have to open the new table. If not, we get a problem on server + shutdown. + */ + if (!open_tables(thd, table_list)) // Should always succeed + { + close_thread_table(thd, &table_list->table); + } } #endif |