MCPcopy Create free account
hub / github.com/MariaDB/server / alloc_table_share

Function alloc_table_share

sql/table.cc:354–420  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

352*/
353
354TABLE_SHARE *alloc_table_share(const char *db, const char *table_name,
355 const char *key, uint key_length)
356{
357 MEM_ROOT mem_root;
358 TABLE_SHARE *share;
359 char *key_buff, *path_buff;
360 char path[FN_REFLEN];
361 uint path_length;
362 DBUG_ENTER("alloc_table_share");
363 DBUG_PRINT("enter", ("table: '%s'.'%s'", db, table_name));
364
365 path_length= build_table_filename(path, sizeof(path) - 1,
366 db, table_name, "", 0);
367 init_sql_alloc(key_memory_table_share, &mem_root, TABLE_ALLOC_BLOCK_SIZE,
368 TABLE_PREALLOC_BLOCK_SIZE, MYF(0));
369 if (multi_alloc_root(&mem_root,
370 &share, sizeof(*share),
371 &key_buff, key_length,
372 &path_buff, path_length + 1,
373 NULL))
374 {
375 bzero((char*) share, sizeof(*share));
376
377 share->set_table_cache_key(key_buff, key, key_length);
378
379 share->path.str= path_buff;
380 share->path.length= path_length;
381 strmov(path_buff, path);
382 share->normalized_path.str= share->path.str;
383 share->normalized_path.length= path_length;
384 share->table_category= get_table_category(share->db, share->table_name);
385 share->open_errno= ENOENT;
386 /* The following will be updated in open_table_from_share */
387 share->can_do_row_logging= 1;
388 if (share->table_category == TABLE_CATEGORY_LOG)
389 share->no_replicate= 1;
390 if (key_length > 6 &&
391 table_alias_charset->strnncoll(key, 6, "mysql", 6) == 0)
392 share->not_usable_by_query_cache= 1;
393
394 memcpy((char*) &share->mem_root, (char*) &mem_root, sizeof(mem_root));
395 mysql_mutex_init(key_TABLE_SHARE_LOCK_share,
396 &share->LOCK_share, MY_MUTEX_INIT_SLOW);
397 mysql_mutex_init(key_TABLE_SHARE_LOCK_ha_data,
398 &share->LOCK_ha_data, MY_MUTEX_INIT_FAST);
399 mysql_mutex_init(key_TABLE_SHARE_LOCK_statistics,
400 &share->LOCK_statistics, MY_MUTEX_INIT_SLOW);
401
402 DBUG_EXECUTE_IF("simulate_big_table_id",
403 if (last_table_id < UINT_MAX32)
404 last_table_id= UINT_MAX32-1;);
405 /*
406 Replication is using 6 bytes as table_map_id. Ensure that
407 the 6 lowest bytes are not 0.
408 We also have to ensure that we do not use the special value
409 UINT_MAX32 as this is used to mark a dummy event row event. See
410 comments in Rows_log_event::Rows_log_event().
411 */

Callers 4

tdc_acquire_shareFunction · 0.85
GetTableShareFunction · 0.85

Calls 9

build_table_filenameFunction · 0.85
init_sql_allocFunction · 0.85
multi_alloc_rootFunction · 0.85
strmovFunction · 0.85
get_table_categoryFunction · 0.85
set_table_cache_keyMethod · 0.80
strnncollMethod · 0.80
fetch_addMethod · 0.80
ifFunction · 0.70

Tested by

no test coverage detected