~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/dict/dict0mem.c

  • Committer: Brian Aker
  • Date: 2008-09-04 19:31:00 UTC
  • Revision ID: brian@tangent.org-20080904193100-l849hgghfy4urj43
Changing default character set from this point on.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 
26
26
/**************************************************************************
27
27
Creates a table memory object. */
28
 
UNIV_INTERN
 
28
 
29
29
dict_table_t*
30
30
dict_mem_table_create(
31
31
/*==================*/
42
42
        mem_heap_t*     heap;
43
43
 
44
44
        ut_ad(name);
45
 
        ut_a(!(flags & (~0 << DICT_TF_BITS)));
 
45
        ut_ad(!(flags & ~DICT_TF_COMPACT));
46
46
 
47
47
        heap = mem_heap_create(DICT_HEAP_SIZE);
48
48
 
49
 
        table = mem_heap_zalloc(heap, sizeof(dict_table_t));
 
49
        table = mem_heap_alloc(heap, sizeof(dict_table_t));
50
50
 
51
51
        table->heap = heap;
52
52
 
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;
 
59
        table->n_def = 0;
56
60
        table->n_cols = (unsigned int) (n_cols + DATA_N_SYS_COLS);
57
61
 
 
62
        table->n_mysql_handles_opened = 0;
 
63
        table->n_foreign_key_checks_running = 0;
 
64
 
 
65
        table->cached = FALSE;
 
66
 
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);
60
71
 
61
72
        table->auto_inc_lock = mem_heap_alloc(heap, lock_get_size());
62
73
 
 
74
        table->query_cache_inv_trx_id = ut_dulint_zero;
 
75
 
 
76
        UT_LIST_INIT(table->locks);
 
77
        UT_LIST_INIT(table->foreign_list);
 
78
        UT_LIST_INIT(table->referenced_list);
 
79
 
 
80
#ifdef UNIV_DEBUG
 
81
        table->does_not_fit_in_memory = FALSE;
 
82
#endif /* UNIV_DEBUG */
 
83
 
 
84
        table->stat_initialized = FALSE;
 
85
 
 
86
        table->stat_modified_counter = 0;
 
87
 
 
88
        table->big_rows = 0;
 
89
 
63
90
        mutex_create(&table->autoinc_mutex, SYNC_DICT_AUTOINC_MUTEX);
64
91
 
 
92
        table->autoinc_inited = FALSE;
 
93
 
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;
68
97
 
 
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;
 
101
 
69
102
#ifdef UNIV_DEBUG
70
103
        table->magic_n = DICT_TABLE_MAGIC_N;
71
104
#endif /* UNIV_DEBUG */
74
107
 
75
108
/********************************************************************
76
109
Free a table memory object. */
77
 
UNIV_INTERN
 
110
 
78
111
void
79
112
dict_mem_table_free(
80
113
/*================*/
137
170
 
138
171
/**************************************************************************
139
172
Adds a column definition to a table. */
140
 
UNIV_INTERN
 
173
 
141
174
void
142
175
dict_mem_table_add_col(
143
176
/*===================*/
165
198
                }
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;
170
204
                }
171
205
 
173
207
                                                     i, name, heap);
174
208
        }
175
209
 
176
 
        col = dict_table_get_nth_col(table, i);
 
210
        col = (dict_col_t*) dict_table_get_nth_col(table, i);
177
211
 
178
212
        col->ind = (unsigned int) i;
179
213
        col->ord_part = 0;
190
224
 
191
225
/**************************************************************************
192
226
Creates an index memory object. */
193
 
UNIV_INTERN
 
227
 
194
228
dict_index_t*
195
229
dict_mem_index_create(
196
230
/*==================*/
210
244
        ut_ad(table_name && index_name);
211
245
 
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));
214
248
 
215
249
        index->heap = heap;
216
250
 
217
251
        index->type = type;
218
252
        index->space = (unsigned int) space;
 
253
        index->page = 0;
219
254
        index->name = mem_heap_strdup(heap, index_name);
220
255
        index->table_name = table_name;
 
256
        index->table = NULL;
 
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;
 
264
 
 
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 */
231
272
 
232
273
/**************************************************************************
233
274
Creates and initializes a foreign constraint memory object. */
234
 
UNIV_INTERN
 
275
 
235
276
dict_foreign_t*
236
277
dict_mem_foreign_create(void)
237
278
/*=========================*/
242
283
 
243
284
        heap = mem_heap_create(100);
244
285
 
245
 
        foreign = mem_heap_zalloc(heap, sizeof(dict_foreign_t));
 
286
        foreign = mem_heap_alloc(heap, sizeof(dict_foreign_t));
246
287
 
247
288
        foreign->heap = heap;
248
289
 
 
290
        foreign->id = NULL;
 
291
 
 
292
        foreign->type = 0;
 
293
        foreign->foreign_table_name = NULL;
 
294
        foreign->foreign_table = NULL;
 
295
        foreign->foreign_col_names = NULL;
 
296
 
 
297
        foreign->referenced_table_name = NULL;
 
298
        foreign->referenced_table = NULL;
 
299
        foreign->referenced_col_names = NULL;
 
300
 
 
301
        foreign->n_fields = 0;
 
302
 
 
303
        foreign->foreign_index = NULL;
 
304
        foreign->referenced_index = NULL;
 
305
 
249
306
        return(foreign);
250
307
}
251
308
 
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. */
256
 
UNIV_INTERN
 
313
 
257
314
void
258
315
dict_mem_index_add_field(
259
316
/*=====================*/
278
335
 
279
336
/**************************************************************************
280
337
Frees an index memory object. */
281
 
UNIV_INTERN
 
338
 
282
339
void
283
340
dict_mem_index_free(
284
341
/*================*/