diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-06-02 16:51:13 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-06-02 16:51:13 +0300 |
commit | 4b3c3e526e7067da921d0aef8451b6e2736a5fe0 (patch) | |
tree | 40a6d851d7c39c443c587e29a725afda85c65929 /sql | |
parent | e7de50a82187cbaaa192c2065d64c0041cd9a6a1 (diff) | |
parent | 96f4b4a55b449a29af7e4b70bebf0ff238ae7f80 (diff) | |
download | mariadb-git-4b3c3e526e7067da921d0aef8451b6e2736a5fe0.tar.gz |
Merge 10.4 into 10.5
Diffstat (limited to 'sql')
-rw-r--r-- | sql/ha_sequence.cc | 3 | ||||
-rw-r--r-- | sql/log.cc | 10 | ||||
-rw-r--r-- | sql/log.h | 2 | ||||
-rw-r--r-- | sql/partition_info.cc | 2 | ||||
-rw-r--r-- | sql/sql_partition_admin.cc | 8 | ||||
-rw-r--r-- | sql/sql_sequence.cc | 11 | ||||
-rw-r--r-- | sql/table.h | 5 | ||||
-rw-r--r-- | sql/wsrep_binlog.cc | 8 | ||||
-rw-r--r-- | sql/wsrep_client_service.cc | 29 | ||||
-rw-r--r-- | sql/wsrep_mysqld.cc | 10 |
10 files changed, 69 insertions, 19 deletions
diff --git a/sql/ha_sequence.cc b/sql/ha_sequence.cc index 2447242593c..b348e6e7025 100644 --- a/sql/ha_sequence.cc +++ b/sql/ha_sequence.cc @@ -452,6 +452,9 @@ static int sequence_initialize(void *p) HTON_HIDDEN | HTON_TEMPORARY_NOT_SUPPORTED | HTON_ALTER_NOT_SUPPORTED | +#ifdef WITH_WSREP + HTON_WSREP_REPLICATION | +#endif HTON_NO_PARTITION); DBUG_RETURN(0); } diff --git a/sql/log.cc b/sql/log.cc index b6e7e644567..a92b180a9a7 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2147,7 +2147,13 @@ static int binlog_commit(handlerton *hton, THD *thd, bool all) thd->backup_stage(&org_stage); THD_STAGE_INFO(thd, stage_binlog_write); +#ifdef WITH_WSREP + // DON'T clear stmt cache in case we are in transaction + if (!cache_mngr->stmt_cache.empty() && + (!wsrep_on(thd) || ending_trans(thd, all))) +#else if (!cache_mngr->stmt_cache.empty()) +#endif { error= binlog_commit_flush_stmt_cache(thd, all, cache_mngr); } @@ -11013,13 +11019,13 @@ maria_declare_plugin_end; #ifdef WITH_WSREP #include "wsrep_mysqld.h" -IO_CACHE *wsrep_get_trans_cache(THD * thd) +IO_CACHE *wsrep_get_cache(THD * thd, bool is_transactional) { DBUG_ASSERT(binlog_hton->slot != HA_SLOT_UNDEF); binlog_cache_mngr *cache_mngr = (binlog_cache_mngr*) thd_get_ha_data(thd, binlog_hton); if (cache_mngr) - return cache_mngr->get_binlog_cache_log(true); + return cache_mngr->get_binlog_cache_log(is_transactional); WSREP_DEBUG("binlog cache not initialized, conn: %llu", thd->thread_id); diff --git a/sql/log.h b/sql/log.h index 584b63879de..e4a4d9c2fb2 100644 --- a/sql/log.h +++ b/sql/log.h @@ -1247,7 +1247,7 @@ static inline TC_LOG *get_tc_log_implementation() } #ifdef WITH_WSREP -IO_CACHE* wsrep_get_trans_cache(THD *); +IO_CACHE* wsrep_get_cache(THD *, bool); void wsrep_thd_binlog_trx_reset(THD * thd); void wsrep_thd_binlog_stmt_rollback(THD * thd); #endif /* WITH_WSREP */ diff --git a/sql/partition_info.cc b/sql/partition_info.cc index bb511b0020c..959dd674101 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -884,10 +884,12 @@ void partition_info::vers_check_limit(THD *thd) bitmap_set_all(), but this is not optimal since there can be quite a number of partitions. */ +#ifndef DBUG_OFF const uint32 sub_factor= num_subparts ? num_subparts : 1; uint32 part_id= vers_info->hist_part->id * sub_factor; const uint32 part_id_end= part_id + sub_factor; DBUG_ASSERT(part_id_end <= num_parts * sub_factor); +#endif ha_partition *hp= (ha_partition*)(table->file); ha_rows hist_rows= hp->part_records(vers_info->hist_part); diff --git a/sql/sql_partition_admin.cc b/sql/sql_partition_admin.cc index 058e5909a25..3a22c9f6201 100644 --- a/sql/sql_partition_admin.cc +++ b/sql/sql_partition_admin.cc @@ -568,6 +568,14 @@ bool Sql_cmd_alter_table_exchange_partition:: part_table= table_list->table; swap_table= swap_table_list->table; + /* Don't allow to exchange with a VIEW */ + if (unlikely(swap_table_list->view)) + { + my_error(ER_WRONG_OBJECT, MYF(0), table_list->db.str, + swap_table_list->table_name.str, "BASE TABLE"); + DBUG_RETURN(TRUE); + } + if (unlikely(check_exchange_partition(swap_table, part_table))) DBUG_RETURN(TRUE); diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 7ef30641888..07571c3bbac 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -309,6 +309,11 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *org_table_list) DBUG_RETURN(TRUE); } +#ifdef WITH_WSREP + if (WSREP_ON && seq->cache != 0) + WSREP_WARN("CREATE SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster."); +#endif + /* If not temporary table */ if (!temporary_table) { @@ -901,12 +906,18 @@ bool Sql_cmd_alter_sequence::execute(THD *thd) No_such_table_error_handler no_such_table_handler; DBUG_ENTER("Sql_cmd_alter_sequence::execute"); + if (check_access(thd, ALTER_ACL, first_table->db.str, &first_table->grant.privilege, &first_table->grant.m_internal, 0, 0)) DBUG_RETURN(TRUE); /* purecov: inspected */ +#ifdef WITH_WSREP + if (WSREP_ON && new_seq->cache != 0) + WSREP_WARN("ALTER SEQUENCES declared without `NOCACHE` will not behave correctly in galera cluster."); +#endif + if (check_grant(thd, ALTER_ACL, first_table, FALSE, 1, FALSE)) DBUG_RETURN(TRUE); /* purecov: inspected */ diff --git a/sql/table.h b/sql/table.h index dbdeefafdb7..8a9b4c46a47 100644 --- a/sql/table.h +++ b/sql/table.h @@ -1,7 +1,7 @@ #ifndef TABLE_INCLUDED #define TABLE_INCLUDED /* Copyright (c) 2000, 2017, Oracle and/or its affiliates. - Copyright (c) 2009, 2021, MariaDB + Copyright (c) 2009, 2022, MariaDB This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -3171,9 +3171,6 @@ enum open_frm_error open_table_from_share(THD *thd, TABLE_SHARE *share, bool is_create_table, List<String> *partitions_to_open= NULL); bool copy_keys_from_share(TABLE *outparam, MEM_ROOT *root); -bool fix_session_vcol_expr(THD *thd, Virtual_column_info *vcol); -bool fix_session_vcol_expr_for_read(THD *thd, Field *field, - Virtual_column_info *vcol); bool parse_vcol_defs(THD *thd, MEM_ROOT *mem_root, TABLE *table, bool *error_reported, vcol_init_mode expr); TABLE_SHARE *alloc_table_share(const char *db, const char *table_name, diff --git a/sql/wsrep_binlog.cc b/sql/wsrep_binlog.cc index 3fe0792d83e..bcc5d2fe46d 100644 --- a/sql/wsrep_binlog.cc +++ b/sql/wsrep_binlog.cc @@ -155,10 +155,10 @@ static int wsrep_write_cache_inc(THD* const thd, goto cleanup; cache->read_pos= cache->read_end; } while ((cache->file >= 0) && (length= my_b_fill(cache))); - } - if (ret == 0) - { - assert(total_length + thd->wsrep_sr().log_position() == saved_pos); + if (ret == 0) + { + assert(total_length + thd->wsrep_sr().log_position() == saved_pos); + } } cleanup: diff --git a/sql/wsrep_client_service.cc b/sql/wsrep_client_service.cc index b7107178717..869234de491 100644 --- a/sql/wsrep_client_service.cc +++ b/sql/wsrep_client_service.cc @@ -85,18 +85,37 @@ int Wsrep_client_service::prepare_data_for_replication() DBUG_ASSERT(m_thd == current_thd); DBUG_ENTER("Wsrep_client_service::prepare_data_for_replication"); size_t data_len= 0; - IO_CACHE* cache= wsrep_get_trans_cache(m_thd); + IO_CACHE* transactional_cache= wsrep_get_cache(m_thd, true); + IO_CACHE* stmt_cache= wsrep_get_cache(m_thd, false); - if (cache) + if (transactional_cache || stmt_cache) { m_thd->binlog_flush_pending_rows_event(true); - if (wsrep_write_cache(m_thd, cache, &data_len)) + + size_t transactional_data_len= 0; + size_t stmt_data_len= 0; + + // Write transactional cache + if (transactional_cache && + wsrep_write_cache(m_thd, transactional_cache, &transactional_data_len)) { WSREP_ERROR("rbr write fail, data_len: %zu", data_len); // wsrep_override_error(m_thd, ER_ERROR_DURING_COMMIT); DBUG_RETURN(1); } + + // Write stmt cache + if (stmt_cache && wsrep_write_cache(m_thd, stmt_cache, &stmt_data_len)) + { + WSREP_ERROR("rbr write fail, data_len: %zu", + data_len); + // wsrep_override_error(m_thd, ER_ERROR_DURING_COMMIT); + DBUG_RETURN(1); + } + + // Complete data written from both caches + data_len = transactional_data_len + stmt_data_len; } if (data_len == 0) @@ -138,7 +157,7 @@ int Wsrep_client_service::prepare_fragment_for_replication( DBUG_ASSERT(m_thd == current_thd); THD* thd= m_thd; DBUG_ENTER("Wsrep_client_service::prepare_fragment_for_replication"); - IO_CACHE* cache= wsrep_get_trans_cache(thd); + IO_CACHE* cache= wsrep_get_cache(thd, true); thd->binlog_flush_pending_rows_event(true); if (!cache) @@ -220,7 +239,7 @@ bool Wsrep_client_service::statement_allowed_for_streaming() const size_t Wsrep_client_service::bytes_generated() const { - IO_CACHE* cache= wsrep_get_trans_cache(m_thd); + IO_CACHE* cache= wsrep_get_cache(m_thd, true); if (cache) { size_t pending_rows_event_length= 0; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 4c74d22c325..c20ebead8d6 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -650,7 +650,7 @@ static std::string wsrep_server_incoming_address() bool is_ipv6= false; unsigned int my_bind_ip= INADDR_ANY; // default if not set - if (my_bind_addr_str && strlen(my_bind_addr_str) && + if (my_bind_addr_str && strlen(my_bind_addr_str) && strcmp(my_bind_addr_str, "*") != 0) { my_bind_ip= wsrep_check_ip(my_bind_addr_str, &is_ipv6); @@ -715,9 +715,13 @@ static std::string wsrep_server_incoming_address() snprintf(inc_addr, inc_addr_max, fmt, addr.get_address(), port); } - + done: - ret= wsrep_node_incoming_address; + if (!strlen(inc_addr)) + ret= wsrep_node_incoming_address; + else + ret= inc_addr; + WSREP_DEBUG("wsrep_incoming_address = %s", ret.c_str()); return ret; } |