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

Method insert_table

sql/sql_cache.cc:3506–3616  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3504*/
3505
3506my_bool
3507Query_cache::insert_table(THD *thd, size_t key_len, const char *key,
3508 Query_cache_block_table *node, size_t db_length,
3509 uint8 suffix_length_arg,
3510 uint8 cache_type,
3511 qc_engine_callback callback,
3512 ulonglong engine_data,
3513 my_bool hash)
3514{
3515 DBUG_ENTER("Query_cache::insert_table");
3516 DBUG_PRINT("qcache", ("insert table node %p, len %zu",
3517 node, key_len));
3518
3519 Query_cache_block *table_block=
3520 (hash ?
3521 (Query_cache_block *) my_hash_search(&tables, (uchar*) key, key_len) :
3522 NULL);
3523
3524 if (table_block &&
3525 table_block->table()->engine_data() != engine_data)
3526 {
3527 DBUG_PRINT("qcache",
3528 ("Handler require invalidation queries of %s.%s %llu-%llu",
3529 table_block->table()->db(),
3530 table_block->table()->table(),
3531 engine_data,
3532 table_block->table()->engine_data()));
3533 /*
3534 as far as we delete all queries with this table, table block will be
3535 deleted, too
3536 */
3537 {
3538 Query_cache_block_table *list_root= table_block->table(0);
3539 invalidate_query_block_list(list_root);
3540 }
3541
3542 table_block= 0;
3543 }
3544
3545 if (table_block == 0)
3546 {
3547 DBUG_PRINT("qcache", ("new table block from %p (%u)",
3548 key, (int) key_len));
3549 table_block= write_block_data(key_len, (uchar*) key,
3550 ALIGN_SIZE(sizeof(Query_cache_table)),
3551 Query_cache_block::TABLE, 1);
3552 if (table_block == 0)
3553 {
3554 DBUG_PRINT("qcache", ("Can't write table name to cache"));
3555 node->parent= NULL;
3556 DBUG_RETURN(0);
3557 }
3558 Query_cache_table *header= table_block->table();
3559 double_linked_list_simple_include(table_block,
3560 &tables_blocks);
3561 /*
3562 First node in the Query_cache_block_table-chain is the table-type
3563 block. This block will only have one Query_cache_block_table (n=0).

Calls 10

my_hash_searchFunction · 0.85
my_hash_insertFunction · 0.85
engine_dataMethod · 0.80
suffix_lengthMethod · 0.80
callbackMethod · 0.80
set_hashedMethod · 0.80
tableMethod · 0.45
dbMethod · 0.45
key_lengthMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected