Skip to content

Commit ab4bc84

Browse files
committed
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.
1 parent e293979 commit ab4bc84

File tree

3 files changed

+2
-33
lines changed

3 files changed

+2
-33
lines changed

storage/innobase/dict/dict0mem.cc

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri
3434
#include "mach0data.h"
3535
#include "dict0dict.h"
3636
#include "fts0priv.h"
37-
#include "ut0crc32.h"
3837
#include "lock0lock.h"
3938
#include "sync0sync.h"
4039
#include "row0row.h"
@@ -82,10 +81,6 @@ const char table_name_t::part_suffix[4]
8281
= "#P#";
8382
#endif
8483

85-
/** An interger randomly initialized at startup used to make a temporary
86-
table name as unuique as possible. */
87-
static ib_uint32_t dict_temp_file_num;
88-
8984
/** Display an identifier.
9085
@param[in,out] s output stream
9186
@param[in] id_name SQL identifier (other than table name)
@@ -1105,35 +1100,15 @@ dict_mem_create_temporary_tablename(
11051100
ut_ad(dbend);
11061101
size_t dblen = size_t(dbend - dbtab) + 1;
11071102

1108-
/* Increment a randomly initialized number for each temp file. */
1109-
my_atomic_add32((int32*) &dict_temp_file_num, 1);
1110-
1111-
size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
1103+
size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20);
11121104
name = static_cast<char*>(mem_heap_alloc(heap, size));
11131105
memcpy(name, dbtab, dblen);
11141106
snprintf(name + dblen, size - dblen,
1115-
TEMP_FILE_PREFIX_INNODB UINT64PF "-" UINT32PF,
1116-
id, dict_temp_file_num);
1107+
TEMP_FILE_PREFIX_INNODB UINT64PF, id);
11171108

11181109
return(name);
11191110
}
11201111

1121-
/** Initialize dict memory variables */
1122-
void
1123-
dict_mem_init(void)
1124-
{
1125-
/* Initialize a randomly distributed temporary file number */
1126-
ib_uint32_t now = static_cast<ib_uint32_t>(ut_time());
1127-
1128-
const byte* buf = reinterpret_cast<const byte*>(&now);
1129-
1130-
dict_temp_file_num = ut_crc32(buf, sizeof(now));
1131-
1132-
DBUG_PRINT("dict_mem_init",
1133-
("Starting Temporary file number is " UINT32PF,
1134-
dict_temp_file_num));
1135-
}
1136-
11371112
/** Validate the search order in the foreign key set.
11381113
@param[in] fk_set the foreign key set to be validated
11391114
@return true if search order is fine in the set, false otherwise. */

storage/innobase/include/dict0mem.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,6 @@ dict_mem_create_temporary_tablename(
494494
const char* dbtab,
495495
table_id_t id);
496496

497-
/** Initialize dict memory variables */
498-
void
499-
dict_mem_init(void);
500-
501497
/** SQL identifier name wrapper for pretty-printing */
502498
class id_name_t
503499
{

storage/innobase/srv/srv0srv.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,8 +1071,6 @@ srv_init()
10711071
trx_i_s_cache_init(trx_i_s_cache);
10721072

10731073
ut_crc32_init();
1074-
1075-
dict_mem_init();
10761074
}
10771075

10781076
/*********************************************************************//**

0 commit comments

Comments
 (0)