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

Function open_table_entry_fini

sql/sql_base.cc:3308–3375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3306*/
3307
3308static bool open_table_entry_fini(THD *thd, TABLE_SHARE *share, TABLE *entry)
3309{
3310 if (Table_triggers_list::check_n_load(thd, &share->db,
3311 &share->table_name, entry, 0))
3312 return TRUE;
3313
3314 /*
3315 If we are here, there was no fatal error (but error may be still
3316 uninitialized).
3317 */
3318 if (unlikely(entry->file->implicit_emptied))
3319 {
3320 entry->file->implicit_emptied= 0;
3321 if (mysql_bin_log.is_open())
3322 {
3323 static const char
3324 QUERY_START[]= "TRUNCATE TABLE ",
3325 QUERY_COMMENT[]=
3326 " /* generated by server for memory table after a restart */";
3327 StringBuffer<
3328 (sizeof(QUERY_START)-1) + (sizeof(QUERY_COMMENT)-1) +
3329 2 * (FN_REFLEN+3) // identifiers, quotes, and '.' & '\0'
3330 > query(system_charset_info);
3331 query.append(STRING_WITH_LEN(QUERY_START));
3332 append_identifier(thd, &query, &share->db);
3333 query.append('.');
3334 append_identifier(thd, &query, &share->table_name);
3335 query.append(STRING_WITH_LEN(QUERY_COMMENT));
3336 /*
3337 we bypass thd->binlog_query() here,
3338 as it does a lot of extra work, that is simply wrong in this case
3339 */
3340 Query_log_event qinfo(thd, query.ptr(), query.length(),
3341 FALSE, TRUE, TRUE, 0);
3342 if (mysql_bin_log.write(&qinfo))
3343 return TRUE;
3344#ifdef HAVE_REPLICATION
3345 // Verbosity Level "Binlog/Replication"
3346 if (opt_readonly && global_system_variables.log_warnings >= 1)
3347 {
3348 extern Master_info_index *master_info_index;
3349 extern Master_info *active_mi;
3350 /*
3351 Use the count to tell whether this server is a slave (candidate).
3352 Though currently this count is always at least 1,
3353 with a permanent @ref active_mi entry that's invalidated when
3354 @ref Master_info::host is empty.
3355 The atomicity of this check is not important here, since results are
3356 influenced by the timing of any concurrent CHANGE MASTER regardless.
3357 */
3358 if (active_mi->host[0] ||
3359 master_info_index->master_info_hash.records > 1)
3360 {
3361 const rpl_gtid *gtid= thd->get_last_commit_gtid();
3362 sql_print_warning(
3363 "A server restart has recreated the memory table %sQ.%sQ; "
3364 "a TRUNCATE query is written to the binary log at GTID %u-%u-%llu. "
3365 "As this server is a read-only slave, "

Callers 1

open_tableFunction · 0.85

Calls 8

get_last_commit_gtidMethod · 0.80
append_identifierFunction · 0.70
sql_print_warningFunction · 0.70
is_openMethod · 0.45
appendMethod · 0.45
ptrMethod · 0.45
lengthMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected