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

Function close_thread_table

sql/sql_base.cc:1020–1081  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1018/* move one table to free list */
1019
1020void close_thread_table(THD *thd, TABLE **table_ptr)
1021{
1022 TABLE *table= *table_ptr;
1023 handler *file= table->file;
1024 DBUG_ENTER("close_thread_table");
1025 DBUG_PRINT("tcache", ("table: '%s'.'%s' %p", table->s->db.str,
1026 table->s->table_name.str, table));
1027 DBUG_ASSERT(!file->keyread_enabled());
1028 DBUG_ASSERT(file->inited == handler::NONE);
1029
1030 /*
1031 The metadata lock must be released after giving back
1032 the table to the table cache.
1033 */
1034 DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE,
1035 table->s->db.str,
1036 table->s->table_name.str,
1037 MDL_SHARED) ||
1038 thd->mdl_context.is_lock_warrantee(MDL_key::TABLE,
1039 table->s->db.str,
1040 table->s->table_name.str,
1041 MDL_SHARED));
1042 table->vcol_cleanup_expr(thd);
1043 table->mdl_ticket= NULL;
1044
1045 file->update_global_table_stats();
1046 file->update_global_index_stats();
1047 if (unlikely(file->handler_stats) && file->handler_stats->active)
1048 {
1049 Exec_time_tracker *tracker;
1050 if ((tracker= file->get_time_tracker()))
1051 file->handler_stats->engine_time+= tracker->get_cycles();
1052 thd->handler_stats.add(file->handler_stats);
1053 }
1054 /*
1055 This lock is needed to allow THD::notify_shared_lock() to
1056 traverse the thd->open_tables list without having to worry that
1057 some of the tables are removed from under it
1058 */
1059
1060 mysql_mutex_lock(&thd->LOCK_thd_data);
1061 *table_ptr=table->next;
1062 mysql_mutex_unlock(&thd->LOCK_thd_data);
1063
1064 if (! table->needs_reopen())
1065 {
1066 /* Avoid having MERGE tables with attached children in table cache. */
1067 file->extra(HA_EXTRA_DETACH_CHILDREN);
1068 /* Free memory and reset for next loop. */
1069 free_field_buffers_larger_than(table, MAX_TDC_BLOB_SIZE);
1070 file->ha_reset();
1071 }
1072
1073 /*
1074 Do this *before* entering the TABLE_SHARE::tdc.LOCK_table_share
1075 critical section.
1076 */
1077 MYSQL_UNBIND_TABLE(file);

Callers 9

handle_alter_part_errorFunction · 0.85
mysql_create_like_tableFunction · 0.85
mysql_ha_close_childsFunction · 0.85
mysql_ha_close_tableFunction · 0.85
close_thread_tablesFunction · 0.85
drop_open_tableFunction · 0.85
reopen_tablesMethod · 0.85

Calls 14

tc_release_tableFunction · 0.85
keyread_enabledMethod · 0.80
is_lock_ownerMethod · 0.80
is_lock_warranteeMethod · 0.80
vcol_cleanup_exprMethod · 0.80
get_cyclesMethod · 0.80
needs_reopenMethod · 0.80
ha_resetMethod · 0.80
get_time_trackerMethod · 0.45

Tested by

no test coverage detected