From 8a8f71b8b82cc394a9e19b6f478d29d560220fd4 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 7 Nov 2022 16:10:10 +0100 Subject: [PATCH] cleanup: ifdefs --- sql/field.cc | 1 - sql/item.cc | 2 +- sql/log_event_server.cc | 21 +++++++-------------- sql/records.cc | 3 +-- sql/sql_cache.h | 3 +++ sql/sql_parse.cc | 4 +--- sql/sql_table.cc | 6 ++---- 7 files changed, 15 insertions(+), 25 deletions(-) diff --git a/sql/field.cc b/sql/field.cc index 8b30c6a71ed..5acebecd5c4 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -10508,7 +10508,6 @@ void Column_definition::create_length_to_internal_length_newdecimal() bool check_expression(Virtual_column_info *vcol, const LEX_CSTRING *name, enum_vcol_info_type type, Alter_info *alter_info) - { bool ret; Item::vcol_func_processor_result res; diff --git a/sql/item.cc b/sql/item.cc index a07b5532f83..e7815941a84 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -1560,7 +1560,7 @@ bool Item_field::check_vcol_func_processor(void *arg) { context= 0; vcol_func_processor_result *res= (vcol_func_processor_result *) arg; - if (res && res->alter_info) + if (res->alter_info) { for (Key &k: res->alter_info->key_list) { diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index 1b4f4db1d2e..f007799100c 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -53,6 +53,7 @@ #include "wsrep_mysqld.h" #include "sql_insert.h" #include "sql_table.h" +#include #include #include "rpl_utility.h" @@ -5027,17 +5028,13 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) } } -#ifdef HAVE_QUERY_CACHE /* Moved invalidation right before the call to rows_event_stmt_cleanup(), to avoid query cache being polluted with stale entries, + Query cache is not invalidated on wsrep applier here */ -# ifdef WITH_WSREP - /* Query cache is not invalidated on wsrep applier here */ if (!(WSREP(thd) && wsrep_thd_is_applying(thd))) -# endif /* WITH_WSREP */ query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); -#endif /* HAVE_QUERY_CACHE */ } table= m_table= rgi->m_table_map.get_table(m_table_id); @@ -5250,10 +5247,8 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi) /* remove trigger's tables */ restore_empty_query_table_list(thd->lex); -#if defined(WITH_WSREP) && defined(HAVE_QUERY_CACHE) if (WSREP(thd) && wsrep_thd_is_applying(thd)) - query_cache.invalidate_locked_for_write(thd, rgi->tables_to_lock); -#endif /* WITH_WSREP && HAVE_QUERY_CACHE */ + query_cache_invalidate_locked_for_write(thd, rgi->tables_to_lock); if (get_flags(STMT_END_F)) { @@ -6751,14 +6746,12 @@ int Rows_log_event::write_row(rpl_group_info *rgi, const bool overwrite) TODO: Add safety measures against infinite looping. */ - if (table->s->sequence) + if (unlikely(table->s->sequence)) error= update_sequence(); else while (unlikely(error= table->file->ha_write_row(table->record[0]))) { - if (error == HA_ERR_LOCK_DEADLOCK || - error == HA_ERR_LOCK_WAIT_TIMEOUT || - (keynum= table->file->get_dup_key(error)) < 0 || - !overwrite) + if (error == HA_ERR_LOCK_DEADLOCK || error == HA_ERR_LOCK_WAIT_TIMEOUT || + (keynum= table->file->get_dup_key(error)) < 0 || !overwrite) { DBUG_PRINT("info",("get_dup_key returns %d)", keynum)); /* @@ -7431,7 +7424,7 @@ int Rows_log_event::find_row(rpl_group_info *rgi) if (table->key_info->flags & HA_NOSAME) { /* Unique does not have non nullable part */ - if (!(table->key_info->flags & (HA_NULL_PART_KEY))) + if (!(table->key_info->flags & HA_NULL_PART_KEY)) { error= 0; goto end; diff --git a/sql/records.cc b/sql/records.cc index 5b2ebefe14f..eb4d5f4d958 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -197,8 +197,7 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table, info->table=table; info->sort_info= filesort; - if ((table->s->tmp_table == INTERNAL_TMP_TABLE) && - !using_addon_fields) + if ((table->s->tmp_table == INTERNAL_TMP_TABLE) && !using_addon_fields) (void) table->file->extra(HA_EXTRA_MMAP); if (using_addon_fields) diff --git a/sql/sql_cache.h b/sql/sql_cache.h index a02034764a7..30522e9e8ff 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -584,6 +584,8 @@ struct Query_cache_query_flags query_cache.send_result_to_client(A, B, C) #define query_cache_invalidate_by_MyISAM_filename_ref \ &query_cache_invalidate_by_MyISAM_filename +#define query_cache_invalidate_locked_for_write(A, B) \ + query_cache.invalidate_locked_for_write(A, B) /* note the "maybe": it's a read without mutex */ #define query_cache_maybe_disabled(T) \ (T->variables.query_cache_type == 0 || query_cache.query_cache_size == 0) @@ -601,6 +603,7 @@ struct Query_cache_query_flags #define query_cache_invalidate1(A,B) do { } while(0) #define query_cache_send_result_to_client(A, B, C) 0 #define query_cache_invalidate_by_MyISAM_filename_ref NULL +#define query_cache_invalidate_locked_for_write(A, B) do { } while(0) #define query_cache_abort(A,B) do { } while(0) #define query_cache_end_of_result(A) do { } while(0) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e745ee3d4d5..11bca673aae 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4899,10 +4899,8 @@ mysql_execute_command(THD *thd, bool is_called_from_prepared_stmt) } else { -#ifdef HAVE_QUERY_CACHE if (thd->variables.query_cache_wlock_invalidate) - query_cache.invalidate_locked_for_write(thd, first_table); -#endif /*HAVE_QUERY_CACHE*/ + query_cache_invalidate_locked_for_write(thd, first_table); my_ok(thd); } break; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0a69505de47..9df3796edc4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -10965,11 +10965,9 @@ do_continue:; DEBUG_SYNC(thd, "alter_table_intermediate_table_created"); /* Open the table since we need to copy the data. */ - new_table= thd->create_and_open_tmp_table(&frm, - alter_ctx.get_tmp_path(), + new_table= thd->create_and_open_tmp_table(&frm, alter_ctx.get_tmp_path(), alter_ctx.new_db.str, - alter_ctx.new_name.str, - true); + alter_ctx.new_name.str, true); if (!new_table) goto err_new_table_cleanup;