From 494e4b99a4a6c2f933c7e663cbb6ad5b17e8f84a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20M=C3=A4kel=C3=A4?= Date: Mon, 16 Jan 2017 16:02:42 +0200 Subject: [PATCH] Remove MYSQL_TABLESPACES. MySQL 5.7 introduced partial support for user-created shared tablespaces (for example, import and export are not supported). MariaDB Server does not support tablespaces at this point of time. Let us remove most InnoDB code and data structures that is related to shared tablespaces. --- .../innodb/r/innodb-alter-discard.result | 2 +- .../suite/innodb/t/innodb-alter-discard.test | 2 +- storage/innobase/btr/btr0btr.cc | 2 +- storage/innobase/dict/dict0crea.cc | 79 +- storage/innobase/dict/dict0dict.cc | 8 - storage/innobase/dict/dict0load.cc | 351 +------- storage/innobase/dict/dict0mem.cc | 4 - storage/innobase/fil/fil0fil.cc | 284 +----- storage/innobase/fsp/fsp0file.cc | 72 +- storage/innobase/fsp/fsp0fsp.cc | 30 +- storage/innobase/fsp/fsp0space.cc | 3 +- storage/innobase/fts/fts0fts.cc | 7 - storage/innobase/handler/ha_innodb.cc | 821 ++---------------- storage/innobase/handler/ha_innodb.h | 69 +- storage/innobase/handler/ha_innopart.cc | 66 +- storage/innobase/handler/handler0alter.cc | 39 +- storage/innobase/handler/i_s.cc | 10 +- storage/innobase/include/db0err.h | 2 - storage/innobase/include/dict0crea.h | 7 - storage/innobase/include/dict0dict.h | 19 +- storage/innobase/include/dict0dict.ic | 69 +- storage/innobase/include/dict0load.h | 10 +- storage/innobase/include/dict0mem.h | 23 +- storage/innobase/include/fil0fil.h | 94 -- storage/innobase/include/fsp0file.h | 12 +- storage/innobase/include/fsp0fsp.h | 16 +- storage/innobase/include/fsp0fsp.ic | 45 +- storage/innobase/include/fsp0space.h | 26 +- storage/innobase/include/fsp0types.h | 19 - storage/innobase/include/ha_prototypes.h | 1 - storage/innobase/row/row0mysql.cc | 8 +- storage/innobase/row/row0quiesce.cc | 9 - storage/innobase/row/row0trunc.cc | 114 +-- storage/innobase/srv/srv0srv.cc | 9 +- storage/innobase/srv/srv0start.cc | 2 +- storage/innobase/ut/ut0ut.cc | 3 - 36 files changed, 182 insertions(+), 2155 deletions(-) diff --git a/mysql-test/suite/innodb/r/innodb-alter-discard.result b/mysql-test/suite/innodb/r/innodb-alter-discard.result index b05b905bc3456..4f773185f3e17 100644 --- a/mysql-test/suite/innodb/r/innodb-alter-discard.result +++ b/mysql-test/suite/innodb/r/innodb-alter-discard.result @@ -5,7 +5,7 @@ call mtr.add_suppression("InnoDB: Operating system error number .* in a file ope call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified."); call mtr.add_suppression("InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them."); call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: './test/t.ibd' OS error: .*"); -call mtr.add_suppression("InnoDB: Ignoring tablespace `test/t` because it could not be opened."); +call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`.`t` because it could not be opened."); call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .*"); call mtr.add_suppression("InnoDB: Error: trying to open a table, but could not$"); call mtr.add_suppression("MySQL is trying to open a table handle but the \.ibd file for$"); diff --git a/mysql-test/suite/innodb/t/innodb-alter-discard.test b/mysql-test/suite/innodb/t/innodb-alter-discard.test index 19ba7c3a3caea..51faf0d906810 100644 --- a/mysql-test/suite/innodb/t/innodb-alter-discard.test +++ b/mysql-test/suite/innodb/t/innodb-alter-discard.test @@ -29,7 +29,7 @@ call mtr.add_suppression("InnoDB: Operating system error number .* in a file ope call mtr.add_suppression("InnoDB: The error means the system cannot find the path specified."); call mtr.add_suppression("InnoDB: If you are installing InnoDB, remember that you must create directories yourself, InnoDB does not create them."); call mtr.add_suppression("InnoDB: Cannot open datafile for read-only: './test/t.ibd' OS error: .*"); -call mtr.add_suppression("InnoDB: Ignoring tablespace `test/t` because it could not be opened."); +call mtr.add_suppression("InnoDB: Ignoring tablespace for `test`.`t` because it could not be opened."); call mtr.add_suppression("InnoDB: Cannot calculate statistics for table .* because the .ibd file is missing. Please refer to .*"); call mtr.add_suppression("InnoDB: Error: trying to open a table, but could not$"); call mtr.add_suppression("MySQL is trying to open a table handle but the \.ibd file for$"); diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index d1d9dfe64fe54..f150a98e6ef95 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -338,7 +338,7 @@ btr_root_adjust_on_import( ulint flags = dict_tf_to_fsp_flags( table->flags, false); ulint fsp_flags = fil_space_get_flags(table->space); - err = fsp_flags_are_equal(flags, fsp_flags) + err = flags == fsp_flags ? DB_SUCCESS : DB_CORRUPTION; } } else { diff --git a/storage/innobase/dict/dict0crea.cc b/storage/innobase/dict/dict0crea.cc index 58b1e5b46b1b2..44624f6b65426 100644 --- a/storage/innobase/dict/dict0crea.cc +++ b/storage/innobase/dict/dict0crea.cc @@ -377,75 +377,6 @@ dict_build_table_def_step( return(err); } -/** Build a tablespace to store various objects. -@param[in,out] tablespace Tablespace object describing what to build. -@return DB_SUCCESS or error code. */ -dberr_t -dict_build_tablespace( - Tablespace* tablespace) -{ - dberr_t err = DB_SUCCESS; - mtr_t mtr; - ulint space = 0; - - ut_ad(mutex_own(&dict_sys->mutex)); - ut_ad(tablespace); - - DBUG_EXECUTE_IF("out_of_tablespace_disk", - return(DB_OUT_OF_FILE_SPACE);); - /* Get a new space id. */ - dict_hdr_get_new_id(NULL, NULL, &space, NULL, false); - if (space == ULINT_UNDEFINED) { - return(DB_ERROR); - } - tablespace->set_space_id(space); - - Datafile* datafile = tablespace->first_datafile(); - - /* We create a new generic empty tablespace. - We initially let it be 4 pages: - - page 0 is the fsp header and an extent descriptor page, - - page 1 is an ibuf bitmap page, - - page 2 is the first inode page, - - page 3 will contain the root of the clustered index of the - first table we create here. */ - - err = fil_ibd_create( - space, - tablespace->name(), - datafile->filepath(), - tablespace->flags(), - FIL_IBD_FILE_INITIAL_SIZE, - tablespace->encryption_mode(), - tablespace->key_id()); - - if (err != DB_SUCCESS) { - return(err); - } - - /* Update SYS_TABLESPACES and SYS_DATAFILES */ - err = dict_replace_tablespace_and_filepath( - tablespace->space_id(), tablespace->name(), - datafile->filepath(), tablespace->flags()); - if (err != DB_SUCCESS) { - os_file_delete(innodb_data_file_key, datafile->filepath()); - return(err); - } - - mtr_start(&mtr); - mtr.set_named_space(space); - - /* Once we allow temporary general tablespaces, we must do this; - mtr_set_log_mode(&mtr, MTR_LOG_NO_REDO); */ - ut_a(!FSP_FLAGS_GET_TEMPORARY(tablespace->flags())); - - fsp_header_init(space, FIL_IBD_FILE_INITIAL_SIZE, &mtr); - - mtr_commit(&mtr); - - return(err); -} - /** Builds a tablespace to contain a table, using file-per-table=1. @param[in,out] table Table to build in its own tablespace. @param[in] node Table create node @@ -554,15 +485,7 @@ dict_build_tablespace_for_table( return(DB_ERROR); } } else { - /* We do not need to build a tablespace for this table. It - is already built. Just find the correct tablespace ID. */ - - if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - ut_ad(table->tablespace != NULL); - - ut_ad(table->space == fil_space_get_id_by_name( - table->tablespace())); - } else if (dict_table_is_temporary(table)) { + if (dict_table_is_temporary(table)) { /* Use the shared temporary tablespace. Note: The temp tablespace supports all non-Compressed row formats whereas the system tablespace only diff --git a/storage/innobase/dict/dict0dict.cc b/storage/innobase/dict/dict0dict.cc index 122ab2c54f0b4..58d5870bf95a3 100644 --- a/storage/innobase/dict/dict0dict.cc +++ b/storage/innobase/dict/dict0dict.cc @@ -7268,22 +7268,14 @@ dict_tf_to_fsp_flags( DICT_TF_HAS_ATOMIC_BLOBS(table_flags); page_size_t page_size = dict_tf_get_page_size(table_flags); bool has_data_dir = DICT_TF_HAS_DATA_DIR(table_flags); - bool is_shared = DICT_TF_HAS_SHARED_SPACE(table_flags); bool page_compression = DICT_TF_GET_PAGE_COMPRESSION(table_flags); ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(table_flags); ut_ad(!page_size.is_compressed() || has_atomic_blobs); - /* General tablespaces that are not compressed do not get the - flags for dynamic row format (POST_ANTELOPE & ATOMIC_BLOBS) */ - if (is_shared && !page_size.is_compressed()) { - has_atomic_blobs = false; - } - ulint fsp_flags = fsp_flags_init(page_size, has_atomic_blobs, has_data_dir, - is_shared, is_temp, 0, 0, diff --git a/storage/innobase/dict/dict0load.cc b/storage/innobase/dict/dict0load.cc index ffa7f48beae19..a3da3a755d667 100644 --- a/storage/innobase/dict/dict0load.cc +++ b/storage/innobase/dict/dict0load.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -811,102 +811,6 @@ dict_get_first_path( return(filepath); } -/** Gets the space name from SYS_TABLESPACES for a given space ID. -@param[in] space_id Tablespace ID -@param[in] callers_heap A heap to allocate from, may be NULL -@return Tablespace name (caller is responsible to free it) -@retval NULL if no dictionary entry was found. */ -static -char* -dict_space_get_name( - ulint space_id, - mem_heap_t* callers_heap) -{ - mtr_t mtr; - dict_table_t* sys_tablespaces; - dict_index_t* sys_index; - dtuple_t* tuple; - dfield_t* dfield; - byte* buf; - btr_pcur_t pcur; - const rec_t* rec; - const byte* field; - ulint len; - char* space_name = NULL; - mem_heap_t* heap = mem_heap_create(1024); - - ut_ad(mutex_own(&dict_sys->mutex)); - - sys_tablespaces = dict_table_get_low("SYS_TABLESPACES"); - if (sys_tablespaces == NULL) { - ut_a(!srv_sys_tablespaces_open); - return(NULL); - } - - sys_index = UT_LIST_GET_FIRST(sys_tablespaces->indexes); - - ut_ad(!dict_table_is_comp(sys_tablespaces)); - ut_ad(name_of_col_is(sys_tablespaces, sys_index, - DICT_FLD__SYS_TABLESPACES__SPACE, "SPACE")); - ut_ad(name_of_col_is(sys_tablespaces, sys_index, - DICT_FLD__SYS_TABLESPACES__NAME, "NAME")); - - tuple = dtuple_create(heap, 1); - dfield = dtuple_get_nth_field(tuple, DICT_FLD__SYS_TABLESPACES__SPACE); - - buf = static_cast(mem_heap_alloc(heap, 4)); - mach_write_to_4(buf, space_id); - - dfield_set_data(dfield, buf, 4); - dict_index_copy_types(tuple, sys_index, 1); - - mtr_start(&mtr); - - btr_pcur_open_on_user_rec(sys_index, tuple, PAGE_CUR_GE, - BTR_SEARCH_LEAF, &pcur, &mtr); - - rec = btr_pcur_get_rec(&pcur); - - /* Get the tablespace name from this SYS_TABLESPACES record. */ - if (btr_pcur_is_on_user_rec(&pcur)) { - field = rec_get_nth_field_old( - rec, DICT_FLD__SYS_TABLESPACES__SPACE, &len); - ut_a(len == 4); - - if (space_id == mach_read_from_4(field)) { - /* A record for this space ID was found. */ - field = rec_get_nth_field_old( - rec, DICT_FLD__SYS_TABLESPACES__NAME, &len); - - ut_ad(len > 0); - ut_ad(len < OS_FILE_MAX_PATH); - - if (len > 0 && len != UNIV_SQL_NULL) { - /* Found a tablespace name. */ - if (callers_heap == NULL) { - space_name = mem_strdupl( - reinterpret_cast< - const char*>(field), - len); - } else { - space_name = mem_heap_strdupl( - callers_heap, - reinterpret_cast< - const char*>(field), - len); - } - ut_ad(space_name); - } - } - } - - btr_pcur_close(&pcur); - mtr_commit(&mtr); - mem_heap_free(heap); - - return(space_name); -} - /** Update the record for space_id in SYS_TABLESPACES to this filepath. @param[in] space_id Tablespace ID @param[in] filepath Tablespace filepath @@ -1144,106 +1048,6 @@ dict_sys_tablespaces_rec_read( return(true); } -/** Load and check each general tablespace mentioned in the SYS_TABLESPACES. -Ignore system and file-per-table tablespaces. -If it is valid, add it to the file_system list. -@param[in] validate true when the previous shutdown was not clean -@return the highest space ID found. */ -UNIV_INLINE -ulint -dict_check_sys_tablespaces( - bool validate) -{ - ulint max_space_id = 0; - btr_pcur_t pcur; - const rec_t* rec; - mtr_t mtr; - - DBUG_ENTER("dict_check_sys_tablespaces"); - - ut_ad(rw_lock_own(dict_operation_lock, RW_LOCK_X)); - ut_ad(mutex_own(&dict_sys->mutex)); - - /* Before traversing it, let's make sure we have - SYS_TABLESPACES and SYS_DATAFILES loaded. */ - dict_table_get_low("SYS_TABLESPACES"); - dict_table_get_low("SYS_DATAFILES"); - - mtr_start(&mtr); - - for (rec = dict_startscan_system(&pcur, &mtr, SYS_TABLESPACES); - rec != NULL; - rec = dict_getnext_system(&pcur, &mtr)) - { - char space_name[NAME_LEN]; - ulint space_id = 0; - ulint fsp_flags; - - if (!dict_sys_tablespaces_rec_read(rec, &space_id, - space_name, &fsp_flags)) { - continue; - } - - /* Ignore system and file-per-table tablespaces. */ - if (is_system_tablespace(space_id) - || !fsp_is_shared_tablespace(fsp_flags)) { - continue; - } - - /* Ignore tablespaces that already are in the tablespace - cache. */ - if (fil_space_for_table_exists_in_mem( - space_id, space_name, false, true, NULL, 0, NULL)) { - /* Recovery can open a datafile that does not - match SYS_DATAFILES. If they don't match, update - SYS_DATAFILES. */ - char *dict_path = dict_get_first_path(space_id); - char *fil_path = fil_space_get_first_path(space_id); - if (dict_path && fil_path - && strcmp(dict_path, fil_path)) { - dict_update_filepath(space_id, fil_path); - } - ut_free(dict_path); - ut_free(fil_path); - continue; - } - - /* Set the expected filepath from the data dictionary. - If the file is found elsewhere (from an ISL or the default - location) or this path is the same file but looks different, - fil_ibd_open() will update the dictionary with what is - opened. */ - char* filepath = dict_get_first_path(space_id); - - validate = true; /* Encryption */ - - /* Check that the .ibd file exists. */ - dberr_t err = fil_ibd_open( - validate, - !srv_read_only_mode && srv_log_file_size != 0, - FIL_TYPE_TABLESPACE, - space_id, - fsp_flags, - space_name, - filepath, - NULL); - - if (err != DB_SUCCESS) { - ib::warn() << "Ignoring tablespace " - << id_name_t(space_name) - << " because it could not be opened."; - } - - max_space_id = ut_max(max_space_id, space_id); - - ut_free(filepath); - } - - mtr_commit(&mtr); - - DBUG_RETURN(max_space_id); -} - /** Read and return 5 integer fields from a SYS_TABLES record. @param[in] rec A record of SYS_TABLES @param[in] name Table Name, the same as SYS_TABLES.NAME @@ -1363,7 +1167,6 @@ dict_check_sys_tables( rec = dict_getnext_system(&pcur, &mtr)) { const byte* field; ulint len; - char* space_name; table_name_t table_name; table_id_t table_id; ulint space_id; @@ -1395,39 +1198,24 @@ dict_check_sys_tables( } if (flags2 & DICT_TF2_DISCARDED) { - ib::info() << "Ignoring tablespace " << table_name + ib::info() << "Ignoring tablespace for " << table_name << " because the DISCARD flag is set ."; ut_free(table_name.m_name); continue; } /* If the table is not a predefined tablespace then it must - be in a file-per-table or shared tablespace. + be in a file-per-table tablespace. Note that flags2 is not available for REDUNDANT tables, so don't check those. */ - ut_ad(DICT_TF_HAS_SHARED_SPACE(flags) - || !DICT_TF_GET_COMPACT(flags) + ut_ad(!DICT_TF_GET_COMPACT(flags) || flags2 & DICT_TF2_USE_FILE_PER_TABLE); - /* Look up the tablespace name in the data dictionary if this - is a shared tablespace. For file-per-table, the table_name - and the tablespace_name are the same. - Some hidden tables like FTS AUX tables may not be found in - the dictionary since they can always be found in the default - location. If so, then dict_space_get_name() will return NULL, - the space name must be the table_name, and the filepath can be - discovered in the default location.*/ - char* shared_space_name = dict_space_get_name(space_id, NULL); - space_name = shared_space_name == NULL - ? table_name.m_name - : shared_space_name; - /* Now that we have the proper name for this tablespace, - whether it is a shared tablespace or a single table - tablespace, look to see if it is already in the tablespace - cache. */ + look to see if it is already in the tablespace cache. */ if (fil_space_for_table_exists_in_mem( - space_id, space_name, false, true, NULL, 0, NULL)) { + space_id, table_name.m_name, + false, true, NULL, 0, NULL)) { /* Recovery can open a datafile that does not match SYS_DATAFILES. If they don't match, update SYS_DATAFILES. */ @@ -1440,7 +1228,6 @@ dict_check_sys_tables( ut_free(dict_path); ut_free(fil_path); ut_free(table_name.m_name); - ut_free(shared_space_name); continue; } @@ -1462,20 +1249,19 @@ dict_check_sys_tables( FIL_TYPE_TABLESPACE, space_id, fsp_flags, - space_name, + table_name.m_name, filepath, NULL); if (err != DB_SUCCESS) { - ib::warn() << "Ignoring tablespace " - << id_name_t(space_name) + ib::warn() << "Ignoring tablespace for " + << table_name << " because it could not be opened."; } max_space_id = ut_max(max_space_id, space_id); ut_free(table_name.m_name); - ut_free(shared_space_name); ut_free(filepath); } @@ -1485,7 +1271,6 @@ dict_check_sys_tables( } /** Check each tablespace found in the data dictionary. -Look at each general tablespace found in SYS_TABLESPACES. Then look at each table defined in SYS_TABLES that has a space_id > 0 to find all the file-per-table tablespaces. @@ -1518,16 +1303,10 @@ dict_check_tablespaces_and_store_max_id( fil_set_max_space_id_if_bigger(max_space_id); - /* Open all general tablespaces found in SYS_TABLESPACES. */ - ulint max1 = dict_check_sys_tablespaces(validate); - /* Open all tablespaces referenced in SYS_TABLES. This will update SYS_TABLESPACES and SYS_DATAFILES if it finds any file-per-table tablespaces not already there. */ - ulint max2 = dict_check_sys_tables(validate); - - /* Store the max space_id found */ - max_space_id = ut_max(max1, max2); + max_space_id = dict_check_sys_tables(validate); fil_set_max_space_id_if_bigger(max_space_id); mutex_exit(&dict_sys->mutex); @@ -2767,72 +2546,6 @@ dict_get_and_save_data_dir_path( } } -/** Make sure the tablespace name is saved in dict_table_t if the table -uses a general tablespace. -Try to read it from the fil_system_t first, then from SYS_TABLESPACES. -@param[in] table Table object -@param[in] dict_mutex_own) true if dict_sys->mutex is owned already */ -void -dict_get_and_save_space_name( - dict_table_t* table, - bool dict_mutex_own) -{ - /* Do this only for general tablespaces. */ - if (!DICT_TF_HAS_SHARED_SPACE(table->flags)) { - return; - } - - bool use_cache = true; - if (table->tablespace != NULL) { - - if (srv_sys_tablespaces_open - && dict_table_has_temp_general_tablespace_name( - table->tablespace)) { - /* We previous saved the temporary name, - get the real one now. */ - use_cache = false; - } else { - /* Keep and use this name */ - return; - } - } - - if (use_cache) { - fil_space_t* space = fil_space_acquire_silent(table->space); - - if (space != NULL) { - /* Use this name unless it is a temporary general - tablespace name and we can now replace it. */ - if (!srv_sys_tablespaces_open - || !dict_table_has_temp_general_tablespace_name( - space->name)) { - - /* Use this tablespace name */ - table->tablespace = mem_heap_strdup( - table->heap, space->name); - - fil_space_release(space); - return; - } - fil_space_release(space); - } - } - - /* Read it from the dictionary. */ - if (srv_sys_tablespaces_open) { - if (!dict_mutex_own) { - dict_mutex_enter_for_mysql(); - } - - table->tablespace = dict_space_get_name( - table->space, table->heap); - - if (!dict_mutex_own) { - dict_mutex_exit_for_mysql(); - } - } -} - /** Loads a table definition and also all its index definitions, and also the cluster definition if the table is a member in a cluster. Also loads all foreign key constraints where the foreign key is in the table or where @@ -2915,37 +2628,12 @@ dict_load_tablespace( return; } - /* A file-per-table table name is also the tablespace name. - A general tablespace name is not the same as the table name. - Use the general tablespace name if it can be read from the - dictionary, if not use 'innodb_general_##. */ - char* shared_space_name = NULL; - char* space_name; - if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - if (srv_sys_tablespaces_open) { - shared_space_name = - dict_space_get_name(table->space, NULL); - - } else { - /* Make the temporary tablespace name. */ - shared_space_name = static_cast( - ut_malloc_nokey( - strlen(general_space_name) + 20)); - - sprintf(shared_space_name, "%s_" ULINTPF, - general_space_name, - static_cast(table->space)); - } - space_name = shared_space_name; - } else { - space_name = table->name.m_name; - } + char* space_name = table->name.m_name; /* The tablespace may already be open. */ if (fil_space_for_table_exists_in_mem( table->space, space_name, false, true, heap, table->id, table)) { - ut_free(shared_space_name); return; } @@ -2970,20 +2658,6 @@ dict_load_tablespace( table->data_dir_path, table->name.m_name, IBD, true); } - - } else if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - /* Set table->tablespace from either - fil_system or SYS_TABLESPACES */ - dict_get_and_save_space_name(table, true); - - /* Set the filepath from either - fil_system or SYS_DATAFILES. */ - filepath = dict_get_first_path(table->space); - if (filepath == NULL) { - ib::warn() << "Could not find the filepath" - " for table " << table->name << - ", space ID " << table->space; - } } /* Try to open the tablespace. We set the 2nd param (fix_dict) to @@ -2998,7 +2672,6 @@ dict_load_tablespace( table->ibd_file_missing = TRUE; } - ut_free(shared_space_name); ut_free(filepath); } diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index f4726ecd329cc..9463c5103ca6e 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -163,10 +163,6 @@ dict_mem_table_create( table->fts = NULL; } - if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - dict_get_and_save_space_name(table, true); - } - new(&table->foreign_set) dict_foreign_set(); new(&table->referenced_set) dict_foreign_set(); diff --git a/storage/innobase/fil/fil0fil.cc b/storage/innobase/fil/fil0fil.cc index f8abe3c5f213c..331fc34e6031b 100644 --- a/storage/innobase/fil/fil0fil.cc +++ b/storage/innobase/fil/fil0fil.cc @@ -128,15 +128,10 @@ out of the LRU-list and keep a count of pending operations. When an operation completes, we decrement the count and return the file node to the LRU-list if the count drops to zero. */ -/** This tablespace name is used internally during recovery to open a -general tablespace before the data dictionary are recovered and available. */ -const char general_space_name[] = "innodb_general"; - /** Reference to the server data directory. Usually it is the current working directory ".", but in the MySQL Embedded Server Library it is an absolute path. */ const char* fil_path_to_mysql_datadir; -Folder folder_mysql_datadir; /** Common InnoDB file extentions */ const char* dot_ext[] = { "", ".ibd", ".isl", ".cfg" }; @@ -3106,13 +3101,7 @@ fil_delete_tablespace( /* Delete the link file pointing to the ibd file we are deleting. */ if (FSP_FLAGS_HAS_DATA_DIR(space->flags)) { - RemoteDatafile::delete_link_file(space->name); - - } else if (FSP_FLAGS_GET_SHARED(space->flags)) { - - RemoteDatafile::delete_link_file(base_name(path)); - } mutex_enter(&fil_system->mutex); @@ -3725,7 +3714,6 @@ fil_rename_tablespace( /** Create a new General or Single-Table tablespace @param[in] space_id Tablespace ID @param[in] name Tablespace name in dbname/tablename format. -For general tablespaces, the 'dbname/' part may be missing. @param[in] path Path and filename of the datafile to create. @param[in] flags Tablespace flags @param[in] size Initial size of the tablespace file in @@ -3750,7 +3738,6 @@ fil_ibd_create( bool success; bool is_temp = FSP_FLAGS_GET_TEMPORARY(flags); bool has_data_dir = FSP_FLAGS_HAS_DATA_DIR(flags); - bool has_shared_space = FSP_FLAGS_GET_SHARED(flags); fil_space_t* space = NULL; fil_space_crypt_t *crypt_data = NULL; @@ -3762,11 +3749,9 @@ fil_ibd_create( /* Create the subdirectories in the path, if they are not there already. */ - if (!has_shared_space) { - err = os_file_create_subdirs_if_needed(path); - if (err != DB_SUCCESS) { - return(err); - } + err = os_file_create_subdirs_if_needed(path); + if (err != DB_SUCCESS) { + return(err); } file = os_file_create( @@ -3923,11 +3908,10 @@ fil_ibd_create( return(DB_ERROR); } - if (has_data_dir || has_shared_space) { + if (has_data_dir) { /* Make the ISL file if the IBD file is not in the default location. */ - err = RemoteDatafile::create_link_file(name, path, - has_shared_space); + err = RemoteDatafile::create_link_file(name, path); if (err != DB_SUCCESS) { os_file_close(file); os_file_delete(innodb_data_file_key, path); @@ -3974,7 +3958,7 @@ fil_ibd_create( These labels reflect the order in which variables are assigned or actions are done. */ error_exit_1: - if (err != DB_SUCCESS && (has_data_dir || has_shared_space)) { + if (err != DB_SUCCESS && has_data_dir) { RemoteDatafile::delete_link_file(name); } @@ -4030,7 +4014,6 @@ fil_ibd_open( bool dict_filepath_same_as_default = false; bool link_file_found = false; bool link_file_is_bad = false; - bool is_shared = FSP_FLAGS_GET_SHARED(flags); Datafile df_default; /* default location */ Datafile df_dict; /* dictionary location */ RemoteDatafile df_remote; /* remote location */ @@ -4056,25 +4039,8 @@ fil_ibd_open( /* Discover the correct file by looking in three possible locations while avoiding unecessary effort. */ - if (is_shared) { - /* Shared tablespaces will have a path_in since the filename - is not generated from the tablespace name. Use the basename - from this path_in with the default datadir as a filepath to - the default location */ - ut_a(path_in); - const char* sep = strrchr(path_in, OS_PATH_SEPARATOR); - const char* basename = (sep == NULL) ? path_in : &sep[1]; - df_default.make_filepath(NULL, basename, IBD); - - /* Always validate shared tablespaces. */ - validate = true; - - /* Set the ISL filepath in the default location. */ - df_remote.set_link_filepath(path_in); - } else { - /* We will always look for an ibd in the default location. */ - df_default.make_filepath(NULL, space_name, IBD); - } + /* We will always look for an ibd in the default location. */ + df_default.make_filepath(NULL, space_name, IBD); /* Look for a filepath embedded in an ISL where the default file would be. */ @@ -4284,8 +4250,7 @@ fil_ibd_open( RemoteDatafile::delete_link_file(space_name); } - } else if (!is_shared - && (!link_file_found || link_file_is_bad)) { + } else if (!link_file_found || link_file_is_bad) { ut_ad(df_dict.is_open()); /* Fix the link file if we got our filepath from the dictionary but a link file did not @@ -4315,9 +4280,7 @@ fil_ibd_open( path_in is not suppled for file-per-table, we must assume that it matched the ISL. */ if ((path_in != NULL && !dict_filepath_same_as_default) - || (path_in == NULL - && (DICT_TF_HAS_DATA_DIR(flags) - || DICT_TF_HAS_SHARED_SPACE(flags))) + || (path_in == NULL && DICT_TF_HAS_DATA_DIR(flags)) || df_remote.filepath() != NULL) { dict_replace_tablespace_and_filepath( id, space_name, df_default.filepath(), flags); @@ -4449,24 +4412,12 @@ fil_ibd_discover( ulint space_id, Datafile& df) { - Datafile df_def_gen; /* default general datafile */ Datafile df_def_per; /* default file-per-table datafile */ - RemoteDatafile df_rem_gen; /* remote general datafile*/ RemoteDatafile df_rem_per; /* remote file-per-table datafile */ - /* Look for the datafile in the default location. If it is - a general tablespace, it will be in the datadir. */ + /* Look for the datafile in the default location. */ const char* filename = df.filepath(); const char* basename = base_name(filename); - df_def_gen.init(basename, 0); - df_def_gen.make_filepath(NULL, basename, IBD); - if (df_def_gen.open_read_only(false) == DB_SUCCESS - && df_def_gen.validate_for_recovery() == DB_SUCCESS - && df_def_gen.space_id() == space_id) { - df.set_filepath(df_def_gen.filepath()); - df.open_read_only(false); - return(true); - } /* If this datafile is file-per-table it will have a schema dir. */ ulint sep_found = 0; @@ -4487,44 +4438,9 @@ fil_ibd_discover( df.open_read_only(false); return(true); } - } - - /* Did not find a general or file-per-table datafile in the - default location. Look for a remote general tablespace. */ - df_rem_gen.set_name(basename); - if (df_rem_gen.open_link_file() == DB_SUCCESS) { - - /* An ISL file was found with contents. */ - if (df_rem_gen.open_read_only(false) != DB_SUCCESS - || df_rem_gen.validate_for_recovery() != DB_SUCCESS) { - - /* Assume that this ISL file is intended to be used. - Do not continue looking for another if this file - cannot be opened or is not a valid IBD file. */ - ib::error() << "ISL file '" - << df_rem_gen.link_filepath() - << "' was found but the linked file '" - << df_rem_gen.filepath() - << "' could not be opened or is not correct."; - return(false); - } - - /* Use this file if it has the space_id from the MLOG - record. */ - if (df_rem_gen.space_id() == space_id) { - df.set_filepath(df_rem_gen.filepath()); - df.open_read_only(false); - return(true); - } - /* Since old MLOG records can use the same basename in - multiple CREATE/DROP sequences, this ISL file could be - pointing to a later version of this basename.ibd file - which has a different space_id. Keep looking. */ - } + /* Look for a remote file-per-table tablespace. */ - /* Look for a remote file-per-table tablespace. */ - if (sep_found == 2) { df_rem_per.set_name(db); if (df_rem_per.open_link_file() == DB_SUCCESS) { @@ -4616,14 +4532,9 @@ fil_ibd_load( return(FIL_LOAD_OK); } - /* If the filepath in the redo log is a default location in or - under the datadir, then just try to open it there. */ Datafile file; file.set_filepath(filename); - Folder folder(filename, dirname_length(filename)); - if (folder_mysql_datadir >= folder) { - file.open_read_only(false); - } + file.open_read_only(false); if (!file.is_open()) { /* The file has been moved or it is a remote datafile. */ @@ -4804,37 +4715,7 @@ fil_space_for_table_exists_in_mem( table->crypt_data = space->crypt_data; } - if (space != NULL - && FSP_FLAGS_GET_SHARED(space->flags) - && adjust_space - && srv_sys_tablespaces_open - && 0 == strncmp(space->name, general_space_name, - strlen(general_space_name))) { - /* This name was assigned during recovery in fil_ibd_load(). - This general tablespace was opened from an MLOG_FILE_NAME log - entry where the tablespace name does not exist. Replace the - temporary name with this name and return this space. */ - HASH_DELETE(fil_space_t, name_hash, fil_system->name_hash, - ut_fold_string(space->name), space); - ut_free(space->name); - space->name = mem_strdup(name); - HASH_INSERT(fil_space_t, name_hash, fil_system->name_hash, - ut_fold_string(space->name), space); - - mutex_exit(&fil_system->mutex); - - return(true); - } - if (space != NULL) { - if (FSP_FLAGS_GET_SHARED(space->flags) - && !srv_sys_tablespaces_open) { - - /* No need to check the name */ - mutex_exit(&fil_system->mutex); - return(true); - } - /* If this space has the expected name, use it. */ fnamespace = fil_space_get_by_name(name); if (space == fnamespace) { @@ -6359,12 +6240,10 @@ fil_mtr_rename_log( dberr_t err; bool old_is_file_per_table = - !is_system_tablespace(old_table->space) - && !DICT_TF_HAS_SHARED_SPACE(old_table->flags); + !is_system_tablespace(old_table->space); bool new_is_file_per_table = - !is_system_tablespace(new_table->space) - && !DICT_TF_HAS_SHARED_SPACE(new_table->flags); + !is_system_tablespace(new_table->space); /* If neither table is file-per-table, there will be no renaming of files. */ @@ -6702,139 +6581,6 @@ truncate_t::truncate( return(err); } -/** Build the basic folder name from the path and length provided -@param[in] path pathname (may also include the file basename) -@param[in] len length of the path, in bytes */ -void -Folder::make_path(const char* path, size_t len) -{ - if (is_absolute_path(path)) { - m_folder = mem_strdupl(path, len); - m_folder_len = len; - } - else { - size_t n = 2 + len + strlen(fil_path_to_mysql_datadir); - m_folder = static_cast(ut_malloc_nokey(n)); - m_folder_len = 0; - - if (path != fil_path_to_mysql_datadir) { - /* Put the mysqld datadir into m_folder first. */ - ut_ad(fil_path_to_mysql_datadir[0] != '\0'); - m_folder_len = strlen(fil_path_to_mysql_datadir); - memcpy(m_folder, fil_path_to_mysql_datadir, - m_folder_len); - if (m_folder[m_folder_len - 1] != OS_PATH_SEPARATOR) { - m_folder[m_folder_len++] = OS_PATH_SEPARATOR; - } - } - - /* Append the path. */ - memcpy(m_folder + m_folder_len, path, len); - m_folder_len += len; - m_folder[m_folder_len] = '\0'; - } - - os_normalize_path(m_folder); -} - -/** Resolve a relative path in m_folder to an absolute path -in m_abs_path setting m_abs_len. */ -void -Folder::make_abs_path() -{ - my_realpath(m_abs_path, m_folder, MYF(0)); - m_abs_len = strlen(m_abs_path); - - ut_ad(m_abs_len + 1 < sizeof(m_abs_path)); - - /* Folder::related_to() needs a trailing separator. */ - if (m_abs_path[m_abs_len - 1] != OS_PATH_SEPARATOR) { - m_abs_path[m_abs_len] = OS_PATH_SEPARATOR; - m_abs_path[++m_abs_len] = '\0'; - } -} - -/** Constructor -@param[in] path pathname (may also include the file basename) -@param[in] len length of the path, in bytes */ -Folder::Folder(const char* path, size_t len) -{ - make_path(path, len); - make_abs_path(); -} - -/** Assignment operator -@param[in] folder folder string provided */ -class Folder& -Folder::operator=(const char* path) -{ - ut_free(m_folder); - make_path(path, strlen(path)); - make_abs_path(); - - return(*this); -} - -/** Determine if two folders are equal -@param[in] other folder to compare to -@return whether the folders are equal */ -bool Folder::operator==(const Folder& other) const -{ - return(m_abs_len == other.m_abs_len - && !memcmp(m_abs_path, other.m_abs_path, m_abs_len)); -} - -/** Determine if the left folder is the same or an ancestor of -(contains) the right folder. -@param[in] other folder to compare to -@return whether this is the same or an ancestor of the other folder. */ -bool Folder::operator>=(const Folder& other) const -{ - return(m_abs_len <= other.m_abs_len - && (!memcmp(other.m_abs_path, m_abs_path, m_abs_len))); -} - -/** Determine if the left folder is an ancestor of (contains) -the right folder. -@param[in] other folder to compare to -@return whether this is an ancestor of the other folder */ -bool Folder::operator>(const Folder& other) const -{ - return(m_abs_len < other.m_abs_len - && (!memcmp(other.m_abs_path, m_abs_path, m_abs_len))); -} - -/** Determine if the directory referenced by m_folder exists. -@return whether the directory exists */ -bool -Folder::exists() -{ - bool exists; - os_file_type_t type; - -#ifdef _WIN32 - /* Temporarily strip the trailing_separator since it will cause - _stat64() to fail on Windows unless the path is the root of some - drive; like "c:\". _stat64() will fail if it is "c:". */ - size_t len = strlen(m_abs_path); - if (m_abs_path[m_abs_len - 1] == OS_PATH_SEPARATOR - && m_abs_path[m_abs_len - 2] != ':') { - m_abs_path[m_abs_len - 1] = '\0'; - } -#endif /* WIN32 */ - - bool ret = os_file_status(m_abs_path, &exists, &type); - -#ifdef _WIN32 - /* Put the separator back on. */ - if (m_abs_path[m_abs_len - 1] == '\0') { - m_abs_path[m_abs_len - 1] = OS_PATH_SEPARATOR; - } -#endif /* WIN32 */ - - return(ret && exists && type == OS_FILE_TYPE_DIR); -} - /* Unit Tests */ #ifdef UNIV_ENABLE_UNIT_TEST_MAKE_FILEPATH #define MF fil_make_filepath diff --git a/storage/innobase/fsp/fsp0file.cc b/storage/innobase/fsp/fsp0file.cc index 600de5418bd2e..00b5c37cec4f0 100644 --- a/storage/innobase/fsp/fsp0file.cc +++ b/storage/innobase/fsp/fsp0file.cc @@ -268,9 +268,8 @@ Datafile::same_as( } /** Allocate and set the datafile or tablespace name in m_name. -If a name is provided, use it; else if the datafile is file-per-table, -extract a file-per-table tablespace name from m_filepath; else it is a -general tablespace, so just call it that for now. The value of m_name +If a name is provided, use it; else extract a file-per-table +tablespace name from m_filepath. The value of m_name will be freed in the destructor. @param[in] name tablespace name if known, NULL if not */ void @@ -280,14 +279,8 @@ Datafile::set_name(const char* name) if (name != NULL) { m_name = mem_strdup(name); - } else if (fsp_is_file_per_table(m_space_id, m_flags)) { - m_name = fil_path_to_space_name(m_filepath); } else { - /* Give this general tablespace a temporary name. */ - m_name = static_cast( - ut_malloc_nokey(strlen(general_space_name) + 20)); - - sprintf(m_name, "%s_" ULINTPF, general_space_name, m_space_id); + m_name = fil_path_to_space_name(m_filepath); } } @@ -408,9 +401,8 @@ Datafile::validate_to_dd( If the datafile is a file-per-table tablespace then also match the row format and zip page size. */ if (m_space_id == space_id - && (m_flags & FSP_FLAGS_MASK_SHARED - || (m_flags & ~FSP_FLAGS_MASK_DATA_DIR) - == (flags & ~FSP_FLAGS_MASK_DATA_DIR))) { + && ((m_flags & ~FSP_FLAGS_MASK_DATA_DIR) + == (flags & ~FSP_FLAGS_MASK_DATA_DIR))) { /* Datafile matches the tablespace expected. */ return(DB_SUCCESS); } @@ -900,19 +892,7 @@ the path provided without its suffix, plus DOT_ISL. void RemoteDatafile::set_link_filepath(const char* path) { - if (m_link_filepath != NULL) { - return; - } - - if (path != NULL && FSP_FLAGS_GET_SHARED(flags())) { - /* Make the link_filepath based on the basename. */ - ut_ad(strcmp(&path[strlen(path) - strlen(DOT_IBD)], - DOT_IBD) == 0); - - m_link_filepath = fil_make_filepath(NULL, base_name(path), - ISL, false); - } else { - /* Make the link_filepath based on the m_name. */ + if (m_link_filepath == NULL) { m_link_filepath = fil_make_filepath(NULL, name(), ISL, false); } } @@ -922,14 +902,11 @@ under the 'datadir' of MySQL. The datadir is the directory of a running mysqld program. We can refer to it by simply using the path ".". @param[in] name tablespace name @param[in] filepath remote filepath of tablespace datafile -@param[in] is_shared true for general tablespace, - false for file-per-table @return DB_SUCCESS or error code */ dberr_t RemoteDatafile::create_link_file( const char* name, - const char* filepath, - bool is_shared) + const char* filepath) { bool success; dberr_t err = DB_SUCCESS; @@ -939,31 +916,8 @@ RemoteDatafile::create_link_file( ut_ad(!srv_read_only_mode); ut_ad(0 == strcmp(&filepath[strlen(filepath) - 4], DOT_IBD)); - if (is_shared) { - /* The default location for a shared tablespace is the - datadir. We previously made sure that this filepath is - not under the datadir. If it is in the datadir there - is no need for a link file. */ - - size_t len = dirname_length(filepath); - if (len == 0) { - /* File is in the datadir. */ - return(DB_SUCCESS); - } - - Folder folder(filepath, len); + link_filepath = fil_make_filepath(NULL, name, ISL, false); - if (folder_mysql_datadir == folder) { - /* File is in the datadir. */ - return(DB_SUCCESS); - } - - /* Use the file basename to build the ISL filepath. */ - link_filepath = fil_make_filepath(NULL, base_name(filepath), - ISL, false); - } else { - link_filepath = fil_make_filepath(NULL, name, ISL, false); - } if (link_filepath == NULL) { return(DB_ERROR); } @@ -1070,8 +1024,6 @@ RemoteDatafile::delete_link_file( It is always created under the datadir of MySQL. For file-per-table tablespaces, the isl file is expected to be in a 'database' directory and called 'tablename.isl'. -For general tablespaces, there will be no 'database' directory. -The 'basename.isl' will be in the datadir. The caller must free the memory returned if it is not null. @param[in] link_filepath filepath of the ISL file @return Filepath of the IBD file read from the ISL file */ @@ -1079,16 +1031,12 @@ char* RemoteDatafile::read_link_file( const char* link_filepath) { - char* filepath = NULL; - FILE* file = NULL; - - file = fopen(link_filepath, "r+b"); + FILE* file = fopen(link_filepath, "r+b"); if (file == NULL) { return(NULL); } - filepath = static_cast( - ut_malloc_nokey(OS_FILE_MAX_PATH)); + char* filepath = static_cast(ut_malloc_nokey(OS_FILE_MAX_PATH)); os_file_read_string(file, filepath, OS_FILE_MAX_PATH); fclose(file); diff --git a/storage/innobase/fsp/fsp0fsp.cc b/storage/innobase/fsp/fsp0fsp.cc index 2dd96bdbd0444..8739326b022e7 100644 --- a/storage/innobase/fsp/fsp0fsp.cc +++ b/storage/innobase/fsp/fsp0fsp.cc @@ -197,7 +197,6 @@ fsp_flags_to_dict_tf( ulint zip_ssize = FSP_FLAGS_GET_ZIP_SSIZE(fsp_flags); bool atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(fsp_flags); bool data_dir = FSP_FLAGS_HAS_DATA_DIR(fsp_flags); - bool shared_space = FSP_FLAGS_GET_SHARED(fsp_flags); bool page_compressed = FSP_FLAGS_GET_PAGE_COMPRESSION(fsp_flags); ulint comp_level = FSP_FLAGS_GET_PAGE_COMPRESSION_LEVEL(fsp_flags); @@ -206,7 +205,7 @@ fsp_flags_to_dict_tf( any code is created where that is needed. */ ulint flags = dict_tf_init(post_antelope | compact, zip_ssize, - atomic_blobs, data_dir, shared_space, + atomic_blobs, data_dir, page_compressed, comp_level, 0); return(flags); @@ -228,7 +227,6 @@ fsp_flags_is_valid( bool atomic_blobs = FSP_FLAGS_HAS_ATOMIC_BLOBS(flags); ulint page_ssize = FSP_FLAGS_GET_PAGE_SSIZE(flags); bool has_data_dir = FSP_FLAGS_HAS_DATA_DIR(flags); - bool is_shared = FSP_FLAGS_GET_SHARED(flags); bool is_temp = FSP_FLAGS_GET_TEMPORARY(flags); ulint unused = FSP_FLAGS_GET_UNUSED(flags); bool page_compression = FSP_FLAGS_GET_PAGE_COMPRESSION(flags); @@ -279,7 +277,7 @@ fsp_flags_is_valid( /* Only single-table tablespaces use the DATA DIRECTORY clause. It is not compatible with the TABLESPACE clause. Nor is it compatible with the TEMPORARY clause. */ - if (has_data_dir && (is_shared || is_temp)) { + if (has_data_dir && is_temp) { GOTO_ERROR; return(false); } @@ -311,7 +309,6 @@ fsp_flags_is_valid( << " page_ssize: " << page_ssize << " " << UNIV_PAGE_SSIZE_MIN << ":" << UNIV_PAGE_SSIZE_MAX << " has_data_dir: " << has_data_dir - << " is_shared: " << is_shared << " is_temp: " << is_temp << " page_compressed: " << page_compression << " page_compression_level: " << page_compression_level; @@ -328,19 +325,6 @@ fsp_is_checksum_disabled( return(fsp_is_system_temporary(space_id)); } -/** Check if tablespace is file-per-table. -@param[in] space_id tablespace ID -@param[in] fsp_flags tablespace flags -@return true if tablespace is file-per-table. */ -bool -fsp_is_file_per_table( - ulint space_id, - ulint fsp_flags) -{ - return(!is_system_tablespace(space_id) - && !fsp_is_shared_tablespace(fsp_flags)); -} - #ifdef UNIV_DEBUG /** Skip some of the sanity checks that are time consuming even in debug mode and can affect frequent verification runs that are done to ensure stability of @@ -1099,8 +1083,8 @@ fsp_try_extend_data_file( to reset the flag to false as dealing with this error requires server restart. */ if (!srv_sys_space.get_tablespace_full_status()) { - ib::error() << "Tablespace " << srv_sys_space.name() - << " " << OUT_OF_SPACE_MSG + ib::error() << "The InnoDB system tablespace " + << OUT_OF_SPACE_MSG << " innodb_data_file_path."; srv_sys_space.set_tablespace_full_status(true); } @@ -1113,8 +1097,8 @@ fsp_try_extend_data_file( to reset the flag to false as dealing with this error requires server restart. */ if (!srv_tmp_space.get_tablespace_full_status()) { - ib::error() << "Tablespace " << srv_tmp_space.name() - << " " << OUT_OF_SPACE_MSG + ib::error() << "The InnoDB temporary tablespace " + << OUT_OF_SPACE_MSG << " innodb_temp_data_file_path."; srv_tmp_space.set_tablespace_full_status(true); } @@ -1174,7 +1158,7 @@ fsp_try_extend_data_file( } /** Calculate the number of pages to extend a datafile. -We extend single-table and general tablespaces first one extent at a time, +We extend single-table tablespaces first one extent at a time, but 4 at a time for bigger tablespaces. It is not enough to extend always by one extent, because we need to add at least one extent to FSP_FREE. A single extent descriptor page will track many extents. And the extent diff --git a/storage/innobase/fsp/fsp0space.cc b/storage/innobase/fsp/fsp0space.cc index b72590e48e8c1..ed557fb83341f 100644 --- a/storage/innobase/fsp/fsp0space.cc +++ b/storage/innobase/fsp/fsp0space.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2015, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc., /**************************************************//** @file fsp/fsp0space.cc -General shared tablespace implementation. +Shared tablespace implementation. Created 2012-11-16 by Sunny Bains as srv/srv0space.cc *******************************************************/ diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 55c34db2b5992..f05ad4421f616 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -1780,13 +1780,6 @@ fts_create_in_mem_aux_table( aux_table_name, table->space, n_cols, 0, table->flags, fts_get_table_flags2_for_aux_tables(table->flags2)); - if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - ut_ad(table->space == fil_space_get_id_by_name( - table->tablespace())); - new_table->tablespace = mem_heap_strdup( - new_table->heap, table->tablespace); - } - if (DICT_TF_HAS_DATA_DIR(table->flags)) { ut_ad(table->data_dir_path != NULL); new_table->data_dir_path = mem_heap_strdup( diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 1e47da86f707a..56b1f96824454 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -474,20 +474,6 @@ static const char* innobase_change_buffering_values[IBUF_USE_COUNT] = { "all" /* IBUF_USE_ALL */ }; - -/* This tablespace name is reserved by InnoDB in order to explicitly -create a file_per_table tablespace for the table. */ -const char reserved_file_per_table_space_name[] = "innodb_file_per_table"; - -/* This tablespace name is reserved by InnoDB for the system tablespace -which uses space_id 0 and stores extra types of system pages like UNDO -and doublewrite. */ -const char reserved_system_space_name[] = "innodb_system"; - -/* This tablespace name is reserved by InnoDB for the predefined temporary -tablespace. */ -const char reserved_temporary_space_name[] = "innodb_temporary"; - /* Call back function array defined by MySQL and used to retrieve FTS results. */ const struct _ft_vft ft_vft_result = {NULL, @@ -1478,20 +1464,6 @@ innobase_rollback_by_xid( XID* xid); /*!< in: X/Open XA transaction identification */ -#ifdef MYSQL_TABLESPACES -/** This API handles CREATE, ALTER & DROP commands for InnoDB tablespaces. -@param[in] hton Handlerton of InnoDB -@param[in] thd Connection -@param[in] alter_info Describies the command and how to do it. -@return MySQL error code*/ -static -int -innobase_alter_tablespace( - handlerton* hton, - THD* thd, - st_alter_tablespace* alter_info); -#endif /* MYSQL_TABLESPACES */ - /** Remove all tables in the named database inside InnoDB. @param[in] hton handlerton from InnoDB @param[in] path Database path; Inside InnoDB the name of the last @@ -2335,8 +2307,6 @@ convert_error_code_to_mysql( return(HA_ERR_TABLE_CORRUPT); case DB_FTS_TOO_MANY_WORDS_IN_PHRASE: return(HA_ERR_FTS_TOO_MANY_WORDS_IN_PHRASE); - case DB_WRONG_FILE_NAME: - return(HA_ERR_GENERIC); // when can this happen? case DB_COMPUTE_VALUE_FAILED: return(HA_ERR_GENERIC); // impossible } @@ -3535,7 +3505,7 @@ innobase_invalidate_query_cache( TRUE); } -/** Quote a standard SQL identifier like tablespace, index or column name. +/** Quote a standard SQL identifier like index or column name. @param[in] file output stream @param[in] trx InnoDB transaction, or NULL @param[in] id identifier to quote */ @@ -3924,9 +3894,6 @@ innobase_init( innobase_hton->commit_checkpoint_request=innobase_checkpoint_request; innobase_hton->create = innobase_create_handler; -#ifdef MYSQL_TABLESPACES - innobase_hton->alter_tablespace = innobase_alter_tablespace; -#endif innobase_hton->drop_database = innobase_drop_database; innobase_hton->panic = innobase_end; innobase_hton->partition_flags= innobase_partition_flags; @@ -4095,7 +4062,6 @@ innobase_init( ut_a(default_path); fil_path_to_mysql_datadir = default_path; - folder_mysql_datadir = fil_path_to_mysql_datadir; /* Set InnoDB initialization parameters according to the values read from MySQL .cnf file */ @@ -4132,10 +4098,10 @@ innobase_init( /* Create the filespace flags. */ fsp_flags = fsp_flags_init( - univ_page_size, false, false, false, false, false, 0, 0); + univ_page_size, false, false, false, false, 0, 0); srv_sys_space.set_flags(fsp_flags); - srv_sys_space.set_name(reserved_system_space_name); + srv_sys_space.set_name("innodb_system"); srv_sys_space.set_path(srv_data_home); /* Supports raw devices */ @@ -4153,12 +4119,12 @@ innobase_init( /* We set the temporary tablspace id later, after recovery. The temp tablespace doesn't support raw devices. Set the name and path. */ - srv_tmp_space.set_name(reserved_temporary_space_name); + srv_tmp_space.set_name("innodb_temporary"); srv_tmp_space.set_path(srv_data_home); /* Create the filespace flags with the temp flag set. */ fsp_flags = fsp_flags_init( - univ_page_size, false, false, false, true, false, 0, 0); + univ_page_size, false, false, true, false, 0, 0); srv_tmp_space.set_flags(fsp_flags); if (!srv_tmp_space.parse_params(innobase_temp_data_file_path, false)) { @@ -11773,11 +11739,6 @@ create_table_info_t::create_table_def() /* For single-table tablespaces, we pass 0 as the space id, and then determine the actual space id when the tablespace is created. */ - if (DICT_TF_HAS_SHARED_SPACE(m_flags)) { - ut_ad(m_tablespace != NULL && m_tablespace[0] != '\0'); - - space_id = fil_space_get_id_by_name(m_tablespace); - } /* Adjust the number of columns for the FTS hidden field */ actual_n_cols = n_cols; @@ -11809,13 +11770,6 @@ create_table_info_t::create_table_def() table->data_dir_path = NULL; } - if (DICT_TF_HAS_SHARED_SPACE(m_flags)) { - ut_ad(strlen(m_tablespace)); - table->tablespace = mem_heap_strdup(table->heap, m_tablespace); - } else { - table->tablespace = NULL; - } - heap = mem_heap_create(1000); for (i = 0; i < n_cols; i++) { @@ -12278,7 +12232,7 @@ create_table_info_t::create_option_data_directory_is_valid() && m_create_info->data_file_name[0] != '\0'); /* Use DATA DIRECTORY only with file-per-table. */ - if (!m_use_shared_space && !m_allow_file_per_table) { + if (!m_allow_file_per_table) { push_warning( m_thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, @@ -12303,201 +12257,6 @@ create_table_info_t::create_option_data_directory_is_valid() return(is_valid); } - -#ifdef MYSQL_TABLESPACES -#define IDENT_NAME_OK 0 -static int check_tablespace_name(const char *name) -{ - CHARSET_INFO *cs= system_charset_info; - return cs->cset->numchars(cs, name, name + strlen(name)) > NAME_CHAR_LEN; -} - - -/** Validate the tablespace name provided for a tablespace DDL -@param[in] name A proposed tablespace name -@param[in] for_table Caller is putting a table here -@return MySQL handler error code like HA_... */ -static -int -validate_tablespace_name( - const char* name, - bool for_table) -{ - int err = 0; - - /* This prefix is reserved by InnoDB for use in internal tablespace names. */ - const char reserved_space_name_prefix[] = "innodb_"; - - if (check_tablespace_name(name) != IDENT_NAME_OK) { - err = HA_WRONG_CREATE_OPTION; - } - - /* The tablespace name cannot start with `innodb_`. */ - if (strlen(name) >= sizeof(reserved_space_name_prefix) - 1 - && 0 == memcmp(name, reserved_space_name_prefix, - sizeof(reserved_space_name_prefix) - 1)) { - - /* Use a different message for reserved names */ - if (0 == strcmp(name, reserved_file_per_table_space_name) - || 0 == strcmp(name, reserved_system_space_name) - || 0 == strcmp(name, reserved_temporary_space_name)) { - /* Allow these names if the caller is putting a - table into one of these by CREATE/ALTER TABLE */ - if (!for_table) { - my_printf_error( - ER_WRONG_TABLESPACE_NAME, - "InnoDB: `%s` is a reserved" - " tablespace name.", - MYF(0), name); - err = HA_WRONG_CREATE_OPTION; - } - } else { - my_printf_error(ER_WRONG_TABLESPACE_NAME, - "InnoDB: A general tablespace" - " name cannot start with `%s`.", - MYF(0), reserved_space_name_prefix); - err = HA_WRONG_CREATE_OPTION; - } - } - - /* The tablespace name cannot contain a '/'. */ - if (memchr(name, '/', strlen(name)) != NULL) { - my_printf_error(ER_WRONG_TABLESPACE_NAME, - "InnoDB: A general tablespace name cannot" - " contain '/'.", MYF(0)); - err = HA_WRONG_CREATE_OPTION; - } - - return(err); -} - -/** Validate TABLESPACE option. -@return true if valid, false if not. */ -bool -create_table_info_t::create_option_tablespace_is_valid() -{ - if (!m_use_shared_space) { - return(true); - } - - if (0 != validate_tablespace_name(m_create_info->tablespace, true)) { - return(false); - } - - /* Look up the tablespace name in the fil_system. */ - ulint space_id = fil_space_get_id_by_name( - m_create_info->tablespace); - - if (space_id == ULINT_UNDEFINED) { - my_printf_error(ER_TABLESPACE_MISSING, - "InnoDB: A general tablespace named" - " `%s` cannot be found.", MYF(0), - m_create_info->tablespace); - return(false); - } - - /* Cannot add a second table to a file-per-table tablespace. */ - ulint fsp_flags = fil_space_get_flags(space_id); - if (fsp_is_file_per_table(space_id, fsp_flags)) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Tablespace `%s` is file-per-table so no" - " other table can be added to it.", MYF(0), - m_create_info->tablespace); - return(false); - } - - /* If TABLESPACE=innodb_file_per_table this function is not called - since tablespace_is_shared_space() will return false. Any other - tablespace is incompatible with the DATA DIRECTORY phrase. - On any ALTER TABLE that contains a DATA DIRECTORY, MySQL will issue - a warning like " option ignored." The check below is - needed for CREATE TABLE only. ALTER TABLE may be moving remote - file-per-table table to a general tablespace, in which case the - create_info->data_file_name is not null. */ - bool is_create_table = (thd_sql_command(m_thd) == SQLCOM_CREATE_TABLE); - if (is_create_table - && m_create_info->data_file_name != NULL - && m_create_info->data_file_name[0] != '\0') { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: DATA DIRECTORY cannot be used" - " with a TABLESPACE assignment.", MYF(0)); - return(false); - } - - /* Temp tables only belong in temp tablespaces. */ - if (m_create_info->options & HA_LEX_CREATE_TMP_TABLE) { - if (!FSP_FLAGS_GET_TEMPORARY(fsp_flags)) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Tablespace `%s` cannot contain" - " TEMPORARY tables.", MYF(0), - m_create_info->tablespace); - return(false); - } - - /* Restrict Compressed Temporary General tablespaces. */ - if (m_create_info->key_block_size - || m_create_info->row_type == ROW_TYPE_COMPRESSED) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Temporary tablespace `%s` cannot" - " contain COMPRESSED tables.", MYF(0), - m_create_info->tablespace); - return(false); - } - } else if (FSP_FLAGS_GET_TEMPORARY(fsp_flags)) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Tablespace `%s` can only contain" - " TEMPORARY tables.", MYF(0), - m_create_info->tablespace); - return(false); - } - - /* Make sure the physical page size of the table matches the - file block size of the tablespace. */ - ulint block_size_needed; - bool table_is_compressed; - if (m_create_info->key_block_size) { - block_size_needed = m_create_info->key_block_size * 1024; - table_is_compressed = true; - } else if (m_create_info->row_type == ROW_TYPE_COMPRESSED) { - block_size_needed = ut_min( - UNIV_PAGE_SIZE / 2, - static_cast(UNIV_ZIP_SIZE_MAX)); - table_is_compressed = true; - } else { - block_size_needed = UNIV_PAGE_SIZE; - table_is_compressed = false; - } - - const page_size_t page_size(fsp_flags); - - /* The compression code needs some work in order for a general - tablespace to contain both compressed and non-compressed tables - together in the same tablespace. The problem seems to be that - each page is either compressed or not based on the fsp flags, - which is shared by all tables in that general tablespace. */ - if (table_is_compressed && page_size.physical() == UNIV_PAGE_SIZE) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Tablespace `%s` cannot contain a" - " COMPRESSED table", MYF(0), - m_create_info->tablespace); - return(false); - } - - if (block_size_needed != page_size.physical()) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Tablespace `%s` uses block size " ULINTPF - " and cannot contain a table with physical" - " page size " ULINTPF, MYF(0), - m_create_info->tablespace, - page_size.physical(), - block_size_needed); - return(false); - } - - return(true); -} -#endif - /** Validate the create options. Check that the options KEY_BLOCK_SIZE, ROW_FORMAT, DATA DIRECTORY, TEMPORARY & TABLESPACE are compatible with each other and other settings. These CREATE OPTIONS are not validated @@ -12516,20 +12275,8 @@ create_table_info_t::create_options_are_invalid() ut_ad(m_thd != NULL); ut_ad(m_create_info != NULL); -#ifdef MYSQL_TABLESPACES - /* The TABLESPACE designation on a CREATE TABLE is not subject to - non-strict-mode. If it is incorrect or is incompatible with other - options, then we will return an error. Make sure the tablespace exists - and is compatible with this table */ - if (!create_option_tablespace_is_valid()) { - return("TABLESPACE"); - } -#endif - - /* If innodb_strict_mode is not set don't do any more validation. - Also, if this table is being put into a shared general tablespace - we ALWAYS act like strict mode is ON. */ - if (!m_use_shared_space && !(THDVAR(m_thd, strict_mode))) { + /* If innodb_strict_mode is not set don't do any more validation. */ + if (!THDVAR(m_thd, strict_mode)) { return(NULL); } @@ -12560,11 +12307,6 @@ create_table_info_t::create_options_are_invalid() ret = "KEY_BLOCK_SIZE"; } - /* The following checks do not appy to shared tablespaces */ - if (m_use_shared_space) { - break; - } - /* Valid KEY_BLOCK_SIZE, check its dependencies. */ if (!m_allow_file_per_table) { push_warning( @@ -12599,47 +12341,43 @@ create_table_info_t::create_options_are_invalid() other incompatibilities. */ switch (row_format) { case ROW_TYPE_COMPRESSED: - if (!m_use_shared_space) { - if (!m_allow_file_per_table) { - push_warning_printf( - m_thd, Sql_condition::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); - ret = "ROW_FORMAT"; - } - if (srv_file_format < UNIV_FORMAT_B) { - push_warning_printf( - m_thd, Sql_condition::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); - ret = "ROW_FORMAT"; - } + if (!m_allow_file_per_table) { + push_warning_printf( + m_thd, Sql_condition::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s requires" + " innodb_file_per_table.", + get_row_format_name(row_format)); + ret = "ROW_FORMAT"; + } + if (srv_file_format < UNIV_FORMAT_B) { + push_warning_printf( + m_thd, Sql_condition::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s requires" + " innodb_file_format > Antelope.", + get_row_format_name(row_format)); + ret = "ROW_FORMAT"; } break; case ROW_TYPE_DYNAMIC: - if (!m_use_shared_space) { - if (!m_allow_file_per_table) { - push_warning_printf( - m_thd, Sql_condition::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_per_table.", - get_row_format_name(row_format)); - ret = "ROW_FORMAT"; - } - if (srv_file_format < UNIV_FORMAT_B) { - push_warning_printf( - m_thd, Sql_condition::WARN_LEVEL_WARN, - ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: ROW_FORMAT=%s requires" - " innodb_file_format > Antelope.", - get_row_format_name(row_format)); - ret = "ROW_FORMAT"; - } + if (!m_allow_file_per_table) { + push_warning_printf( + m_thd, Sql_condition::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s requires" + " innodb_file_per_table.", + get_row_format_name(row_format)); + ret = "ROW_FORMAT"; + } + if (srv_file_format < UNIV_FORMAT_B) { + push_warning_printf( + m_thd, Sql_condition::WARN_LEVEL_WARN, + ER_ILLEGAL_HA_CREATE_OPTION, + "InnoDB: ROW_FORMAT=%s requires" + " innodb_file_format > Antelope.", + get_row_format_name(row_format)); + ret = "ROW_FORMAT"; } /* FALLTRHOUGH */ case ROW_TYPE_COMPACT: @@ -12863,18 +12601,6 @@ ha_innobase::update_create_info( if (m_prebuilt->table->data_dir_path) { create_info->data_file_name = m_prebuilt->table->data_dir_path; } - - /* Update the TABLESPACE name from the Data Dictionary. */ - dict_get_and_save_space_name(m_prebuilt->table, false); - - /* Put this tablespace name into the create_info structure so that - SHOW CREATE TABLE will display TABLESPACE=name. This also affects - an ALTER TABLE which must know the current TABLESPACE so that the - table will stay there. */ - if (m_prebuilt->table->tablespace != NULL - && create_info->tablespace == NULL) { - create_info->tablespace = m_prebuilt->table->tablespace; - } } /*****************************************************************//** @@ -12929,14 +12655,12 @@ create_table_info_t::parse_table_name( m_temp_path[0] = '\0'; m_remote_path[0] = '\0'; - m_tablespace[0] = '\0'; /* A full path is provided by the server for TEMPORARY tables not targeted for a tablespace or when DATA DIRECTORY is given. So these two are not compatible. Likewise, DATA DIRECTORY is not compatible with a TABLESPACE assignment. */ - if ((m_create_info->options & HA_LEX_CREATE_TMP_TABLE) - && !m_use_shared_space) { + if ((m_create_info->options & HA_LEX_CREATE_TMP_TABLE)) { strncpy(m_temp_path, name, FN_REFLEN - 1); } @@ -12967,21 +12691,11 @@ create_table_info_t::parse_table_name( "INDEX DIRECTORY"); } - /* The TABLESPACE designation has already been validated by - create_option_tablespace_is_valid() irregardless of strict-mode. - So it only needs to be copied now. */ - if (m_use_shared_space) { - strncpy(m_tablespace, m_create_info->tablespace, - NAME_LEN - 1); - } - DBUG_RETURN(0); } /** Determine InnoDB table flags. If strict_mode=OFF, this will adjust the flags to what should be assumed. -However, if an existing general tablespace is being targeted, we will NOT -assume anything or adjust these flags. @retval true if successful, false if error */ bool create_table_info_t::innobase_table_flags() @@ -13075,7 +12789,7 @@ create_table_info_t::innobase_table_flags() } /* Make sure compressed row format is allowed. */ - if (!m_allow_file_per_table && !m_use_shared_space) { + if (!m_allow_file_per_table) { push_warning( m_thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, @@ -13084,8 +12798,7 @@ create_table_info_t::innobase_table_flags() zip_allowed = false; } - if (file_format_allowed < UNIV_FORMAT_B - && !m_use_shared_space) { + if (file_format_allowed < UNIV_FORMAT_B) { push_warning( m_thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, @@ -13148,16 +12861,14 @@ create_table_info_t::innobase_table_flags() case ROW_TYPE_COMPRESSED: /* ROW_FORMAT=COMPRESSED requires file_per_table and file_format=Barracuda unless there is a target tablespace. */ - if (!m_allow_file_per_table - && !m_use_shared_space) { + if (!m_allow_file_per_table) { push_warning_printf( m_thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, "InnoDB: ROW_FORMAT=COMPRESSED requires" " innodb_file_per_table."); - } else if (file_format_allowed == UNIV_FORMAT_A - && !m_use_shared_space) { + } else if (file_format_allowed == UNIV_FORMAT_A) { push_warning_printf( m_thd, Sql_condition::WARN_LEVEL_WARN, ER_ILLEGAL_HA_CREATE_OPTION, @@ -13215,14 +12926,13 @@ create_table_info_t::innobase_table_flags() /* Set the table flags */ dict_tf_set(&m_flags, innodb_row_format, zip_ssize, - m_use_data_dir, m_use_shared_space, + m_use_data_dir, options->page_compressed, options->page_compression_level == 0 ? default_compression_level : options->page_compression_level, 0); if (m_use_file_per_table) { - ut_ad(!m_use_shared_space); m_flags2 |= DICT_TF2_USE_FILE_PER_TABLE; } @@ -13408,18 +13118,12 @@ void create_table_info_t::set_tablespace_type( bool table_being_altered_is_file_per_table) { - /* Note whether this table will be created using a shared, - general or system tablespace. */ - m_use_shared_space = tablespace_is_shared_space(m_create_info); - /** Allow file_per_table for this table either because: 1) the setting innodb_file_per_table=on, - 2) the table being altered is currently file_per_table - 3) explicitly requested by tablespace=innodb_file_per_table. */ + 2) the table being altered is currently file_per_table */ m_allow_file_per_table = m_innodb_file_per_table - || table_being_altered_is_file_per_table - || tablespace_is_file_per_table(m_create_info); + || table_being_altered_is_file_per_table; /* All noncompresed temporary tables will be put into the system temporary tablespace. */ @@ -13429,12 +13133,10 @@ create_table_info_t::set_tablespace_type( || m_create_info->key_block_size > 0); /* Ignore the current innodb-file-per-table setting if we are - creating a temporary, non-compressed table or if the - TABLESPACE= phrase is using an existing shared tablespace. */ + creating a temporary, non-compressed table. */ m_use_file_per_table = m_allow_file_per_table - && !is_noncompressed_temporary - && !m_use_shared_space; + && !is_noncompressed_temporary; /* DATA DIRECTORY must have m_use_file_per_table but cannot be used with TEMPORARY tables. */ @@ -13443,7 +13145,6 @@ create_table_info_t::set_tablespace_type( && !(m_create_info->options & HA_LEX_CREATE_TMP_TABLE) && (m_create_info->data_file_name != NULL) && (m_create_info->data_file_name[0] != '\0'); - ut_ad(!(m_use_shared_space && m_use_data_dir)); } /** Initialize the create_table_info_t object. @@ -13871,7 +13572,6 @@ ha_innobase::create( char norm_name[FN_REFLEN]; /* {database}/{tablename} */ char temp_path[FN_REFLEN]; /* Absolute path of temp frm */ char remote_path[FN_REFLEN]; /* Absolute path of table */ - char tablespace[NAME_LEN]; /* Tablespace name identifier */ trx_t* trx; DBUG_ENTER("ha_innobase::create"); @@ -13880,8 +13580,7 @@ ha_innobase::create( create_info, norm_name, temp_path, - remote_path, - tablespace); + remote_path); /* Initialize the object. */ if ((error = info.initialize())) { @@ -13974,16 +13673,6 @@ ha_innobase::discard_or_import_tablespace( DBUG_RETURN(HA_ERR_TABLE_NEEDS_UPGRADE); } - if (DICT_TF_HAS_SHARED_SPACE(dict_table->flags)) { - my_printf_error(ER_NOT_ALLOWED_COMMAND, - "InnoDB: Cannot %s table `%s` because it is in" - " a general tablespace. It must be file-per-table.", - MYF(0), discard ? "discard" : "import", - dict_table->name.m_name); - - DBUG_RETURN(HA_ERR_NOT_ALLOWED_COMMAND); - } - TrxInInnoDB trx_in_innodb(m_prebuilt->trx); if (trx_in_innodb.is_aborted()) { @@ -14316,410 +14005,6 @@ ha_innobase::delete_table( DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); } -#ifdef MYSQL_TABLESPACES -/** Validate the parameters in st_alter_tablespace -before using them in InnoDB tablespace functions. -@param[in] thd Connection -@param[in] alter_info How to do the command. -@return MySQL handler error code like HA_... */ -static -int -validate_create_tablespace_info( - THD* thd, - st_alter_tablespace* alter_info) -{ - ulint space_id; - - /* The parser ensures that these fields are provided. */ - ut_a(alter_info->tablespace_name); - ut_a(alter_info->data_file_name); - - if (high_level_read_only) { - return(HA_ERR_INNODB_READ_ONLY); - } - - /* From this point forward, push a warning for each problem found - instead of returning immediately*/ - int error = validate_tablespace_name( - alter_info->tablespace_name, false); - - /* Make sure the tablespace is not already open. */ - space_id = fil_space_get_id_by_name(alter_info->tablespace_name); - if (space_id != ULINT_UNDEFINED) { - my_printf_error(ER_TABLESPACE_EXISTS, - "InnoDB: A tablespace named `%s`" - " already exists.", MYF(0), - alter_info->tablespace_name); - error = HA_ERR_TABLESPACE_EXISTS; - } - if (alter_info->file_block_size) { - /* Check for a bad file block size. */ - if (!ut_is_2pow(alter_info->file_block_size) - || alter_info->file_block_size < UNIV_ZIP_SIZE_MIN - || alter_info->file_block_size > UNIV_PAGE_SIZE_MAX) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB does not support" - " FILE_BLOCK_SIZE=%llu", MYF(0), - alter_info->file_block_size); - error = HA_WRONG_CREATE_OPTION; - - /* Don't allow a file block size larger than UNIV_PAGE_SIZE. */ - } else if (alter_info->file_block_size > UNIV_PAGE_SIZE) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Cannot create a tablespace" - " with FILE_BLOCK_SIZE=%llu because" - " INNODB_PAGE_SIZE=%lu.", MYF(0), - alter_info->file_block_size, - UNIV_PAGE_SIZE); - error = HA_WRONG_CREATE_OPTION; - - /* Don't allow a compressed tablespace when page size > 16k. */ - } else if (UNIV_PAGE_SIZE > UNIV_PAGE_SIZE_DEF - && alter_info->file_block_size != UNIV_PAGE_SIZE) { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: Cannot create a COMPRESSED" - " tablespace when innodb_page_size >" - " 16k.", MYF(0)); - error = HA_WRONG_CREATE_OPTION; - } - } - - /* Validate the ADD DATAFILE name. */ - char* filepath = mem_strdup(alter_info->data_file_name); - os_normalize_path(filepath); - - /* It must end with '.ibd' and contain a basename of at least - 1 character before the.ibd extension. */ - ulint dirname_len = dirname_length(filepath); - const char* basename = filepath + dirname_len; - ulint basename_len = strlen(basename); - if (basename_len < 5) { - my_error(ER_WRONG_FILE_NAME, MYF(0), - alter_info->data_file_name); - ut_free(filepath); - return(HA_WRONG_CREATE_OPTION); - } - - if (memcmp(&basename[basename_len - 4], DOT_IBD, 5)) { - my_error(ER_WRONG_FILE_NAME, MYF(0), - alter_info->data_file_name); - my_printf_error(ER_WRONG_FILE_NAME, - "An IBD filepath must end with `.ibd`.", - MYF(0)); - ut_free(filepath); - return(HA_WRONG_CREATE_OPTION); - } - - /* Do not allow an invalid colon in the file name. */ - const char* colon = strchr(filepath, ':'); - if (colon != NULL) { -#ifdef _WIN32 - /* Do not allow names like "C:name.ibd" because it - specifies the "C:" drive but allows a relative location. - It should be like "c:\". If a single colon is used it must - be the second byte the the third byte must be a separator. */ - if (colon != &filepath[1] - || (colon[1] != OS_PATH_SEPARATOR) - || NULL != strchr(&colon[1], ':')) { -#endif /* _WIN32 */ - my_error(ER_WRONG_FILE_NAME, MYF(0), - alter_info->data_file_name); - my_printf_error(ER_WRONG_FILE_NAME, - "Invalid use of ':'.", MYF(0)); - ut_free(filepath); - return(HA_WRONG_CREATE_OPTION); -#ifdef _WIN32 - } -#endif /* _WIN32 */ - } - -#ifndef _WIN32 - /* On Non-Windows platforms, '\\' is a valid file name character. - But for InnoDB datafiles, we always assume it is a directory - separator and convert these to '/' */ - if (strchr(alter_info->data_file_name, '\\') != NULL) { - ib::warn() << "Converting backslash to forward slash in" - " ADD DATAFILE " << alter_info->data_file_name; - } -#endif /* _WIN32 */ - - /* The directory path must be pre-existing. */ - Folder folder(filepath, dirname_len); - ut_free(filepath); - if (!folder.exists()) { - my_error(ER_WRONG_FILE_NAME, MYF(0), - alter_info->data_file_name); - my_printf_error(ER_WRONG_FILE_NAME, - "The directory does not exist.", MYF(0)); - return(HA_WRONG_CREATE_OPTION); - } - - /* CREATE TABLESPACE...ADD DATAFILE can be inside but not under - the datadir.*/ - if (folder_mysql_datadir > folder) { - my_error(ER_WRONG_FILE_NAME, MYF(0), - alter_info->data_file_name); - my_printf_error(ER_WRONG_FILE_NAME, - "CREATE TABLESPACE data file" - " cannot be under the datadir.", MYF(0)); - error = HA_WRONG_CREATE_OPTION; - } - - return(error); -} - -/** CREATE a tablespace. -@param[in] hton Handlerton of InnoDB -@param[in] thd Connection -@param[in] alter_info How to do the command -@return MySQL error code*/ -static -int -innobase_create_tablespace( - handlerton* hton, - THD* thd, - st_alter_tablespace* alter_info) -{ - trx_t* trx; - int error=0; - Tablespace tablespace; - - DBUG_ENTER("innobase_create_tablespace"); - DBUG_ASSERT(hton == innodb_hton_ptr); - - /* Be sure the input parameters are valid before continuing. */ - error = validate_create_tablespace_info(thd, alter_info); - if (error) { - DBUG_RETURN(error); - } - - /* Create the tablespace object. */ - tablespace.set_name(alter_info->tablespace_name); - - dberr_t err = tablespace.add_datafile(alter_info->data_file_name); - if (err != DB_SUCCESS) { - DBUG_RETURN(convert_error_code_to_mysql(err, 0, NULL)); - } - - /* Get the transaction associated with the current thd and make - sure it will not block this DDL. */ - trx_t* parent_trx = check_trx_exists(thd); - - /* In case MySQL calls this in the middle of a SELECT - query, release possible adaptive hash latch to avoid - deadlocks of threads */ - trx_search_latch_release_if_reserved(parent_trx); - - /* Allocate a new transaction for this DDL */ - trx = innobase_trx_allocate(thd); - ++trx->will_lock; - - trx_start_if_not_started(trx, true); - row_mysql_lock_data_dictionary(trx); - - /* In FSP_FLAGS, a zip_ssize of zero means that the tablespace - holds non-compresssed tables. A non-zero zip_ssize means that - the general tablespace can ONLY contain compressed tables. */ - ulint zip_size = static_cast(alter_info->file_block_size); - ut_ad(zip_size <= UNIV_PAGE_SIZE_MAX); - if (zip_size == 0) { - zip_size = UNIV_PAGE_SIZE; - } - - bool zipped = (zip_size != UNIV_PAGE_SIZE); - page_size_t page_size(zip_size, UNIV_PAGE_SIZE, zipped); - bool atomic_blobs = page_size.is_compressed(); - - /* Create the filespace flags */ - ulint fsp_flags = fsp_flags_init( - page_size, /* page sizes and a flag if compressed */ - atomic_blobs, /* needed only for compressed tables */ - false, /* This is not a file-per-table tablespace */ - true, /* This is a general shared tablespace */ - false, /* Temporary General Tablespaces not allowed */ - false, /* Page compression is not used. */ - 0, /* Page compression level 0 */ - 0); - - tablespace.set_flags(fsp_flags); - - err = dict_build_tablespace(&tablespace); - if (err != DB_SUCCESS) { - error = convert_error_code_to_mysql(err, 0, NULL); - trx_rollback_for_mysql(trx); - goto cleanup; - } - - innobase_commit_low(trx); - -cleanup: - row_mysql_unlock_data_dictionary(trx); - trx_free_for_mysql(trx); - - DBUG_RETURN(error); -} - -/** DROP a tablespace. -@param[in] hton Handlerton of InnoDB -@param[in] thd Connection -@param[in] alter_info How to do the command -@return MySQL error code*/ -static -int -innobase_drop_tablespace( - handlerton* hton, - THD* thd, - st_alter_tablespace* alter_info) -{ - trx_t* trx; - dberr_t err; - int error = 0; - ulint space_id; - - DBUG_ENTER("innobase_drop_tablespace"); - DBUG_ASSERT(hton == innodb_hton_ptr); - - if (srv_read_only_mode) { - DBUG_RETURN(HA_ERR_INNODB_READ_ONLY); - } - - error = validate_tablespace_name(alter_info->tablespace_name, false); - if (error != 0) { - DBUG_RETURN(error); - } - - /* Be sure that this tablespace is known and valid. */ - space_id = fil_space_get_id_by_name(alter_info->tablespace_name); - if (space_id == ULINT_UNDEFINED) { - - space_id = dict_space_get_id(alter_info->tablespace_name); - if (space_id == ULINT_UNDEFINED) { - DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); - // DBUG_RETURN(HA_ERR_TABLESPACE_MISSING); - } - - /* The datafile is not open but the tablespace is in - sys_tablespaces, so we can try to drop the metadata. */ - } - - /* The tablespace can only be dropped if it is empty. */ - if (!dict_space_is_empty(space_id)) { - DBUG_RETURN(HA_ERR_TABLE_READONLY); - //DBUG_RETURN(HA_ERR_TABLESPACE_IS_NOT_EMPTY); - } - - /* Get the transaction associated with the current thd and make sure - it will not block this DDL. */ - trx_t* parent_trx = check_trx_exists(thd); - - /* In case MySQL calls this in the middle of a SELECT - query, release possible adaptive hash latch to avoid - deadlocks of threads */ - trx_search_latch_release_if_reserved(parent_trx); - - /* Allocate a new transaction for this DDL */ - trx = innobase_trx_allocate(thd); - ++trx->will_lock; - - trx_start_if_not_started(trx, true); - row_mysql_lock_data_dictionary(trx); - - /* Update SYS_TABLESPACES and SYS_DATAFILES */ - err = dict_delete_tablespace_and_datafiles(space_id, trx); - if (err != DB_SUCCESS) { - ib::error() << "Unable to delete the dictionary entries" - " for tablespace `" << alter_info->tablespace_name - << "`, Space ID " << space_id; - goto have_error; - } - - /* Delete the physical files, fil_space_t & fil_node_t entries. */ - err = fil_delete_tablespace(space_id, BUF_REMOVE_FLUSH_NO_WRITE); - switch (err) { - case DB_TABLESPACE_NOT_FOUND: - /* OK if the physical file is mising. - We deleted the metadata. */ - case DB_SUCCESS: - innobase_commit_low(trx); - break; - default: - ib::error() << "Unable to delete the tablespace `" - << alter_info->tablespace_name - << "`, Space ID " << space_id; -have_error: - error = convert_error_code_to_mysql(err, 0, NULL); - trx_rollback_for_mysql(trx); - } - - row_mysql_unlock_data_dictionary(trx); - trx_free_for_mysql(trx); - - DBUG_RETURN(error); -} - -/** This API handles CREATE, ALTER & DROP commands for InnoDB tablespaces. -@param[in] hton Handlerton of InnoDB -@param[in] thd Connection -@param[in] alter_info How to do the command -@return MySQL error code*/ -static -int -innobase_alter_tablespace( - handlerton* hton, - THD* thd, - st_alter_tablespace* alter_info) -{ - int error; /* return zero for success */ - DBUG_ENTER("innobase_alter_tablespace"); - - switch (alter_info->ts_cmd_type) { - case CREATE_TABLESPACE: - error = innobase_create_tablespace(hton, thd, alter_info); - break; - - case DROP_TABLESPACE: - error = innobase_drop_tablespace(hton, thd, alter_info); - break; - - default: - error = HA_ADMIN_NOT_IMPLEMENTED; - } - - if (error) { - /* These are the most common message params */ - const char* object_type = "TABLESPACE"; - const char* object = alter_info->tablespace_name; - - /* Modify those params as needed. */ - switch (alter_info->ts_cmd_type) { - case DROP_TABLESPACE: - ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_DROP_FILEGROUP_FAILED, - "%s %s", object_type, object); - break; - case CREATE_TABLESPACE: - ib_errf(thd, IB_LOG_LEVEL_ERROR, - ER_CREATE_FILEGROUP_FAILED, - "%s %s", object_type, object); - break; - case CREATE_LOGFILE_GROUP: - my_error(ER_ILLEGAL_HA_CREATE_OPTION, MYF(0), - innobase_hton_name, "LOGFILE GROUP"); - break; - case ALTER_TABLESPACE: - case ALTER_ACCESS_MODE_TABLESPACE: - case DROP_LOGFILE_GROUP: - case ALTER_LOGFILE_GROUP: - case CHANGE_FILE_TABLESPACE: - case TS_CMD_NOT_DEFINED: - break; - } - } - - DBUG_RETURN(error); -} -#endif /* MYSQL_TABLESPACES */ - /** Remove all tables in the named database inside InnoDB. @param[in] hton handlerton from InnoDB @param[in] path Database path; Inside InnoDB the name of the last diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 8d879207fab2b..066eff12ca9c3 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -23,19 +23,6 @@ this program; if not, write to the Free Software Foundation, Inc., system clustered index when there is no primary key. */ extern const char innobase_index_reserve_name[]; -/* "innodb_file_per_table" tablespace name is reserved by InnoDB in order -to explicitly create a file_per_table tablespace for the table. */ -extern const char reserved_file_per_table_space_name[]; - -/* "innodb_system" tablespace name is reserved by InnoDB for the -system tablespace which uses space_id 0 and stores extra types of -system pages like UNDO and doublewrite. */ -extern const char reserved_system_space_name[]; - -/* "innodb_temporary" tablespace name is reserved by InnoDB for the -predefined shared temporary tablespace. */ -extern const char reserved_temporary_space_name[]; - /* Structure defines translation table between mysql index and InnoDB index structures */ struct innodb_idx_translate_t { @@ -677,52 +664,6 @@ extern const char reserved_file_per_table_space_name[]; //extern "C" int wsrep_trx_is_aborting(void *thd_ptr); #endif -/** Check if the explicit tablespace targeted is file_per_table. -@param[in] create_info Metadata for the table to create. -@return true if the table is intended to use a file_per_table tablespace. */ -UNIV_INLINE -bool -tablespace_is_file_per_table( - const HA_CREATE_INFO* create_info) -{ - return(create_info->tablespace != NULL - && (0 == strcmp(create_info->tablespace, - reserved_file_per_table_space_name))); -} - -/** Check if table will be explicitly put in an existing shared general -or system tablespace. -@param[in] create_info Metadata for the table to create. -@return true if the table will use a shared general or system tablespace. */ -UNIV_INLINE -bool -tablespace_is_shared_space( -const HA_CREATE_INFO* create_info) -{ - return(create_info->tablespace != NULL - && create_info->tablespace[0] != '\0' - && (0 != strcmp(create_info->tablespace, - reserved_file_per_table_space_name))); -} - -/** Check if table will be explicitly put in a general tablespace. -@param[in] create_info Metadata for the table to create. -@return true if the table will use a general tablespace. */ -UNIV_INLINE -bool -tablespace_is_general_space( - const HA_CREATE_INFO* create_info) -{ - return(create_info->tablespace != NULL - && create_info->tablespace[0] != '\0' - && (0 != strcmp(create_info->tablespace, - reserved_file_per_table_space_name)) - && (0 != strcmp(create_info->tablespace, - reserved_temporary_space_name)) - && (0 != strcmp(create_info->tablespace, - reserved_system_space_name))); -} - /** Parse hint for table and its indexes, and update the information in dictionary. @param[in] thd Connection thread @@ -748,15 +689,13 @@ class create_table_info_t HA_CREATE_INFO* create_info, char* table_name, char* temp_path, - char* remote_path, - char* tablespace) + char* remote_path) :m_thd(thd), m_form(form), m_create_info(create_info), m_table_name(table_name), m_temp_path(temp_path), m_remote_path(remote_path), - m_tablespace(tablespace), m_innodb_file_per_table(srv_file_per_table) {} @@ -875,9 +814,6 @@ class create_table_info_t /** Remote path (DATA DIRECTORY) or zero length-string */ char* m_remote_path; - /** Tablespace name or zero length-string. */ - char* m_tablespace; - /** Local copy of srv_file_per_table. */ bool m_innodb_file_per_table; @@ -894,9 +830,6 @@ class create_table_info_t /** Using DATA DIRECTORY */ bool m_use_data_dir; - /** Using a Shared General Tablespace */ - bool m_use_shared_space; - /** Table flags */ ulint m_flags; diff --git a/storage/innobase/handler/ha_innopart.cc b/storage/innobase/handler/ha_innopart.cc index 09a60be157701..80f3b410ee773 100644 --- a/storage/innobase/handler/ha_innopart.cc +++ b/storage/innobase/handler/ha_innopart.cc @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. -Copyright (c) 2016, MariaDB Corporation. +Copyright (c) 2016, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -2464,35 +2464,6 @@ ha_innopart::update_part_elem( } part_elem->index_file_name = NULL; - dict_get_and_save_space_name(ib_table, false); - if (ib_table->tablespace != NULL) { - ut_ad(part_elem->tablespace_name == NULL - || 0 == strcmp(part_elem->tablespace_name, - ib_table->tablespace)); - if (part_elem->tablespace_name == NULL - || strcmp(ib_table->tablespace, - part_elem->tablespace_name) != 0) { - - /* Play safe and allocate memory from TABLE and copy - instead of expose the internal data dictionary. */ - part_elem->tablespace_name = - strdup_root(&table->mem_root, - ib_table->tablespace); - } - } - else { - ut_ad(part_elem->tablespace_name == NULL - || 0 == strcmp(part_elem->tablespace_name, - "innodb_file_per_table")); - if (part_elem->tablespace_name != NULL - && 0 != strcmp(part_elem->tablespace_name, - "innodb_file_per_table")) { - - /* Update part_elem tablespace to NULL same as in - innodb data dictionary ib_table. */ - part_elem->tablespace_name = NULL; - } - } } /** Update create_info. @@ -2558,7 +2529,7 @@ ha_innopart::update_create_info( DBUG_VOID_RETURN; } - /* part_elem->data_file_name and tablespace_name should be correct from + /* part_elem->data_file_name should be correct from the .frm, but may have been changed, so update from SYS_DATAFILES. index_file_name is ignored, so remove it. */ @@ -2592,17 +2563,11 @@ set_create_info_dir( if (part_elem->data_file_name != NULL && part_elem->data_file_name[0] != '\0') { info->data_file_name = part_elem->data_file_name; - /* Also implies non-default tablespace. */ - info->tablespace = NULL; } if (part_elem->index_file_name != NULL && part_elem->index_file_name[0] != '\0') { info->index_file_name = part_elem->index_file_name; } - if (part_elem->tablespace_name != NULL - && part_elem->tablespace_name[0] != '\0') { - info->tablespace = part_elem->tablespace_name; - } } /** Set flags and append '/' to remote path if necessary. */ @@ -2647,12 +2612,10 @@ ha_innopart::create( /** absolute path of table */ char remote_path[FN_REFLEN]; char partition_name[FN_REFLEN]; - char tablespace_name[NAME_LEN + 1]; char* table_name_end; size_t table_name_len; char* partition_name_start; char table_data_file_name[FN_REFLEN]; - char table_level_tablespace_name[NAME_LEN + 1]; const char* index_file_name; size_t len; @@ -2661,8 +2624,7 @@ ha_innopart::create( create_info, table_name, temp_path, - remote_path, - tablespace_name); + remote_path); DBUG_ENTER("ha_innopart::create"); ut_ad(create_info != NULL); @@ -2708,11 +2670,6 @@ ha_innopart::create( table_data_file_name[0] = '\0'; } index_file_name = create_info->index_file_name; - if (create_info->tablespace != NULL) { - strcpy(table_level_tablespace_name, create_info->tablespace); - } else { - table_level_tablespace_name[0] = '\0'; - } info.allocate_trx(); @@ -2798,15 +2755,12 @@ ha_innopart::create( table_data_file_name; create_info->index_file_name = index_file_name; - create_info->tablespace = - table_level_tablespace_name; set_create_info_dir(part_elem, create_info); } } /* Reset table level DATA/INDEX DIRECTORY. */ create_info->data_file_name = table_data_file_name; create_info->index_file_name = index_file_name; - create_info->tablespace = table_level_tablespace_name; } innobase_commit_low(info.trx()); @@ -4238,27 +4192,13 @@ ha_innopart::create_new_partition( { int error; char norm_name[FN_REFLEN]; - const char* tablespace_name_backup = create_info->tablespace; const char* data_file_name_backup = create_info->data_file_name; DBUG_ENTER("ha_innopart::create_new_partition"); /* Delete by ddl_log on failure. */ normalize_table_name(norm_name, part_name); set_create_info_dir(part_elem, create_info); - /* The below check is the same as for CREATE TABLE, but since we are - doing an alter here it will not trigger the check in - create_option_tablespace_is_valid(). */ - if (tablespace_is_shared_space(create_info) - && create_info->data_file_name != NULL - && create_info->data_file_name[0] != '\0') { - my_printf_error(ER_ILLEGAL_HA_CREATE_OPTION, - "InnoDB: DATA DIRECTORY cannot be used" - " with a TABLESPACE assignment.", MYF(0)); - DBUG_RETURN(HA_WRONG_CREATE_OPTION); - } - error = ha_innobase::create(norm_name, table, create_info); - create_info->tablespace = tablespace_name_backup; create_info->data_file_name = data_file_name_backup; if (error == HA_ERR_FOUND_DUPP_KEY) { DBUG_RETURN(HA_ERR_TABLE_EXIST); diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 6b6667b5e56c9..8ba9f6cb175d7 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4579,20 +4579,6 @@ prepare_inplace_alter_table_dict( goto new_clustered_failed; } - /* Use the old tablespace unless the tablespace - is changing. */ - if (DICT_TF_HAS_SHARED_SPACE(user_table->flags) - && (ha_alter_info->create_info->tablespace == NULL - || (0 == strcmp(ha_alter_info->create_info->tablespace, - user_table->tablespace)))) { - space_id = user_table->space; - } else if (tablespace_is_shared_space( - ha_alter_info->create_info)) { - space_id = fil_space_get_id_by_name( - ha_alter_info->create_info->tablespace); - ut_a(space_id != ULINT_UNDEFINED); - } - /* The initial space id 0 may be overridden later if this table is going to be a file_per_table tablespace. */ ctx->new_table = dict_mem_table_create( @@ -5596,37 +5582,16 @@ ha_innobase::prepare_inplace_alter_table( /* ALTER TABLE will not implicitly move a table from a single-table tablespace to the system tablespace when innodb_file_per_table=OFF. But it will implicitly move a table from the system tablespace to a - single-table tablespace if innodb_file_per_table = ON. - Tables found in a general tablespace will stay there unless ALTER - TABLE contains another TABLESPACE=name. If that is found it will - explicitly move a table to the named tablespace. - So if you specify TABLESPACE=`innodb_system` a table can be moved - into the system tablespace from either a general or file-per-table - tablespace. But from then on, it is labeled as using a shared space - (the create options have tablespace=='innodb_system' and the - SHARED_SPACE flag is set in the table flags) so it can no longer be - implicitly moved to a file-per-table tablespace. */ - bool in_system_space = is_system_tablespace(indexed_table->space); - bool is_file_per_table = !in_system_space - && !DICT_TF_HAS_SHARED_SPACE(indexed_table->flags); -#ifdef UNIV_DEBUG - bool in_general_space = !in_system_space - && DICT_TF_HAS_SHARED_SPACE(indexed_table->flags); - - /* The table being altered can only be in a system tablespace, - or its own file-per-table tablespace, or a general tablespace. */ - ut_ad(1 == in_system_space + is_file_per_table + in_general_space); -#endif /* UNIV_DEBUG */ + single-table tablespace if innodb_file_per_table = ON. */ create_table_info_t info(m_user_thd, altered_table, ha_alter_info->create_info, NULL, NULL, - NULL, NULL); - info.set_tablespace_type(is_file_per_table); + info.set_tablespace_type(indexed_table->space != TRX_SYS_SPACE); if (ha_alter_info->handler_flags & Alter_inplace_info::ADD_INDEX) { if (info.gcols_in_fulltext_or_spatial()) { diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index 01fadaf8e10e0..a400ee5475896 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -6050,8 +6050,6 @@ i_s_dict_fill_sys_tables( if (is_system_tablespace(table->space)) { space_type = "System"; - } else if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - space_type = "General"; } else { space_type = "Single"; } @@ -8045,9 +8043,6 @@ i_s_dict_fill_sys_tablespaces( file_format = trx_sys_file_format_id_to_name(atomic_blobs); if (is_system_tablespace(space)) { row_format = "Compact or Redundant"; - } else if (fsp_is_shared_tablespace(flags) && !is_compressed) { - file_format = "Any"; - row_format = "Any"; } else if (is_compressed) { row_format = "Compressed"; } else if (atomic_blobs) { @@ -8058,8 +8053,6 @@ i_s_dict_fill_sys_tablespaces( if (is_system_tablespace(space)) { space_type = "System"; - } else if (fsp_is_shared_tablespace(flags)) { - space_type = "General"; } else { space_type = "Single"; } @@ -8089,8 +8082,7 @@ i_s_dict_fill_sys_tablespaces( space_type)); char* filepath = NULL; - if (FSP_FLAGS_HAS_DATA_DIR(flags) - || FSP_FLAGS_GET_SHARED(flags)) { + if (FSP_FLAGS_HAS_DATA_DIR(flags)) { mutex_enter(&dict_sys->mutex); filepath = dict_get_first_path(space); mutex_exit(&dict_sys->mutex); diff --git a/storage/innobase/include/db0err.h b/storage/innobase/include/db0err.h index ab505e040832e..316d90bec346c 100644 --- a/storage/innobase/include/db0err.h +++ b/storage/innobase/include/db0err.h @@ -154,8 +154,6 @@ enum dberr_t { DB_TABLE_CORRUPT, /*!< Table/clustered index is corrupted */ - DB_WRONG_FILE_NAME, /*!< Invalid Filename */ - DB_COMPUTE_VALUE_FAILED, /*!< Compute generated value failed */ DB_NO_FK_ON_S_BASE_COL, /*!< Cannot add foreign constrain diff --git a/storage/innobase/include/dict0crea.h b/storage/innobase/include/dict0crea.h index 51cef91d3184a..9065f7ebf3d06 100644 --- a/storage/innobase/include/dict0crea.h +++ b/storage/innobase/include/dict0crea.h @@ -67,13 +67,6 @@ dict_create_table_step( /*===================*/ que_thr_t* thr); /*!< in: query thread */ -/** Builds a tablespace to store various objects. -@param[in,out] tablespace Tablespace object describing what to build. -@return DB_SUCCESS or error code. */ -dberr_t -dict_build_tablespace( - Tablespace* tablespace); - /** Builds a tablespace to contain a table, using file-per-table=1. @param[in,out] table Table to build in its own tablespace. @param[in] node Table create node diff --git a/storage/innobase/include/dict0dict.h b/storage/innobase/include/dict0dict.h index b29e6aedcc080..a7fe80e447d44 100644 --- a/storage/innobase/include/dict0dict.h +++ b/storage/innobase/include/dict0dict.h @@ -992,7 +992,9 @@ dict_tf_get_format( @param[in] format, File Format @param[in] zip_ssize Zip Shift Size @param[in] use_data_dir Table uses DATA DIRECTORY -@param[in] shared_space Table uses a General Shared Tablespace */ +@param[in] page_compressed Table uses page compression +@param[in] page_compression_level Page compression level +@param[in] not_used For future */ UNIV_INLINE void dict_tf_set( @@ -1000,7 +1002,6 @@ dict_tf_set( rec_format_t format, ulint zip_ssize, bool use_data_dir, - bool shared_space, bool page_compressed, ulint page_compression_level, ulint not_used); @@ -1010,7 +1011,9 @@ dict_tf_set( @param[in] zip_ssize Zip Shift Size (log 2 minus 9) @param[in] atomic_blobs Table uses Compressed or Dynamic @param[in] data_dir Table uses DATA DIRECTORY -@param[in] shared_space Table uses a General Shared Tablespace */ +@param[in] page_compressed Table uses page compression +@param[in] page_compression_level Page compression level +@param[in] not_used For future */ UNIV_INLINE ulint dict_tf_init( @@ -1018,7 +1021,6 @@ dict_tf_init( ulint zip_ssize, bool atomic_blobs, bool data_dir, - bool shared_space, bool page_compressed, ulint page_compression_level, ulint not_used); @@ -1973,15 +1975,6 @@ dict_table_is_temporary( const dict_table_t* table) /*!< in: table to check */ MY_ATTRIBUTE((warn_unused_result)); -/** Check if the table is in a shared tablespace (System or General). -@param[in] id Space ID to check -@return true if id is a shared tablespace, false if not. */ -UNIV_INLINE -bool -dict_table_in_shared_tablespace( - const dict_table_t* table) - MY_ATTRIBUTE((warn_unused_result)); - /********************************************************************//** Turn-off redo-logging if temporary table. */ UNIV_INLINE diff --git a/storage/innobase/include/dict0dict.ic b/storage/innobase/include/dict0dict.ic index c8624ea8b7dee..3bb00294bfa94 100644 --- a/storage/innobase/include/dict0dict.ic +++ b/storage/innobase/include/dict0dict.ic @@ -660,7 +660,6 @@ dict_tf_is_valid( ulint zip_ssize = DICT_TF_GET_ZIP_SSIZE(flags); bool atomic_blobs = DICT_TF_HAS_ATOMIC_BLOBS(flags); bool data_dir = DICT_TF_HAS_DATA_DIR(flags); - bool shared_space = DICT_TF_HAS_SHARED_SPACE(flags); ulint unused = DICT_TF_GET_UNUSED(flags); bool page_compression = DICT_TF_GET_PAGE_COMPRESSION(flags); ulint page_compression_level = DICT_TF_GET_PAGE_COMPRESSION_LEVEL(flags); @@ -711,11 +710,6 @@ dict_tf_is_valid( } - /* HAS_DATA_DIR and SHARED_SPACE are mutually exclusive. */ - if (data_dir && shared_space) { - flags_corrupt = true; - } - if (flags_corrupt) { ib::error() << "InnoDB: Error: table unused flags are:" << flags @@ -726,8 +720,7 @@ dict_tf_is_valid( << " data_dir:" << data_dir << " zip_ssize:" << zip_ssize << " page_compression:" << page_compression - << " page_compression_level:" << page_compression_level - << " shared_space:" << shared_space; + << " page_compression_level:" << page_compression_level; return (false); } else { return(true); @@ -753,13 +746,6 @@ dict_tf2_is_valid( return(false); } - bool file_per_table = ((flags2 & DICT_TF2_USE_FILE_PER_TABLE) != 0); - bool shared_space = DICT_TF_HAS_SHARED_SPACE(flags); - - if (file_per_table && shared_space) { - return(false); - } - return(true); } @@ -931,7 +917,6 @@ dict_table_get_format( @param[in] format File Format @param[in] zip_ssize Zip Shift Size @param[in] use_data_dir Table uses DATA DIRECTORY -@param[in] shared_space Table uses a General Shared Tablespace @param[in] page_compressed Table uses page compression @param[in] page_compression_level Page compression level @param[in] not_used For future */ @@ -943,7 +928,6 @@ dict_tf_set( rec_format_t format, ulint zip_ssize, bool use_data_dir, - bool shared_space, bool page_compressed, ulint page_compression_level, ulint not_used) @@ -973,10 +957,6 @@ dict_tf_set( *flags |= (1 << DICT_TF_POS_DATA_DIR); } - if (shared_space) { - *flags |= (1 << DICT_TF_POS_SHARED_SPACE); - } - if (page_compressed) { *flags |= (1 << DICT_TF_POS_ATOMIC_BLOBS) | (1 << DICT_TF_POS_PAGE_COMPRESSION) @@ -993,7 +973,6 @@ dict_tf_set( @param[in] zip_ssize Zip Shift Size (log 2 minus 9) @param[in] atomic_blobs Table uses Compressed or Dynamic @param[in] data_dir Table uses DATA DIRECTORY -@param[in] shared_space Table uses a General Shared Tablespace @param[in] page_compression Table uses page compression @param[in] page_compression_level used compression level @param[in] not_used For future */ @@ -1004,7 +983,6 @@ dict_tf_init( ulint zip_ssize, bool atomic_blobs, bool data_dir, - bool shared_space, bool page_compressed, ulint page_compression_level, ulint not_used) @@ -1027,10 +1005,6 @@ dict_tf_init( flags |= (1 << DICT_TF_POS_DATA_DIR); } - if (shared_space) { - flags |= (1 << DICT_TF_POS_SHARED_SPACE); - } - if (page_compressed) { flags |= (1 << DICT_TF_POS_ATOMIC_BLOBS) | (1 << DICT_TF_POS_PAGE_COMPRESSION) @@ -1073,8 +1047,7 @@ dict_sys_tables_type_to_tf( | DICT_TF_MASK_ATOMIC_BLOBS | DICT_TF_MASK_DATA_DIR | DICT_TF_MASK_PAGE_COMPRESSION - | DICT_TF_MASK_PAGE_COMPRESSION_LEVEL - | DICT_TF_MASK_SHARED_SPACE); + | DICT_TF_MASK_PAGE_COMPRESSION_LEVEL); ut_ad(!DICT_TF_GET_ZIP_SSIZE(flags) || DICT_TF_HAS_ATOMIC_BLOBS(flags)); return(flags); @@ -1109,8 +1082,7 @@ dict_tf_to_sys_tables_type( | DICT_TF_MASK_ATOMIC_BLOBS | DICT_TF_MASK_DATA_DIR | DICT_TF_MASK_PAGE_COMPRESSION - | DICT_TF_MASK_PAGE_COMPRESSION_LEVEL - | DICT_TF_MASK_SHARED_SPACE); + | DICT_TF_MASK_PAGE_COMPRESSION_LEVEL); return(type); } @@ -1744,18 +1716,6 @@ dict_table_is_temporary( return(DICT_TF2_FLAG_IS_SET(table, DICT_TF2_TEMPORARY)); } -/** Check if the table is in a shared tablespace (System or General). -@param[in] id Space ID to check -@return true if id is a shared tablespace, false if not. */ -UNIV_INLINE -bool -dict_table_in_shared_tablespace( - const dict_table_t* table) -{ - return(is_system_tablespace(table->space) - || DICT_TF_HAS_SHARED_SPACE(table->flags)); -} - /********************************************************************//** Turn-off redo-logging if temporary table. */ UNIV_INLINE @@ -1778,8 +1738,8 @@ A patch was added to v3.23.52 which initializes the MIX_LEN field to 0. Since file-per-table tablespaces were added in 4.1, any SYS_TABLES record with a non-zero space ID will have a reliable MIX_LEN field. However, this test does not use flags2 from SYS_TABLES.MIX_LEN. Instead, -assume that if the tablespace is not a predefined system tablespace and it -is not a general shared tablespace, then it must be file-per-table. +assume that if the tablespace is not a predefined system tablespace, + then it must be file-per-table. Also, during ALTER TABLE, the DICT_TF2_USE_FILE_PER_TABLE flag may not be set on one of the file-per-table tablespaces. This test cannot be done on a table in the process of being created @@ -1792,8 +1752,7 @@ dict_table_is_file_per_table( const dict_table_t* table) /*!< in: table to check */ { bool is_file_per_table = - !is_system_tablespace(table->space) - && !DICT_TF_HAS_SHARED_SPACE(table->flags); + !is_system_tablespace(table->space); /* If the table is file-per-table and it is not redundant, then it should have the flags2 bit for DICT_TF2_USE_FILE_PER_TABLE. */ @@ -1801,7 +1760,7 @@ dict_table_is_file_per_table( || !DICT_TF_GET_COMPACT(table->flags) || DICT_TF2_FLAG_IS_SET(table, DICT_TF2_USE_FILE_PER_TABLE)); - return(is_file_per_table ); + return(is_file_per_table); } /** Get reference count. @@ -1833,20 +1792,6 @@ dict_table_t::release() --n_ref_count; } -/** Check if tablespace name is "innodb_general". -@param[in] tablespace_name tablespace name -@retval true if name is "innodb_general" -@retval false if name is not "innodb_general" */ -inline -bool -dict_table_has_temp_general_tablespace_name( - const char* tablespace_name) { - - return(tablespace_name != NULL - && strncmp(tablespace_name, general_space_name, - strlen(general_space_name)) == 0); -} - /** Encode the number of columns and number of virtual columns in a 4 bytes value. We could do this because the number of columns in InnoDB is limited to 1017 diff --git a/storage/innobase/include/dict0load.h b/storage/innobase/include/dict0load.h index 6d01c38c43217..0a862bb17a947 100644 --- a/storage/innobase/include/dict0load.h +++ b/storage/innobase/include/dict0load.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 1996, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -201,15 +202,6 @@ dict_get_and_save_data_dir_path( dict_table_t* table, bool dict_mutex_own); -/** Make sure the tablespace name is saved in dict_table_t if needed. -Try to read it from the file dictionary first, then from SYS_TABLESPACES. -@param[in] table Table object -@param[in] dict_mutex_own) true if dict_sys->mutex is owned already */ -void -dict_get_and_save_space_name( - dict_table_t* table, - bool dict_mutex_own); - /** Loads a table definition and also all its index definitions, and also the cluster definition if the table is a member in a cluster. Also loads all foreign key constraints where the foreign key is in the table or where diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 68d2f5d07fabb..6717e7085c2e0 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -137,12 +137,8 @@ This flag prevents older engines from attempting to open the table and allows InnoDB to update_create_info() accordingly. */ #define DICT_TF_WIDTH_DATA_DIR 1 -/** Width of the SHARED tablespace flag. -It is used to identify tables that exist inside a shared general tablespace. -If a table is created with the TABLESPACE=tsname option, an older engine will -not be able to find that table. This flag prevents older engines from attempting -to open the table and allows InnoDB to quickly find the tablespace. */ - +/** Width of the SHARED tablespace flag (Oracle MYSQL 5.7). +Not supported by MariaDB. */ #define DICT_TF_WIDTH_SHARED_SPACE 1 /** @@ -226,10 +222,6 @@ DEFAULT=0, ON = 1, OFF = 2 #define DICT_TF_MASK_DATA_DIR \ ((~(~0U << DICT_TF_WIDTH_DATA_DIR)) \ << DICT_TF_POS_DATA_DIR) -/** Bit mask of the SHARED_SPACE field */ -#define DICT_TF_MASK_SHARED_SPACE \ - ((~(~0U << DICT_TF_WIDTH_SHARED_SPACE)) \ - << DICT_TF_POS_SHARED_SPACE) /** Bit mask of the PAGE_COMPRESSION field */ #define DICT_TF_MASK_PAGE_COMPRESSION \ ((~(~0U << DICT_TF_WIDTH_PAGE_COMPRESSION)) \ @@ -267,10 +259,6 @@ DEFAULT=0, ON = 1, OFF = 2 #define DICT_TF_HAS_DATA_DIR(flags) \ ((flags & DICT_TF_MASK_DATA_DIR) \ >> DICT_TF_POS_DATA_DIR) -/** Return the value of the SHARED_SPACE field */ -#define DICT_TF_HAS_SHARED_SPACE(flags) \ - ((flags & DICT_TF_MASK_SHARED_SPACE) \ - >> DICT_TF_POS_SHARED_SPACE) /** Return the value of the PAGE_COMPRESSION field */ #define DICT_TF_GET_PAGE_COMPRESSION(flags) \ ((flags & DICT_TF_MASK_PAGE_COMPRESSION) \ @@ -307,7 +295,8 @@ for unknown bits in order to protect backward incompatibility. */ /* @{ */ /** Total number of bits in table->flags2. */ #define DICT_TF2_BITS 9 -#define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS) +#define DICT_TF2_UNUSED_BIT_MASK (~0U << DICT_TF2_BITS | \ + 1U << DICT_TF_POS_SHARED_SPACE) #define DICT_TF2_BIT_MASK ~DICT_TF2_UNUSED_BIT_MASK /** TEMPORARY; TRUE for tables from CREATE TEMPORARY TABLE. */ @@ -1395,10 +1384,6 @@ struct dict_table_t { /** NULL or the directory path specified by DATA DIRECTORY. */ char* data_dir_path; - /** NULL or the tablespace name that this table is assigned to, - specified by the TABLESPACE option.*/ - id_name_t tablespace; - /** Space where the clustered index of the table is placed. */ uint32_t space; diff --git a/storage/innobase/include/fil0fil.h b/storage/innobase/include/fil0fil.h index 0788f84d11a97..eebe21d85bf58 100644 --- a/storage/innobase/include/fil0fil.h +++ b/storage/innobase/include/fil0fil.h @@ -38,8 +38,6 @@ Created 10/25/1995 Heikki Tuuri #include #include -extern const char general_space_name[]; - // Forward declaration struct trx_t; class page_id_t; @@ -256,101 +254,10 @@ extern const char* dot_ext[]; #define DOT_ISL dot_ext[ISL] #define DOT_CFG dot_ext[CFG] -/** Wrapper for a path to a directory. -This folder may or may not yet esist. Since not all directory paths -end in "/", we should only use this for a directory path or a filepath -that has a ".ibd" extension. */ -class Folder -{ -public: - /** Default constructor */ - Folder() : m_folder(NULL) {} - - /** Constructor - @param[in] path pathname (not necessarily NUL-terminated) - @param[in] len length of the path, in bytes */ - Folder(const char* path, size_t len); - - /** Assignment operator - @param[in] folder folder string provided */ - class Folder& operator=(const char* path); - - /** Destructor */ - ~Folder() - { - ut_free(m_folder); - } - - /** Implicit type conversion - @return the wrapped object */ - operator const char*() const - { - return(m_folder); - } - - /** Explicit type conversion - @return the wrapped object */ - const char* operator()() const - { - return(m_folder); - } - - /** return the length of m_folder - @return the length of m_folder */ - size_t len() - { - return m_folder_len; - } - - /** Determine if two folders are equal - @param[in] other folder to compare to - @return whether the folders are equal */ - bool operator==(const Folder& other) const; - - /** Determine if the left folder is the same or an ancestor of - (contains) the right folder. - @param[in] other folder to compare to - @return whether this is the same or an ancestor or the other folder. */ - bool operator>=(const Folder& other) const; - - /** Determine if the left folder is an ancestor of (contains) - the right folder. - @param[in] other folder to compare to - @return whether this is an ancestor of the other folder */ - bool operator>(const Folder& other) const; - - /** Determine if the directory referenced by m_folder exists. - @return whether the directory exists */ - bool exists(); - -private: - /** Build the basic folder name from the path and length provided - @param[in] path pathname (not necessarily NUL-terminated) - @param[in] len length of the path, in bytes */ - void make_path(const char* path, size_t len); - - /** Resolve a relative path in m_folder to an absolute path - in m_abs_path setting m_abs_len. */ - void make_abs_path(); - - /** The wrapped folder string */ - char* m_folder; - - /** Length of m_folder */ - size_t m_folder_len; - - /** A full absolute path to the same file. */ - char m_abs_path[FN_REFLEN + 2]; - - /** Length of m_abs_path to the deepest folder */ - size_t m_abs_len; -}; - /** When mysqld is run, the default directory "." is the mysqld datadir, but in the MySQL Embedded Server Library and mysqlbackup it is not the default directory, and we must set the base file path explicitly */ extern const char* fil_path_to_mysql_datadir; -extern Folder folder_mysql_datadir; /** Initial size of a single-table tablespace in pages */ #define FIL_IBD_FILE_INITIAL_SIZE 4 @@ -1052,7 +959,6 @@ fil_make_filepath( /** Creates a new General or Single-Table tablespace @param[in] space_id Tablespace ID @param[in] name Tablespace name in dbname/tablename format. -For general tablespaces, the 'dbname/' part may be missing. @param[in] path Path and filename of the datafile to create. @param[in] flags Tablespace flags @param[in] size Initial size of the tablespace file in pages, diff --git a/storage/innobase/include/fsp0file.h b/storage/innobase/include/fsp0file.h index 610c4e9927b73..5129c63108ad0 100644 --- a/storage/innobase/include/fsp0file.h +++ b/storage/innobase/include/fsp0file.h @@ -220,9 +220,8 @@ class Datafile { void set_filepath(const char* filepath); /** Allocate and set the datafile or tablespace name in m_name. - If a name is provided, use it; else if the datafile is file-per-table, - extract a file-per-table tablespace name from m_filepath; else it is a - general tablespace, so just call it that for now. The value of m_name + If a name is provided, use it; else extract a file-per-table + tablespace name from m_filepath. The value of m_name will be freed in the destructor. @param[in] name Tablespace Name if known, NULL if not */ void set_name(const char* name); @@ -559,13 +558,10 @@ class RemoteDatafile : public Datafile the path ".". @param[in] name tablespace name @param[in] filepath remote filepath of tablespace datafile - @param[in] is_shared true for general tablespace, - false for file-per-table @return DB_SUCCESS or error code */ static dberr_t create_link_file( const char* name, - const char* filepath, - bool is_shared = false); + const char* filepath); /** Delete an InnoDB Symbolic Link (ISL) file by name. @param[in] name tablespace name */ @@ -575,8 +571,6 @@ class RemoteDatafile : public Datafile It is always created under the datadir of MySQL. For file-per-table tablespaces, the isl file is expected to be in a 'database' directory and called 'tablename.isl'. - For general tablespaces, there will be no 'database' directory. - The 'basename.isl' will be in the datadir. The caller must free the memory returned if it is not null. @param[in] link_filepath filepath of the ISL file @return Filepath of the IBD file read from the ISL file */ diff --git a/storage/innobase/include/fsp0fsp.h b/storage/innobase/include/fsp0fsp.h index edfb1bb47ef25..129842982a3f9 100644 --- a/storage/innobase/include/fsp0fsp.h +++ b/storage/innobase/include/fsp0fsp.h @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2016, MariaDB Corporation. All Rights Reserved. +Copyright (c) 2013, 2017, MariaDB Corporation. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -274,7 +274,7 @@ fsp_header_get_tablespace_size(void); /*================================*/ /** Calculate the number of pages to extend a datafile. -We extend single-table and general tablespaces first one extent at a time, +We extend single-table tablespaces first one extent at a time, but 4 at a time for bigger tablespaces. It is not enough to extend always by one extent, because we need to add at least one extent to FSP_FREE. A single extent descriptor page will track many extents. And the extent @@ -644,21 +644,10 @@ bool fsp_flags_is_compressed( ulint flags); -/** Determine if two tablespaces are equivalent or compatible. -@param[in] flags1 First tablespace flags -@param[in] flags2 Second tablespace flags -@return true the flags are compatible, false if not */ -UNIV_INLINE -bool -fsp_flags_are_equal( - ulint flags1, - ulint flags2); - /** Initialize an FSP flags integer. @param[in] page_size page sizes in bytes and compression flag. @param[in] atomic_blobs Used by Dynammic and Compressed. @param[in] has_data_dir This tablespace is in a remote location. -@param[in] is_shared This tablespace can be shared by many tables. @param[in] is_temporary This tablespace is temporary. @return tablespace flags after initialization */ UNIV_INLINE @@ -667,7 +656,6 @@ fsp_flags_init( const page_size_t& page_size, bool atomic_blobs, bool has_data_dir, - bool is_shared, bool is_temporary, bool page_compression, ulint page_compression_level, diff --git a/storage/innobase/include/fsp0fsp.ic b/storage/innobase/include/fsp0fsp.ic index 7f50bddb66202..9ff2dab75d48d 100644 --- a/storage/innobase/include/fsp0fsp.ic +++ b/storage/innobase/include/fsp0fsp.ic @@ -1,7 +1,7 @@ /***************************************************************************** Copyright (c) 1995, 2016, Oracle and/or its affiliates. All Rights Reserved. -Copyright (c) 2013, 2016, MariaDB Corporation. +Copyright (c) 2013, 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -53,40 +53,6 @@ fsp_flags_is_compressed( #define ACTUAL_SSIZE(ssize) (0 == ssize ? UNIV_PAGE_SSIZE_ORIG : ssize) -/** Determine if two tablespaces are equivalent or compatible. -@param[in] flags1 First tablespace flags -@param[in] flags2 Second tablespace flags -@return true the flags are compatible, false if not */ -UNIV_INLINE -bool -fsp_flags_are_equal( - ulint flags1, - ulint flags2) -{ - /* If either one of these flags is ULINT_UNDEFINED, - then they are not equal */ - if (flags1 == ULINT_UNDEFINED || flags2 == ULINT_UNDEFINED) { - return(false); - } - - if (!fsp_is_shared_tablespace(flags1) || !fsp_is_shared_tablespace(flags2)) { - /* At least one of these is a single-table tablespaces so all - flags must match. */ - return(flags1 == flags2); - } - - /* Both are shared tablespaces which can contain all formats. - But they must have the same logical and physical page size. - Once InnoDB can support multiple page sizes together, - the logical page size will not matter. */ - ulint zip_ssize1 = ACTUAL_SSIZE(FSP_FLAGS_GET_ZIP_SSIZE(flags1)); - ulint zip_ssize2 = ACTUAL_SSIZE(FSP_FLAGS_GET_ZIP_SSIZE(flags2)); - ulint page_ssize1 = ACTUAL_SSIZE(FSP_FLAGS_GET_PAGE_SSIZE(flags1)); - ulint page_ssize2 = ACTUAL_SSIZE(FSP_FLAGS_GET_PAGE_SSIZE(flags2)); - - return(zip_ssize1 == zip_ssize2 && page_ssize1 == page_ssize2); -} - /** Convert a page size, which is a power of 2, to an ssize, which is the number of bit shifts from 512 to make that page size. @param[in] page_size compressed page size in bytes @@ -179,7 +145,6 @@ fsp_flags_set_page_size( @param[in] page_size page sizes in bytes and compression flag. @param[in] atomic_blobs Used by Dynammic and Compressed. @param[in] has_data_dir This tablespace is in a remote location. -@param[in] is_shared This tablespace can be shared by many tables. @param[in] is_temporary This tablespace is temporary. @param[in] page_compressed Table uses page compression @param[in] page_compression_level Page compression level @@ -191,7 +156,6 @@ fsp_flags_init( const page_size_t& page_size, bool atomic_blobs, bool has_data_dir, - bool is_shared, bool is_temporary, bool page_compression, ulint page_compression_level, @@ -217,13 +181,6 @@ fsp_flags_init( flags |= FSP_FLAGS_MASK_DATA_DIR; } - /* Shared tablespaces can hold all row formats, so we only mark the - POST_ANTELOPE and ATOMIC_BLOB bits if it is compressed. */ - if (is_shared) { - ut_ad(!has_data_dir); - flags |= FSP_FLAGS_MASK_SHARED; - } - if (is_temporary) { ut_ad(!has_data_dir); flags |= FSP_FLAGS_MASK_TEMPORARY; diff --git a/storage/innobase/include/fsp0space.h b/storage/innobase/include/fsp0space.h index 31a1a4abc7512..6ecca6211ed35 100644 --- a/storage/innobase/include/fsp0space.h +++ b/storage/innobase/include/fsp0space.h @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -18,7 +19,7 @@ this program; if not, write to the Free Software Foundation, Inc., /**************************************************//** @file include/fsp0space.h -General shared tablespace implementation. +Shared tablespace interface Created 2013-7-26 by Kevin Lewis *******************************************************/ @@ -61,10 +62,6 @@ class Tablespace { shutdown(); ut_ad(m_files.empty()); ut_ad(m_space_id == ULINT_UNDEFINED); - if (m_name != NULL) { - ut_free(m_name); - m_name = NULL; - } if (m_path != NULL) { ut_free(m_path); m_path = NULL; @@ -75,21 +72,8 @@ class Tablespace { Tablespace(const Tablespace&); Tablespace& operator=(const Tablespace&); - /** Set tablespace name - @param[in] name tablespace name */ - void set_name(const char* name) - { - ut_ad(m_name == NULL); - m_name = mem_strdup(name); - ut_ad(m_name != NULL); - } - - /** Get tablespace name - @return tablespace name */ - const char* name() const - { - return(m_name); - } + void set_name(const char* name) { m_name = name; } + const char* name() const { return m_name; } /** Set tablespace path and filename members. @param[in] path where tablespace file(s) resides @@ -236,7 +220,7 @@ class Tablespace { /* DATA MEMBERS */ /** Name of the tablespace. */ - char* m_name; + const char* m_name; /** Tablespace ID */ ulint m_space_id; diff --git a/storage/innobase/include/fsp0types.h b/storage/innobase/include/fsp0types.h index 9bbe58bb1dd5e..1c535677e8322 100644 --- a/storage/innobase/include/fsp0types.h +++ b/storage/innobase/include/fsp0types.h @@ -216,15 +216,6 @@ bool fsp_is_checksum_disabled( ulint space_id); -/** Check if tablespace is file-per-table. -@param[in] space_id Tablespace ID -@param[in] fsp_flags Tablespace Flags -@return true if tablespace is file-per-table. */ -bool -fsp_is_file_per_table( - ulint space_id, - ulint fsp_flags); - #ifdef UNIV_DEBUG /** Skip some of the sanity checks that are time consuming even in debug mode and can affect frequent verification runs that are done to ensure stability of @@ -343,10 +334,6 @@ is a tablespace with encryption. */ #define FSP_FLAGS_MASK_DATA_DIR \ ((~(~0U << FSP_FLAGS_WIDTH_DATA_DIR)) \ << FSP_FLAGS_POS_DATA_DIR) -/** Bit mask of the SHARED field */ -#define FSP_FLAGS_MASK_SHARED \ - ((~(~0U << FSP_FLAGS_WIDTH_SHARED)) \ - << FSP_FLAGS_POS_SHARED) /** Bit mask of the TEMPORARY field */ #define FSP_FLAGS_MASK_TEMPORARY \ ((~(~0U << FSP_FLAGS_WIDTH_TEMPORARY)) \ @@ -384,10 +371,6 @@ is a tablespace with encryption. */ #define FSP_FLAGS_HAS_DATA_DIR(flags) \ ((flags & FSP_FLAGS_MASK_DATA_DIR) \ >> FSP_FLAGS_POS_DATA_DIR) -/** Return the contents of the SHARED field */ -#define FSP_FLAGS_GET_SHARED(flags) \ - ((flags & FSP_FLAGS_MASK_SHARED) \ - >> FSP_FLAGS_POS_SHARED) /** Return the contents of the TEMPORARY field */ #define FSP_FLAGS_GET_TEMPORARY(flags) \ ((flags & FSP_FLAGS_MASK_TEMPORARY) \ @@ -407,8 +390,6 @@ is a tablespace with encryption. */ #define FSP_FLAGS_GET_ATOMIC_WRITES(flags) \ ((flags & FSP_FLAGS_MASK_ATOMIC_WRITES) \ >> FSP_FLAGS_POS_ATOMIC_WRITES) -/** Use an alias in the code for FSP_FLAGS_GET_SHARED() */ -#define fsp_is_shared_tablespace FSP_FLAGS_GET_SHARED /* @} */ /** Set a PAGE_COMPRESSION into the correct bits in a given diff --git a/storage/innobase/include/ha_prototypes.h b/storage/innobase/include/ha_prototypes.h index 541fbe24d82ae..866853e605963 100644 --- a/storage/innobase/include/ha_prototypes.h +++ b/storage/innobase/include/ha_prototypes.h @@ -49,7 +49,6 @@ struct fts_string_t; #undef MYSQL_REPLACE_TRX_IN_THD #undef MYSQL_SPATIAL_INDEX #undef MYSQL_STORE_FTS_DOC_ID -#undef MYSQL_TABLESPACES /*********************************************************************//** Wrapper around MySQL's copy_and_convert function. diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 21bcd381c8770..0bc4fe4def9db 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -4050,14 +4050,12 @@ row_drop_table_for_mysql( bool is_temp; bool ibd_file_missing; bool is_discarded; - bool shared_tablespace; case DB_SUCCESS: space_id = table->space; ibd_file_missing = table->ibd_file_missing; is_discarded = dict_table_is_discarded(table); is_temp = dict_table_is_temporary(table); - shared_tablespace = DICT_TF_HAS_SHARED_SPACE(table->flags); /* If there is a temp path then the temp flag is set. However, during recovery, we might have a temp flag but @@ -4086,7 +4084,7 @@ row_drop_table_for_mysql( filepath = fil_make_filepath( table->dir_path_of_temp_table, NULL, IBD, false); - } else if (!shared_tablespace) { + } else { filepath = fil_make_filepath( NULL, table->name.m_name, IBD, false); } @@ -4098,8 +4096,8 @@ row_drop_table_for_mysql( } /* Do not attempt to drop known-to-be-missing tablespaces, - nor system or shared general tablespaces. */ - if (is_discarded || ibd_file_missing || shared_tablespace + nor the system tablespace. */ + if (is_discarded || ibd_file_missing || is_system_tablespace(space_id)) { break; } diff --git a/storage/innobase/row/row0quiesce.cc b/storage/innobase/row/row0quiesce.cc index 828b126309f22..d26d81c9239fd 100644 --- a/storage/innobase/row/row0quiesce.cc +++ b/storage/innobase/row/row0quiesce.cc @@ -649,15 +649,6 @@ row_quiesce_set_state( ER_TABLE_IN_SYSTEM_TABLESPACE, table_name); return(DB_UNSUPPORTED); - - } else if (DICT_TF_HAS_SHARED_SPACE(table->flags)) { - std::ostringstream err_msg; - err_msg << "FLUSH TABLES FOR EXPORT on table " << table->name - << " in a general tablespace."; - ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_WARN, - ER_NOT_SUPPORTED_YET, err_msg.str().c_str()); - - return(DB_UNSUPPORTED); } else if (row_quiesce_table_has_fts_index(table)) { ib_senderrf(trx->mysql_thd, IB_LOG_LEVEL_WARN, diff --git a/storage/innobase/row/row0trunc.cc b/storage/innobase/row/row0trunc.cc index 2d5ba6781d4e7..b372da4b93929 100644 --- a/storage/innobase/row/row0trunc.cc +++ b/storage/innobase/row/row0trunc.cc @@ -1,6 +1,7 @@ /***************************************************************************** Copyright (c) 2013, 2016, Oracle and/or its affiliates. All Rights Reserved. +Copyright (c) 2017, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software @@ -1309,7 +1310,6 @@ row_truncate_fts( fts_table.name = table->name; fts_table.flags2 = table->flags2; fts_table.flags = table->flags; - fts_table.tablespace = table->tablespace; fts_table.space = table->space; /* table->data_dir_path is used for FTS AUX table @@ -1320,20 +1320,6 @@ row_truncate_fts( ut_ad(table->data_dir_path != NULL); } - /* table->tablespace() may not be always populated or - if table->tablespace() uses "innodb_general" name, - fetch the real name. */ - if (DICT_TF_HAS_SHARED_SPACE(table->flags) - && (table->tablespace() == NULL - || dict_table_has_temp_general_tablespace_name( - table->tablespace()))) { - dict_get_and_save_space_name(table, true); - ut_ad(table->tablespace() != NULL); - ut_ad(!dict_table_has_temp_general_tablespace_name( - table->tablespace())); - } - - fts_table.tablespace = table->tablespace(); fts_table.data_dir_path = table->data_dir_path; dberr_t err; @@ -1604,8 +1590,6 @@ row_truncate_prepare(dict_table_t* table, ulint* flags) dict_get_and_save_data_dir_path(table, true); - dict_get_and_save_space_name(table, true); - if (*flags != ULINT_UNDEFINED) { dberr_t err = fil_prepare_for_truncate(table->space); @@ -2212,75 +2196,51 @@ truncate_t::fixup_tables_in_non_system_tablespace() done and erased from this list. */ ut_a((*it)->m_space_id != TRX_SYS_SPACE); - /* Step-1: Drop tablespace (only for single-tablespace), - drop indexes and re-create indexes. */ - - if (fsp_is_file_per_table((*it)->m_space_id, - (*it)->m_tablespace_flags)) { - /* The table is file_per_table */ - - ib::info() << "Completing truncate for table with " - "id (" << (*it)->m_old_table_id << ") " - "residing in file-per-table tablespace with " - "id (" << (*it)->m_space_id << ")"; - - if (!fil_space_get((*it)->m_space_id)) { + /* Drop tablespace, drop indexes and re-create indexes. */ - /* Create the database directory for name, - if it does not exist yet */ - fil_create_directory_for_tablename( - (*it)->m_tablename); + ib::info() << "Completing truncate for table with " + "id (" << (*it)->m_old_table_id << ") " + "residing in file-per-table tablespace with " + "id (" << (*it)->m_space_id << ")"; - err = fil_ibd_create( - (*it)->m_space_id, - (*it)->m_tablename, - (*it)->m_dir_path, - (*it)->m_tablespace_flags, - FIL_IBD_FILE_INITIAL_SIZE, - (*it)->m_encryption, - (*it)->m_key_id); + if (!fil_space_get((*it)->m_space_id)) { - if (err != DB_SUCCESS) { - /* If checkpoint is not yet done - and table is dropped and then we might - still have REDO entries for this table - which are INVALID. Ignore them. */ - ib::warn() << "Failed to create" - " tablespace for " - << (*it)->m_space_id - << " space-id"; - err = DB_ERROR; - break; - } - } + /* Create the database directory for name, + if it does not exist yet */ + fil_create_directory_for_tablename( + (*it)->m_tablename); - ut_ad(fil_space_get((*it)->m_space_id)); - - err = fil_recreate_tablespace( + err = fil_ibd_create( (*it)->m_space_id, - (*it)->m_format_flags, - (*it)->m_tablespace_flags, (*it)->m_tablename, - **it, log_get_lsn()); - - } else { - /* Table is in a shared tablespace */ + (*it)->m_dir_path, + (*it)->m_tablespace_flags, + FIL_IBD_FILE_INITIAL_SIZE, + (*it)->m_encryption, + (*it)->m_key_id); - ib::info() << "Completing truncate for table with " - "id (" << (*it)->m_old_table_id << ") " - "residing in shared tablespace with " - "id (" << (*it)->m_space_id << ")"; + if (err != DB_SUCCESS) { + /* If checkpoint is not yet done + and table is dropped and then we might + still have REDO entries for this table + which are INVALID. Ignore them. */ + ib::warn() << "Failed to create" + " tablespace for " + << (*it)->m_space_id + << " space-id"; + err = DB_ERROR; + break; + } + } - /* Temp-tables in temp-tablespace are never restored.*/ - ut_ad((*it)->m_space_id != SRV_TMP_SPACE_ID); + ut_ad(fil_space_get((*it)->m_space_id)); - err = fil_recreate_table( - (*it)->m_space_id, - (*it)->m_format_flags, - (*it)->m_tablespace_flags, - (*it)->m_tablename, - **it); - } + err = fil_recreate_tablespace( + (*it)->m_space_id, + (*it)->m_format_flags, + (*it)->m_tablespace_flags, + (*it)->m_tablename, + **it, log_get_lsn()); /* Step-2: Update the SYS_XXXX tables to reflect new table-id and root_page_no. */ diff --git a/storage/innobase/srv/srv0srv.cc b/storage/innobase/srv/srv0srv.cc index 2fa7a02e85eaf..5d478e4529f06 100644 --- a/storage/innobase/srv/srv0srv.cc +++ b/storage/innobase/srv/srv0srv.cc @@ -3157,11 +3157,6 @@ srv_was_tablespace_truncated(const fil_space_t* space) return(false); } - bool has_shared_space = FSP_FLAGS_GET_SHARED(space->flags); - - if (is_system_tablespace(space->id) || has_shared_space) { - return(false); - } - - return(truncate_t::was_tablespace_truncated(space->id)); + return (!is_system_tablespace(space->id) + && truncate_t::was_tablespace_truncated(space->id)); } diff --git a/storage/innobase/srv/srv0start.cc b/storage/innobase/srv/srv0start.cc index dfed856b05173..ddc766accd4cb 100644 --- a/storage/innobase/srv/srv0start.cc +++ b/storage/innobase/srv/srv0start.cc @@ -692,7 +692,7 @@ srv_undo_tablespace_open( /* Set the compressed page size to 0 (non-compressed) */ flags = fsp_flags_init( - univ_page_size, false, false, false, false, false, 0, 0); + univ_page_size, false, false, false, false, 0, 0); space = fil_space_create( undo_name, space_id, flags, FIL_TYPE_TABLESPACE, NULL, true); diff --git a/storage/innobase/ut/ut0ut.cc b/storage/innobase/ut/ut0ut.cc index 9eb11c913c5c8..d43735bba2e52 100644 --- a/storage/innobase/ut/ut0ut.cc +++ b/storage/innobase/ut/ut0ut.cc @@ -756,9 +756,6 @@ ut_strerr( case DB_FORCED_ABORT: return("Transaction aborted by another higher priority " "transaction"); - case DB_WRONG_FILE_NAME: - return("Invalid Filename"); - case DB_COMPUTE_VALUE_FAILED: return("Compute generated column failed"); case DB_NO_FK_ON_S_BASE_COL: