diff options
Diffstat (limited to 'storage/innobase/dict')
-rw-r--r-- | storage/innobase/dict/dict0boot.c | 4 | ||||
-rw-r--r-- | storage/innobase/dict/dict0crea.c | 14 | ||||
-rw-r--r-- | storage/innobase/dict/dict0dict.c | 89 | ||||
-rw-r--r-- | storage/innobase/dict/dict0load.c | 71 | ||||
-rw-r--r-- | storage/innobase/dict/dict0mem.c | 4 |
5 files changed, 124 insertions, 58 deletions
diff --git a/storage/innobase/dict/dict0boot.c b/storage/innobase/dict/dict0boot.c index 20d676e6129..428047e13e6 100644 --- a/storage/innobase/dict/dict0boot.c +++ b/storage/innobase/dict/dict0boot.c @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ diff --git a/storage/innobase/dict/dict0crea.c b/storage/innobase/dict/dict0crea.c index bd4e449d11b..eeebbe9bbd2 100644 --- a/storage/innobase/dict/dict0crea.c +++ b/storage/innobase/dict/dict0crea.c @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ @@ -378,7 +378,7 @@ dict_create_sys_indexes_tuple( sys_indexes = dict_sys->sys_indexes; - table = dict_table_get_low(index->table_name); + table = dict_table_get_low(index->table_name, DICT_ERR_IGNORE_NONE); entry = dtuple_create(heap, 7 + DATA_N_SYS_COLS); @@ -580,7 +580,7 @@ dict_build_index_def_step( index = node->index; - table = dict_table_get_low(index->table_name); + table = dict_table_get_low(index->table_name, DICT_ERR_IGNORE_NONE); if (table == NULL) { return(DB_TABLE_NOT_FOUND); @@ -1215,8 +1215,8 @@ dict_create_or_check_foreign_constraint_tables(void) mutex_enter(&(dict_sys->mutex)); - table1 = dict_table_get_low("SYS_FOREIGN"); - table2 = dict_table_get_low("SYS_FOREIGN_COLS"); + table1 = dict_table_get_low("SYS_FOREIGN", DICT_ERR_IGNORE_NONE); + table2 = dict_table_get_low("SYS_FOREIGN_COLS", DICT_ERR_IGNORE_NONE); if (table1 && table2 && UT_LIST_GET_LEN(table1->indexes) == 3 @@ -1546,7 +1546,7 @@ dict_create_add_foreigns_to_dictionary( ut_ad(mutex_own(&(dict_sys->mutex))); - if (NULL == dict_table_get_low("SYS_FOREIGN")) { + if (NULL == dict_table_get_low("SYS_FOREIGN", DICT_ERR_IGNORE_NONE)) { fprintf(stderr, "InnoDB: table SYS_FOREIGN not found" " in internal data dictionary\n"); diff --git a/storage/innobase/dict/dict0dict.c b/storage/innobase/dict/dict0dict.c index aec2264ad1c..c3f64046da0 100644 --- a/storage/innobase/dict/dict0dict.c +++ b/storage/innobase/dict/dict0dict.c @@ -23,6 +23,8 @@ Data dictionary system Created 1/8/1996 Heikki Tuuri ***********************************************************************/ +#include <my_sys.h> + #include "dict0dict.h" #ifdef UNIV_NONINL @@ -750,15 +752,18 @@ UNIV_INTERN dict_table_t* dict_table_get( /*===========*/ - const char* table_name, /*!< in: table name */ - ibool inc_mysql_count)/*!< in: whether to increment the open - handle count on the table */ + const char* table_name, /*!< in: table name */ + ibool inc_mysql_count,/*!< in: whether to increment + the open handle count on the + table */ + dict_err_ignore_t ignore_err) /*!< in: errors to ignore when + loading the table */ { dict_table_t* table; mutex_enter(&(dict_sys->mutex)); - table = dict_table_get_low(table_name); + table = dict_table_get_low(table_name, ignore_err); if (inc_mysql_count && table) { table->n_mysql_handles_opened++; @@ -1832,6 +1837,11 @@ undo_size_ok: dict_index_is_ibuf(index) ? SYNC_IBUF_INDEX_TREE : SYNC_INDEX_TREE); + DBUG_EXECUTE_IF( + "index_partially_created_should_kick", + DEBUG_SYNC_C("index_partially_created"); + ); + if (!UNIV_UNLIKELY(new_index->type & DICT_UNIVERSAL)) { new_index->stat_n_diff_key_vals = mem_heap_alloc( @@ -2745,9 +2755,11 @@ UNIV_INTERN ulint dict_foreign_add_to_cache( /*======================*/ - dict_foreign_t* foreign, /*!< in, own: foreign key constraint */ - ibool check_charsets) /*!< in: TRUE=check charset - compatibility */ + dict_foreign_t* foreign, /*!< in, own: foreign key + constraint */ + ibool check_charsets, /*!< in: TRUE=check charset + compatibility */ + dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ { dict_table_t* for_table; dict_table_t* ref_table; @@ -2787,7 +2799,8 @@ dict_foreign_add_to_cache( for_in_cache->n_fields, for_in_cache->foreign_index, check_charsets, FALSE); - if (index == NULL) { + if (index == NULL + && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) { dict_foreign_error_report( ef, for_in_cache, "there is no index in referenced table" @@ -2822,7 +2835,8 @@ dict_foreign_add_to_cache( & (DICT_FOREIGN_ON_DELETE_SET_NULL | DICT_FOREIGN_ON_UPDATE_SET_NULL)); - if (index == NULL) { + if (index == NULL + && !(ignore_err & DICT_ERR_IGNORE_FK_NOKEY)) { dict_foreign_error_report( ef, for_in_cache, "there is no index in the table" @@ -2872,14 +2886,27 @@ dict_scan_to( const char* string) /*!< in: look for this */ { char quote = '\0'; + ibool escape = FALSE; for (; *ptr; ptr++) { if (*ptr == quote) { /* Closing quote character: do not look for starting quote or the keyword. */ - quote = '\0'; + + /* If the quote character is escaped by a + backslash, ignore it. */ + if (escape) { + escape = FALSE; + } else { + quote = '\0'; + } } else if (quote) { /* Within quotes: do nothing. */ + if (escape) { + escape = FALSE; + } else if (*ptr == '\\') { + escape = TRUE; + } } else if (*ptr == '`' || *ptr == '"' || *ptr == '\'') { /* Starting quote: remember the quote character. */ quote = *ptr; @@ -3198,7 +3225,7 @@ dict_scan_table_name( 2 = Store as given, compare in lower; case semi-sensitive */ if (innobase_get_lower_case_table_names() == 2) { innobase_casedn_str(ref); - *table = dict_table_get_low(ref); + *table = dict_table_get_low(ref, DICT_ERR_IGNORE_NONE); memcpy(ref, database_name, database_name_len); ref[database_name_len] = '/'; memcpy(ref + database_name_len + 1, table_name, table_name_len + 1); @@ -3211,7 +3238,7 @@ dict_scan_table_name( #else innobase_casedn_str(ref); #endif /* !__WIN__ */ - *table = dict_table_get_low(ref); + *table = dict_table_get_low(ref, DICT_ERR_IGNORE_NONE); } *success = TRUE; @@ -3265,6 +3292,11 @@ dict_strip_comments( char* ptr; /* unclosed quote character (0 if none) */ char quote = 0; + ibool escape = FALSE; + + DBUG_ENTER("dict_strip_comments"); + + DBUG_PRINT("dict_strip_comments", ("%s", sql_string)); str = mem_alloc(sql_length + 1); @@ -3279,16 +3311,29 @@ end_of_string: ut_a(ptr <= str + sql_length); - return(str); + DBUG_PRINT("dict_strip_comments", ("%s", str)); + DBUG_RETURN(str); } if (*sptr == quote) { /* Closing quote character: do not look for starting quote or comments. */ - quote = 0; + + /* If the quote character is escaped by a + backslash, ignore it. */ + if (escape) { + escape = FALSE; + } else { + quote = 0; + } } else if (quote) { /* Within quotes: do not look for starting quotes or comments. */ + if (escape) { + escape = FALSE; + } else if (*sptr == '\\') { + escape = TRUE; + } } else if (*sptr == '"' || *sptr == '`' || *sptr == '\'') { /* Starting quote: remember the quote character. */ quote = *sptr; @@ -3461,7 +3506,7 @@ dict_create_foreign_constraints_low( ut_ad(mutex_own(&(dict_sys->mutex))); - table = dict_table_get_low(name); + table = dict_table_get_low(name, DICT_ERR_IGNORE_NONE); if (table == NULL) { mutex_enter(&dict_foreign_err_mutex); @@ -4468,7 +4513,13 @@ dict_update_statistics( return; } - do { + for (; index != NULL; index = dict_table_get_next_index(index)) { + + /* Skip incomplete indexes. */ + if (index->name[0] == TEMP_INDEX_PREFIX) { + continue; + } + if (UNIV_LIKELY (srv_force_recovery < SRV_FORCE_NO_IBUF_MERGE || (srv_force_recovery < SRV_FORCE_NO_LOG_REDO @@ -4522,9 +4573,7 @@ fake_statistics: (1 + dict_index_get_n_unique(index)) * sizeof(*index->stat_n_non_null_key_vals)); } - - index = dict_table_get_next_index(index); - } while (index); + } index = dict_table_get_first_index(table); @@ -4600,7 +4649,7 @@ dict_table_print_by_name( mutex_enter(&(dict_sys->mutex)); - table = dict_table_get_low(name); + table = dict_table_get_low(name, DICT_ERR_IGNORE_NONE); ut_a(table); diff --git a/storage/innobase/dict/dict0load.c b/storage/innobase/dict/dict0load.c index f6e7a417f88..f99170a16e4 100644 --- a/storage/innobase/dict/dict0load.c +++ b/storage/innobase/dict/dict0load.c @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ @@ -103,7 +103,7 @@ dict_get_first_table_name_in_db( mtr_start(&mtr); - sys_tables = dict_table_get_low("SYS_TABLES"); + sys_tables = dict_table_get_low("SYS_TABLES", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); ut_a(!dict_table_is_comp(sys_tables)); @@ -269,7 +269,8 @@ dict_startscan_system( ut_a(system_id < SYS_NUM_SYSTEM_TABLES); - system_table = dict_table_get_low(SYSTEM_TABLE_NAME[system_id]); + system_table = dict_table_get_low(SYSTEM_TABLE_NAME[system_id], + DICT_ERR_IGNORE_NONE); clust_index = UT_LIST_GET_FIRST(system_table->indexes); @@ -334,7 +335,7 @@ dict_process_sys_tables_rec( /* If DICT_TABLE_LOAD_FROM_CACHE is set, first check whether there is cached dict_table_t struct first */ if (status & DICT_TABLE_LOAD_FROM_CACHE) { - *table = dict_table_get_low(table_name); + *table = dict_table_get_low(table_name, DICT_ERR_IGNORE_NONE); if (!(*table)) { err_msg = "Table not found in cache"; @@ -675,7 +676,7 @@ dict_check_tablespaces_and_store_max_id( mtr_start(&mtr); - sys_tables = dict_table_get_low("SYS_TABLES"); + sys_tables = dict_table_get_low("SYS_TABLES", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); ut_a(!dict_table_is_comp(sys_tables)); @@ -958,7 +959,7 @@ dict_load_columns( mtr_start(&mtr); - sys_columns = dict_table_get_low("SYS_COLUMNS"); + sys_columns = dict_table_get_low("SYS_COLUMNS", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_columns->indexes); ut_a(!dict_table_is_comp(sys_columns)); @@ -1165,7 +1166,7 @@ dict_load_fields( mtr_start(&mtr); - sys_fields = dict_table_get_low("SYS_FIELDS"); + sys_fields = dict_table_get_low("SYS_FIELDS", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_fields->indexes); ut_a(!dict_table_is_comp(sys_fields)); ut_a(name_of_col_is(sys_fields, sys_index, 4, "COL_NAME")); @@ -1392,7 +1393,7 @@ dict_load_indexes( mtr_start(&mtr); - sys_indexes = dict_table_get_low("SYS_INDEXES"); + sys_indexes = dict_table_get_low("SYS_INDEXES", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_indexes->indexes); ut_a(!dict_table_is_comp(sys_indexes)); ut_a(name_of_col_is(sys_indexes, sys_index, 4, "NAME")); @@ -1764,7 +1765,7 @@ dict_load_table( mtr_start(&mtr); - sys_tables = dict_table_get_low("SYS_TABLES"); + sys_tables = dict_table_get_low("SYS_TABLES", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_tables->indexes); ut_a(!dict_table_is_comp(sys_tables)); ut_a(name_of_col_is(sys_tables, sys_index, 3, "ID")); @@ -1893,9 +1894,16 @@ err_exit: all indexes were loaded. */ if (!cached) { } else if (err == DB_SUCCESS) { - err = dict_load_foreigns(table->name, TRUE, TRUE); - + err = dict_load_foreigns(table->name, TRUE, TRUE, + ignore_err); + if (err != DB_SUCCESS) { + fprintf(stderr, + "InnoDB: Load table '%s' failed, the table " + "has missing foreign key indexes. Turn off " + "'foreign_key_checks' and try again.", + table->name); + dict_table_remove_from_cache(table); table = NULL; } else { @@ -2093,7 +2101,8 @@ dict_load_foreign_cols( foreign->heap, foreign->n_fields * sizeof(void*)); mtr_start(&mtr); - sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS"); + sys_foreign_cols = dict_table_get_low("SYS_FOREIGN_COLS", + DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_foreign_cols->indexes); ut_a(!dict_table_is_comp(sys_foreign_cols)); @@ -2142,15 +2151,19 @@ static ulint dict_load_foreign( /*==============*/ - const char* id, /*!< in: foreign constraint id, not + const char* id, + /*!< in: foreign constraint id, not necessary '\0'-terminated */ - ulint id_len, /*!< in: id length */ - ibool check_charsets, + ulint id_len, + /*!< in: id length */ + ibool check_charsets, /*!< in: TRUE=check charset compatibility */ - ibool check_recursive) + ibool check_recursive, /*!< in: Whether to record the foreign table parent count to avoid unlimited recursive load of chained foreign tables */ + dict_err_ignore_t ignore_err) + /*!< in: error to be ignored */ { dict_foreign_t* foreign; dict_table_t* sys_foreign; @@ -2173,7 +2186,7 @@ dict_load_foreign( mtr_start(&mtr); - sys_foreign = dict_table_get_low("SYS_FOREIGN"); + sys_foreign = dict_table_get_low("SYS_FOREIGN", DICT_ERR_IGNORE_NONE); sys_index = UT_LIST_GET_FIRST(sys_foreign->indexes); ut_a(!dict_table_is_comp(sys_foreign)); @@ -2287,7 +2300,9 @@ dict_load_foreign( have to load it so that we are able to make type comparisons in the next function call. */ - for_table = dict_table_get_low(foreign->foreign_table_name_lookup); + for_table = dict_table_get_low( + foreign->foreign_table_name_lookup, + DICT_ERR_IGNORE_NONE); if (for_table && ref_table && check_recursive) { /* This is to record the longest chain of ancesters @@ -2310,7 +2325,7 @@ dict_load_foreign( a new foreign key constraint but loading one from the data dictionary. */ - return(dict_foreign_add_to_cache(foreign, check_charsets)); + return(dict_foreign_add_to_cache(foreign, check_charsets, ignore_err)); } /***********************************************************************//** @@ -2324,11 +2339,13 @@ UNIV_INTERN ulint dict_load_foreigns( /*===============*/ - const char* table_name, /*!< in: table name */ - ibool check_recursive,/*!< in: Whether to check recursive - load of tables chained by FK */ - ibool check_charsets) /*!< in: TRUE=check charset - compatibility */ + const char* table_name, /*!< in: table name */ + ibool check_recursive,/*!< in: Whether to check + recursive load of tables + chained by FK */ + ibool check_charsets, /*!< in: TRUE=check charset + compatibility */ + dict_err_ignore_t ignore_err) /*!< in: error to be ignored */ { ulint tuple_buf[(DTUPLE_EST_ALLOC(1) + sizeof(ulint) - 1) / sizeof(ulint)]; @@ -2345,7 +2362,7 @@ dict_load_foreigns( ut_ad(mutex_own(&(dict_sys->mutex))); - sys_foreign = dict_table_get_low("SYS_FOREIGN"); + sys_foreign = dict_table_get_low("SYS_FOREIGN", DICT_ERR_IGNORE_NONE); if (sys_foreign == NULL) { /* No foreign keys defined yet in this database */ @@ -2429,7 +2446,7 @@ loop: /* Load the foreign constraint definition to the dictionary cache */ err = dict_load_foreign((char*) field, len, check_charsets, - check_recursive); + check_recursive, ignore_err); if (err != DB_SUCCESS) { btr_pcur_close(&pcur); diff --git a/storage/innobase/dict/dict0mem.c b/storage/innobase/dict/dict0mem.c index a8ff501a700..5be5c1b5543 100644 --- a/storage/innobase/dict/dict0mem.c +++ b/storage/innobase/dict/dict0mem.c @@ -11,8 +11,8 @@ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with -this program; if not, write to the Free Software Foundation, Inc., 59 Temple -Place, Suite 330, Boston, MA 02111-1307 USA +this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA *****************************************************************************/ |