Commit ab4bc844 authored by Marko Mäkelä's avatar Marko Mäkelä

Follow-up to MDEV-14585: Remove dict_temp_file_num

Now that InnoDB startup drops tables whose name starts with #sql,
the table ID alone should be enough to create a unique table name.

dict_temp_file_num, dict_mem_init(): Remove.

dict_mem_create_temporary_tablename(): Use a combination of
"#sql-ib" and the ID of the table that is being rebuilt
in TRUNCATE TABLE, or discarded in the commit of table-rebuilding
ALTER TABLE...ALGORITHM=INPLACE, or deferred to the DROP queue.

Thanks to Sergey Vojtovich for pointing this out.
parent e2939795
...@@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri ...@@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri
#include "mach0data.h" #include "mach0data.h"
#include "dict0dict.h" #include "dict0dict.h"
#include "fts0priv.h" #include "fts0priv.h"
#include "ut0crc32.h"
#include "lock0lock.h" #include "lock0lock.h"
#include "sync0sync.h" #include "sync0sync.h"
#include "row0row.h" #include "row0row.h"
...@@ -82,10 +81,6 @@ const char table_name_t::part_suffix[4] ...@@ -82,10 +81,6 @@ const char table_name_t::part_suffix[4]
= "#P#"; = "#P#";
#endif #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;
/** Display an identifier. /** Display an identifier.
@param[in,out] s output stream @param[in,out] s output stream
@param[in] id_name SQL identifier (other than table name) @param[in] id_name SQL identifier (other than table name)
...@@ -1105,35 +1100,15 @@ dict_mem_create_temporary_tablename( ...@@ -1105,35 +1100,15 @@ dict_mem_create_temporary_tablename(
ut_ad(dbend); ut_ad(dbend);
size_t dblen = size_t(dbend - dbtab) + 1; size_t dblen = size_t(dbend - dbtab) + 1;
/* Increment a randomly initialized number for each temp file. */ size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20);
my_atomic_add32((int32*) &dict_temp_file_num, 1);
size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
name = static_cast<char*>(mem_heap_alloc(heap, size)); name = static_cast<char*>(mem_heap_alloc(heap, size));
memcpy(name, dbtab, dblen); memcpy(name, dbtab, dblen);
snprintf(name + dblen, size - dblen, snprintf(name + dblen, size - dblen,
TEMP_FILE_PREFIX_INNODB UINT64PF "-" UINT32PF, TEMP_FILE_PREFIX_INNODB UINT64PF, id);
id, dict_temp_file_num);
return(name); return(name);
} }
/** Initialize dict memory variables */
void
dict_mem_init(void)
{
/* Initialize a randomly distributed temporary file number */
ib_uint32_t now = static_cast<ib_uint32_t>(ut_time());
const byte* buf = reinterpret_cast<const byte*>(&now);
dict_temp_file_num = ut_crc32(buf, sizeof(now));
DBUG_PRINT("dict_mem_init",
("Starting Temporary file number is " UINT32PF,
dict_temp_file_num));
}
/** Validate the search order in the foreign key set. /** Validate the search order in the foreign key set.
@param[in] fk_set the foreign key set to be validated @param[in] fk_set the foreign key set to be validated
@return true if search order is fine in the set, false otherwise. */ @return true if search order is fine in the set, false otherwise. */
......
...@@ -494,10 +494,6 @@ dict_mem_create_temporary_tablename( ...@@ -494,10 +494,6 @@ dict_mem_create_temporary_tablename(
const char* dbtab, const char* dbtab,
table_id_t id); table_id_t id);
/** Initialize dict memory variables */
void
dict_mem_init(void);
/** SQL identifier name wrapper for pretty-printing */ /** SQL identifier name wrapper for pretty-printing */
class id_name_t class id_name_t
{ {
......
...@@ -1071,8 +1071,6 @@ srv_init() ...@@ -1071,8 +1071,6 @@ srv_init()
trx_i_s_cache_init(trx_i_s_cache); trx_i_s_cache_init(trx_i_s_cache);
ut_crc32_init(); ut_crc32_init();
dict_mem_init();
} }
/*********************************************************************//** /*********************************************************************//**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment