45
ut_a(!(flags & (~0 << DICT_TF_BITS)));
45
ut_ad(!(flags & ~DICT_TF_COMPACT));
47
47
heap = mem_heap_create(DICT_HEAP_SIZE);
49
table = mem_heap_zalloc(heap, sizeof(dict_table_t));
49
table = mem_heap_alloc(heap, sizeof(dict_table_t));
51
51
table->heap = heap;
53
53
table->flags = (unsigned int) flags;
54
54
table->name = mem_heap_strdup(heap, name);
55
table->dir_path_of_temp_table = NULL;
55
56
table->space = (unsigned int) space;
57
table->ibd_file_missing = FALSE;
58
table->tablespace_discarded = FALSE;
56
60
table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS);
62
table->n_mysql_handles_opened = 0;
63
table->n_foreign_key_checks_running = 0;
65
table->cached = FALSE;
58
67
table->cols = mem_heap_alloc(heap, (n_cols + DATA_N_SYS_COLS)
59
68
* sizeof(dict_col_t));
69
table->col_names = NULL;
70
UT_LIST_INIT(table->indexes);
61
72
table->auto_inc_lock = mem_heap_alloc(heap, lock_get_size());
74
table->query_cache_inv_trx_id = ut_dulint_zero;
76
UT_LIST_INIT(table->locks);
77
UT_LIST_INIT(table->foreign_list);
78
UT_LIST_INIT(table->referenced_list);
81
table->does_not_fit_in_memory = FALSE;
82
#endif /* UNIV_DEBUG */
84
table->stat_initialized = FALSE;
86
table->stat_modified_counter = 0;
63
90
mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
92
table->autoinc_inited = FALSE;
65
94
/* The actual increment value will be set by MySQL, we simply
66
95
default to 1 here.*/
67
96
table->autoinc_increment = 1;
98
/* The number of transactions that are either waiting on the
99
AUTOINC lock or have been granted the lock. */
100
table->n_waiting_or_granted_auto_inc_locks = 0;
70
103
table->magic_n = DICT_TABLE_MAGIC_N;
71
104
#endif /* UNIV_DEBUG */
166
199
if (UNIV_LIKELY(i) && UNIV_UNLIKELY(!table->col_names)) {
167
200
/* All preceding column names are empty. */
168
char* s = mem_heap_zalloc(heap, table->n_def);
201
char* s = mem_heap_alloc(heap, table->n_def);
202
memset(s, 0, table->n_def);
169
203
table->col_names = s;
210
244
ut_ad(table_name && index_name);
212
246
heap = mem_heap_create(DICT_HEAP_SIZE);
213
index = mem_heap_zalloc(heap, sizeof(dict_index_t));
247
index = mem_heap_alloc(heap, sizeof(dict_index_t));
215
249
index->heap = heap;
217
251
index->type = type;
218
252
index->space = (unsigned int) space;
219
254
index->name = mem_heap_strdup(heap, index_name);
220
255
index->table_name = table_name;
257
index->n_def = index->n_nullable = 0;
221
258
index->n_fields = (unsigned int) n_fields;
222
259
index->fields = mem_heap_alloc(heap, 1 + n_fields
223
260
* sizeof(dict_field_t));
224
261
/* The '1 +' above prevents allocation
225
262
of an empty mem block */
263
index->stat_n_diff_key_vals = NULL;
265
index->cached = FALSE;
266
memset(&index->lock, 0, sizeof index->lock);
226
267
#ifdef UNIV_DEBUG
227
268
index->magic_n = DICT_INDEX_MAGIC_N;
228
269
#endif /* UNIV_DEBUG */
243
284
heap = mem_heap_create(100);
245
foreign = mem_heap_zalloc(heap, sizeof(dict_foreign_t));
286
foreign = mem_heap_alloc(heap, sizeof(dict_foreign_t));
247
288
foreign->heap = heap;
293
foreign->foreign_table_name = NULL;
294
foreign->foreign_table = NULL;
295
foreign->foreign_col_names = NULL;
297
foreign->referenced_table_name = NULL;
298
foreign->referenced_table = NULL;
299
foreign->referenced_col_names = NULL;
301
foreign->n_fields = 0;
303
foreign->foreign_index = NULL;
304
foreign->referenced_index = NULL;
253
310
Adds a field definition to an index. NOTE: does not take a copy
254
311
of the column name if the field is a column. The memory occupied
255
312
by the column name may be released only after publishing the index. */
258
315
dict_mem_index_add_field(
259
316
/*=====================*/