summaryrefslogtreecommitdiff
path: root/storage/innobase/dict/dict0mem.cc
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-02-03 18:41:18 -0800
committerIgor Babaev <igor@askmonty.org>2019-02-03 18:41:18 -0800
commit37deed3f37561f264f65e162146bbc2ad35fb1a2 (patch)
treec1cfb6c0995bfcc4ac3fb335f518a8b404413e32 /storage/innobase/dict/dict0mem.cc
parent658128af43b4d7c6db445164f8ed25ed4d1e3109 (diff)
parent5b996782be6b752ce50a0ecaa222b0688aa9e75d (diff)
downloadmariadb-git-37deed3f37561f264f65e162146bbc2ad35fb1a2.tar.gz
Merge branch '10.4' into bb-10.4-mdev16188
Diffstat (limited to 'storage/innobase/dict/dict0mem.cc')
-rw-r--r--storage/innobase/dict/dict0mem.cc73
1 files changed, 27 insertions, 46 deletions
diff --git a/storage/innobase/dict/dict0mem.cc b/storage/innobase/dict/dict0mem.cc
index f5f61eff5b3..3d373bf37d8 100644
--- a/storage/innobase/dict/dict0mem.cc
+++ b/storage/innobase/dict/dict0mem.cc
@@ -34,7 +34,6 @@ Created 1/8/1996 Heikki Tuuri
#include "mach0data.h"
#include "dict0dict.h"
#include "fts0priv.h"
-#include "ut0crc32.h"
#include "lock0lock.h"
#include "sync0sync.h"
#include "row0row.h"
@@ -82,10 +81,6 @@ const char table_name_t::part_suffix[4]
= "#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;
-
/** Display an identifier.
@param[in,out] s output stream
@param[in] id_name SQL identifier (other than table name)
@@ -1112,35 +1107,15 @@ dict_mem_create_temporary_tablename(
ut_ad(dbend);
size_t dblen = size_t(dbend - dbtab) + 1;
- /* Increment a randomly initialized number for each temp file. */
- my_atomic_add32((int32*) &dict_temp_file_num, 1);
-
- size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20 + 1 + 10);
+ size = dblen + (sizeof(TEMP_FILE_PREFIX) + 3 + 20);
name = static_cast<char*>(mem_heap_alloc(heap, size));
memcpy(name, dbtab, dblen);
snprintf(name + dblen, size - dblen,
- TEMP_FILE_PREFIX_INNODB UINT64PF "-" UINT32PF,
- id, dict_temp_file_num);
+ TEMP_FILE_PREFIX_INNODB UINT64PF, id);
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.
@param[in] fk_set the foreign key set to be validated
@return true if search order is fine in the set, false otherwise. */
@@ -1216,18 +1191,25 @@ inline void dict_index_t::reconstruct_fields()
n_nullable = 0;
ulint n_core_null = 0;
const bool comp = dict_table_is_comp(table);
- const auto* non_pk_col_map = table->instant->non_pk_col_map;
- for (unsigned i = n_first, o = i, j = 0; i < n_fields; ) {
+ const auto* field_map_it = table->instant->field_map;
+ for (unsigned i = n_first, j = 0; i < n_fields; ) {
dict_field_t& f = tfields[i++];
- auto c = *non_pk_col_map++;
- if (c & 1U << 15) {
+ auto c = *field_map_it++;
+ if (c.is_dropped()) {
f.col = &table->instant->dropped[j++];
- ut_ad(f.col->is_dropped());
+ DBUG_ASSERT(f.col->is_dropped());
f.fixed_len = dict_col_get_fixed_size(f.col, comp);
} else {
- f = fields[o++];
- f.col = dict_table_get_nth_col(table, c);
- f.name = f.col->name(*table);
+ DBUG_ASSERT(!c.is_not_null());
+ const auto old = std::find_if(
+ fields + n_first, fields + n_fields,
+ [c](const dict_field_t& o)
+ { return o.col->ind == c.ind(); });
+ ut_ad(old >= &fields[n_first]);
+ ut_ad(old < &fields[n_fields]);
+ DBUG_ASSERT(!old->prefix_len);
+ DBUG_ASSERT(old->col == &table->cols[c.ind()]);
+ f = *old;
}
f.col->clear_instant();
@@ -1263,23 +1245,22 @@ bool dict_table_t::deserialise_columns(const byte* metadata, ulint len)
return true;
}
- uint16_t* non_pk_col_map = static_cast<uint16_t*>(
+ field_map_element_t* field_map = static_cast<field_map_element_t*>(
mem_heap_alloc(heap,
- num_non_pk_fields * sizeof *non_pk_col_map));
+ num_non_pk_fields * sizeof *field_map));
unsigned n_dropped_cols = 0;
for (unsigned i = 0; i < num_non_pk_fields; i++) {
- non_pk_col_map[i] = mach_read_from_2(metadata);
+ auto c = field_map[i] = mach_read_from_2(metadata);
metadata += 2;
- if (non_pk_col_map[i] & 1U << 15) {
- if ((non_pk_col_map[i] & ~(3U << 14))
- > DICT_MAX_FIXED_COL_LEN + 1) {
+ if (field_map[i].is_dropped()) {
+ if (c.ind() > DICT_MAX_FIXED_COL_LEN + 1) {
return true;
}
n_dropped_cols++;
- } else if (non_pk_col_map[i] >= n_cols) {
+ } else if (c >= n_cols) {
return true;
}
}
@@ -1289,14 +1270,14 @@ bool dict_table_t::deserialise_columns(const byte* metadata, ulint len)
instant = new (mem_heap_alloc(heap, sizeof *instant)) dict_instant_t();
instant->n_dropped = n_dropped_cols;
instant->dropped = dropped_cols;
- instant->non_pk_col_map = non_pk_col_map;
+ instant->field_map = field_map;
dict_col_t* col = dropped_cols;
for (unsigned i = 0; i < num_non_pk_fields; i++) {
- if (non_pk_col_map[i] & 1U << 15) {
- auto fixed_len = non_pk_col_map[i] & ~(3U << 14);
+ if (field_map[i].is_dropped()) {
+ auto fixed_len = field_map[i].ind();
DBUG_ASSERT(fixed_len <= DICT_MAX_FIXED_COL_LEN + 1);
- (col++)->set_dropped(non_pk_col_map[i] & 1U << 14,
+ (col++)->set_dropped(field_map[i].is_not_null(),
fixed_len == 1,
fixed_len > 1 ? fixed_len - 1
: 0);