diff options
author | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-07-19 00:29:42 +0300 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2023-05-05 15:59:17 +0300 |
commit | 6dc017b88ab4c75051a7d155e1d9914473676e99 (patch) | |
tree | b4ad97c880dc792d48f04ca260bd079a9f7b111c /sql | |
parent | 4d03cf12ccea89bfae52311008752f8b3261f4aa (diff) | |
download | mariadb-git-6dc017b88ab4c75051a7d155e1d9914473676e99.tar.gz |
MDEV-29069 follow-up: allow deterministic DEFAULTs
Diffstat (limited to 'sql')
-rw-r--r-- | sql/log_event_server.cc | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/sql/log_event_server.cc b/sql/log_event_server.cc index cd18ac38996..0f4c8a8aa72 100644 --- a/sql/log_event_server.cc +++ b/sql/log_event_server.cc @@ -7025,11 +7025,12 @@ record_compare_differ: bool Rows_log_event::is_key_usable(const KEY *key) const { RPL_TABLE_LIST *tl= (RPL_TABLE_LIST*)m_table->pos_in_table_list; + const bool online_alter= tl->m_online_alter_copy_fields; if (!m_table->s->keys_in_use.is_set(key - m_table->key_info)) return false; - if (!tl->m_online_alter_copy_fields) + if (!online_alter) { if (m_cols.n_bits >= m_table->s->fields) return true; @@ -7044,8 +7045,17 @@ bool Rows_log_event::is_key_usable(const KEY *key) const for (uint p= 0; p < key->user_defined_key_parts; p++) { - uint field_idx= key->key_part[p].fieldnr - 1; - if (!bitmap_is_set(&m_table->has_value_set, field_idx)) + Field *f= key->key_part[p].field; + /* + in the online alter case (but not in replication) we don't have + to reject an index if it includes new columns, as long as + their values are deterministic. + */ + bool non_deterministic_default= f->default_value && + f->default_value->flags & VCOL_NOT_STRICTLY_DETERMINISTIC; + bool next_number_field= f == f->table->next_number_field; + if (!bitmap_is_set(&m_table->has_value_set, f->field_index) && + (!online_alter || non_deterministic_default || next_number_field)) return false; } return true; |