diff options
author | unknown <heikki@hundin.mysql.fi> | 2002-02-14 10:24:27 +0200 |
---|---|---|
committer | unknown <heikki@hundin.mysql.fi> | 2002-02-14 10:24:27 +0200 |
commit | 199e17e577163252c0ba5ecec4f4a655e621ce00 (patch) | |
tree | 3c4a3aabddd03f0b49b650f268a1c2f1716f3760 /innobase | |
parent | 5c08b0fbabd600d54305462bf004845c2f5e7c68 (diff) | |
download | mariadb-git-199e17e577163252c0ba5ecec4f4a655e621ce00.tar.gz |
dict0dict.h, dict0dict.c, row0mysql.c, ha_innobase.cc:
Add some more safety if MySQL tries to drop a table on which there are open handles
sql/ha_innobase.cc:
Add some more safety if MySQL tries to drop a table on which there are open handles
innobase/row/row0mysql.c:
Add some more safety if MySQL tries to drop a table on which there are open handles
innobase/dict/dict0dict.c:
Add some more safety if MySQL tries to drop a table on which there are open handles
innobase/include/dict0dict.h:
Add some more safety if MySQL tries to drop a table on which there are open handles
Diffstat (limited to 'innobase')
-rw-r--r-- | innobase/dict/dict0dict.c | 50 | ||||
-rw-r--r-- | innobase/include/dict0dict.h | 17 | ||||
-rw-r--r-- | innobase/row/row0mysql.c | 22 |
3 files changed, 65 insertions, 24 deletions
diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index 95f9b54c914..56bdf83aa4d 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -196,21 +196,6 @@ dict_mutex_exit_for_mysql(void) } /************************************************************************ -Increments the count of open MySQL handles to a table. */ - -void -dict_table_increment_handle_count( -/*==============================*/ - dict_table_t* table) /* in: table */ -{ - mutex_enter(&(dict_sys->mutex)); - - table->n_mysql_handles_opened++; - - mutex_exit(&(dict_sys->mutex)); -} - -/************************************************************************ Decrements the count of open MySQL handles to a table. */ void @@ -496,6 +481,41 @@ dict_table_get( } /************************************************************************** +Returns a table object and increments MySQL open handle count on the table. +*/ + +dict_table_t* +dict_table_get_and_increment_handle_count( +/*======================================*/ + /* out: table, NULL if does not exist */ + char* table_name, /* in: table name */ + trx_t* trx) /* in: transaction handle or NULL */ +{ + dict_table_t* table; + + UT_NOT_USED(trx); + + mutex_enter(&(dict_sys->mutex)); + + table = dict_table_get_low(table_name); + + if (table != NULL) { + + table->n_mysql_handles_opened++; + } + + mutex_exit(&(dict_sys->mutex)); + + if (table != NULL) { + if (!table->stat_initialized) { + dict_update_statistics(table); + } + } + + return(table); +} + +/************************************************************************** Adds a table object to the dictionary cache. */ void diff --git a/innobase/include/dict0dict.h b/innobase/include/dict0dict.h index 79d67ecae15..0f6f516c2cb 100644 --- a/innobase/include/dict0dict.h +++ b/innobase/include/dict0dict.h @@ -27,13 +27,6 @@ Created 1/8/1996 Heikki Tuuri #include "trx0types.h" /************************************************************************ -Increments the count of open MySQL handles to a table. */ - -void -dict_table_increment_handle_count( -/*==============================*/ - dict_table_t* table); /* in: table */ -/************************************************************************ Decrements the count of open MySQL handles to a table. */ void @@ -195,6 +188,16 @@ dict_table_get( char* table_name, /* in: table name */ trx_t* trx); /* in: transaction handle */ /************************************************************************** +Returns a table object and increments MySQL open handle count on the table. +*/ + +dict_table_t* +dict_table_get_and_increment_handle_count( +/*======================================*/ + /* out: table, NULL if does not exist */ + char* table_name, /* in: table name */ + trx_t* trx); /* in: transaction handle or NULL */ +/************************************************************************** Returns a table object, based on table id, and memoryfixes it. */ dict_table_t* diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 45c59ff2c38..8357ebe7b96 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -273,8 +273,6 @@ row_create_prebuilt( ulint ref_len; ulint i; - dict_table_increment_handle_count(table); - heap = mem_heap_create(128); prebuilt = mem_heap_alloc(heap, sizeof(row_prebuilt_t)); @@ -1466,6 +1464,13 @@ loop: table = dict_table_get_low(drop->table_name); mutex_exit(&(dict_sys->mutex)); + if (table == NULL) { + /* If for some reason the table has already been dropped + through some other mechanism, do not try to drop it */ + + goto already_dropped; + } + if (table->n_mysql_handles_opened > 0) { return(n_tables + n_tables_dropped); @@ -1475,10 +1480,16 @@ loop: row_drop_table_for_mysql_in_background(drop->table_name); +already_dropped: mutex_enter(&kernel_mutex); UT_LIST_REMOVE(row_mysql_drop_list, row_mysql_drop_list, drop); + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Dropped table %s in background drop queue.\n", + drop->table_name); + mem_free(drop->table_name); mem_free(drop); @@ -1741,6 +1752,13 @@ row_drop_table_for_mysql( if (table->n_mysql_handles_opened > 0) { + ut_print_timestamp(stderr); + fprintf(stderr, + " InnoDB: Warning: MySQL is trying to drop table %s\n" + "InnoDB: though there are still open handles to it.\n" + "InnoDB: Adding the table to the background drop queue.\n", + table->name); + row_add_table_to_background_drop_list(table); err = DB_SUCCESS; |