diff options
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/dict/dict0mem.cc | 8 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 6 | ||||
-rw-r--r-- | storage/innobase/handler/handler0alter.cc | 17 | ||||
-rw-r--r-- | storage/innobase/include/dict0mem.h | 23 | ||||
-rw-r--r-- | storage/innobase/row/row0mysql.cc | 3 |
5 files changed, 45 insertions, 12 deletions
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc index dcf52c93de1..bde8303ead5 100644 --- a/storage/innobase/dict/dict0mem.cc +++ b/storage/innobase/dict/dict0mem.cc @@ -50,6 +50,14 @@ static const char* innobase_system_databases[] = { NullS }; +/** The start of the table basename suffix for partitioned tables */ +const char table_name_t::part_suffix[4] +#ifdef _WIN32 += "#p#"; +#else += "#P#"; +#endif + /** An interger randomly initialized at startup used to make a temporary table name as unuique as possible. */ static ib_uint32_t dict_temp_file_num; diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 0fdfaa449fd..7bb84b41a11 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -294,11 +294,7 @@ is_partition( { /* We look for pattern #P# to see if the table is partitioned MariaDB table. */ -#ifdef _WIN32 - return strstr(file_name, "#p#"); -#else - return strstr(file_name, "#P#"); -#endif /* _WIN32 */ + return strstr(file_name, table_name_t::part_suffix); } /** Signal to shut down InnoDB (NULL if shutdown was signaled, or if diff --git a/storage/innobase/handler/handler0alter.cc b/storage/innobase/handler/handler0alter.cc index 8565cad96ec..412438237fa 100644 --- a/storage/innobase/handler/handler0alter.cc +++ b/storage/innobase/handler/handler0alter.cc @@ -4520,11 +4520,18 @@ prepare_inplace_alter_table_dict( to rebuild the table with a temporary name. */ if (new_clustered) { - const char* new_table_name - = dict_mem_create_temporary_tablename( - ctx->heap, - ctx->new_table->name.m_name, - ctx->new_table->id); + size_t dblen = ctx->old_table->name.dblen() + 1; + size_t tablen = altered_table->s->table_name.length; + const char* part = ctx->old_table->name.part(); + size_t partlen = part ? strlen(part) : 0; + char* new_table_name = static_cast<char*>( + mem_heap_alloc(ctx->heap, + dblen + tablen + partlen + 1)); + memcpy(new_table_name, ctx->old_table->name.m_name, dblen); + memcpy(new_table_name + dblen, + altered_table->s->table_name.str, tablen); + memcpy(new_table_name + dblen + tablen, + part ? part : "", partlen + 1); ulint n_cols = 0; ulint n_v_cols = 0; dtuple_t* add_cols; diff --git a/storage/innobase/include/dict0mem.h b/storage/innobase/include/dict0mem.h index 44d1a11ab33..fc120149c5f 100644 --- a/storage/innobase/include/dict0mem.h +++ b/storage/innobase/include/dict0mem.h @@ -568,6 +568,29 @@ struct table_name_t { /** The name in internal representation */ char* m_name; + + /** @return the end of the schema name */ + const char* dbend() const + { + const char* sep = strchr(m_name, '/'); + ut_ad(sep); + return sep; + } + + /** @return the length of the schema name, in bytes */ + size_t dblen() const { return dbend() - m_name; } + + /** Determine the filename-safe encoded table name. + @return the filename-safe encoded table name */ + const char* basename() const { return dbend() + 1; } + + /** The start of the table basename suffix for partitioned tables */ + static const char part_suffix[4]; + + /** Determine the partition or subpartition name suffix. + @return the partition name + @retval NULL if the table is not partitioned */ + const char* part() const { return strstr(basename(), part_suffix); } }; /** Data structure for a column in a table */ diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 4677dfc296a..58d90cfb2ac 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -3629,8 +3629,7 @@ row_drop_table_for_mysql( TRX_DICT_OP_INDEX, we should be dropping auxiliary tables for full-text indexes or temp tables. */ ut_ad(strstr(table->name.m_name, "/FTS_") - || strstr(table->name.m_name, - "/" TEMP_FILE_PREFIX_INNODB)); + || strstr(table->name.m_name, TEMP_TABLE_PATH_PREFIX)); } /* Mark all indexes unavailable in the data dictionary cache |