From 8dafbcefe85fd9b16303ceebdd0f332a945b2cd3 Mon Sep 17 00:00:00 2001 From: marko Date: Tue, 18 Mar 2008 10:10:51 +0000 Subject: [PATCH] branches/zip: Pass the tablespace flags correctly when creating or opening single-table tablespaces. This bug was reported by Sunny as Mantis issue #26. fil_space_create(), fil_create_new_single_table_tablespace(), fil_open_single_table_tablespace(), fsp_header_init_fields(): Add ut_a(flags != DICT_TF_COMPACT). dict_build_table_def_step(), row_import_tablespace_for_mysql(), row_truncate_table_for_mysql(): Pass correct flags to fil_create_new_single_table_tablespace() or fil_open_single_table_tablespace(). --- dict/dict0crea.c | 2 +- fil/fil0fil.c | 21 +++++++++++++++++++-- fsp/fsp0fsp.c | 10 ++++++++-- include/fil0fil.h | 3 +-- include/fsp0fsp.h | 4 ++-- row/row0mysql.c | 12 +++++++----- 6 files changed, 38 insertions(+), 14 deletions(-) diff --git a/dict/dict0crea.c b/dict/dict0crea.c index 75a05251ce1..f9959d29a93 100644 --- a/dict/dict0crea.c +++ b/dict/dict0crea.c @@ -263,7 +263,7 @@ dict_build_table_def_step( error = fil_create_new_single_table_tablespace( &space, path_or_name, is_path, - table->flags, + table->flags == DICT_TF_COMPACT ? 0 : table->flags, FIL_IBD_FILE_INITIAL_SIZE); table->space = (unsigned int) space; diff --git a/fil/fil0fil.c b/fil/fil0fil.c index ed24b88c20c..d6a8d1039e1 100644 --- a/fil/fil0fil.c +++ b/fil/fil0fil.c @@ -1079,6 +1079,13 @@ fil_space_create( { fil_system_t* system = fil_system; fil_space_t* space; + + /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for + ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and + ROW_FORMAT=REDUNDANT (table->flags == 0). For any other + format, the tablespace flags should equal table->flags. */ + ut_a(flags != DICT_TF_COMPACT); + try_again: /*printf( "InnoDB: Adding tablespace %lu of name %s, purpose %lu\n", id, name, @@ -2606,8 +2613,7 @@ fil_create_new_single_table_tablespace( table */ ibool is_temp, /* in: TRUE if a table created with CREATE TEMPORARY TABLE */ - ulint flags, /* in: compressed page size and - file format version, or 0 */ + ulint flags, /* in: tablespace flags */ ulint size) /* in: the initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE */ @@ -2621,6 +2627,11 @@ fil_create_new_single_table_tablespace( char* path; ut_a(size >= FIL_IBD_FILE_INITIAL_SIZE); + /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for + ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and + ROW_FORMAT=REDUNDANT (table->flags == 0). For any other + format, the tablespace flags should equal table->flags. */ + ut_a(flags != DICT_TF_COMPACT); path = fil_make_ibd_name(tablename, is_temp); @@ -2988,6 +2999,12 @@ fil_open_single_table_tablespace( filepath = fil_make_ibd_name(name, FALSE); + /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for + ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and + ROW_FORMAT=REDUNDANT (table->flags == 0). For any other + format, the tablespace flags should equal table->flags. */ + ut_a(flags != DICT_TF_COMPACT); + file = os_file_create_simple_no_error_handling( filepath, OS_FILE_OPEN, OS_FILE_READ_ONLY, &success); if (!success) { diff --git a/fsp/fsp0fsp.c b/fsp/fsp0fsp.c index 47a6c55828e..3b5c81d8bc4 100644 --- a/fsp/fsp0fsp.c +++ b/fsp/fsp0fsp.c @@ -909,9 +909,15 @@ fsp_header_init_fields( /*===================*/ page_t* page, /* in/out: first page in the space */ ulint space_id, /* in: space id */ - ulint flags) /* in: compressed page size and - file format version, or 0 */ + ulint flags) /* in: tablespace flags (FSP_SPACE_FLAGS): + 0, or table->flags if newer than COMPACT */ { + /* The tablespace flags (FSP_SPACE_FLAGS) should be 0 for + ROW_FORMAT=COMPACT (table->flags == DICT_TF_COMPACT) and + ROW_FORMAT=REDUNDANT (table->flags == 0). For any other + format, the tablespace flags should equal table->flags. */ + ut_a(flags != DICT_TF_COMPACT); + mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_ID + page, space_id); mach_write_to_4(FSP_HEADER_OFFSET + FSP_SPACE_FLAGS + page, diff --git a/include/fil0fil.h b/include/fil0fil.h index 596c50521f4..268b6f6b1fa 100644 --- a/include/fil0fil.h +++ b/include/fil0fil.h @@ -422,8 +422,7 @@ fil_create_new_single_table_tablespace( table */ ibool is_temp, /* in: TRUE if a table created with CREATE TEMPORARY TABLE */ - ulint flags, /* in: compressed page size and - file format version, or 0 */ + ulint flags, /* in: tablespace flags */ ulint size); /* in: the initial size of the tablespace file in pages, must be >= FIL_IBD_FILE_INITIAL_SIZE */ diff --git a/include/fsp0fsp.h b/include/fsp0fsp.h index 5278401390e..ada805b70bf 100644 --- a/include/fsp0fsp.h +++ b/include/fsp0fsp.h @@ -108,8 +108,8 @@ fsp_header_init_fields( /*===================*/ page_t* page, /* in/out: first page in the space */ ulint space_id, /* in: space id */ - ulint flags); /* in: compressed page size and - file format version, or 0 */ + ulint flags); /* in: tablespace flags (FSP_SPACE_FLAGS): + 0, or table->flags if newer than COMPACT */ /************************************************************************** Initializes the space header of a new created space and creates also the insert buffer tree root if space == 0. */ diff --git a/row/row0mysql.c b/row/row0mysql.c index 6389fa3587f..46a035b7ce3 100644 --- a/row/row0mysql.c +++ b/row/row0mysql.c @@ -2558,8 +2558,10 @@ row_import_tablespace_for_mysql( ibuf_delete_for_discarded_space(table->space); - success = fil_open_single_table_tablespace(TRUE, table->space, - table->flags, table->name); + success = fil_open_single_table_tablespace( + TRUE, table->space, + table->flags == DICT_TF_COMPACT ? 0 : table->flags, + table->name); if (success) { table->ibd_file_missing = FALSE; table->tablespace_discarded = FALSE; @@ -2741,9 +2743,9 @@ row_truncate_table_for_mysql( if (table->space && !table->dir_path_of_temp_table) { /* Discard and create the single-table tablespace. */ ulint space = table->space; - ulint zip_size= fil_space_get_zip_size(space); + ulint flags = fil_space_get_flags(space); - if (zip_size != ULINT_UNDEFINED + if (flags != ULINT_UNDEFINED && fil_discard_tablespace(space)) { dict_index_t* index; @@ -2751,7 +2753,7 @@ row_truncate_table_for_mysql( space = 0; if (fil_create_new_single_table_tablespace( - &space, table->name, FALSE, zip_size, + &space, table->name, FALSE, flags, FIL_IBD_FILE_INITIAL_SIZE) != DB_SUCCESS) { ut_print_timestamp(stderr); fprintf(stderr,