Commit bac728a2 authored by Nikita Malyavin's avatar Nikita Malyavin Committed by Sergei Golubchik

MDEV-29069 follow-up: allow deterministic DEFAULTs

parent 2be4c836
...@@ -1073,8 +1073,8 @@ update t set a = a + 1 where a = 10; ...@@ -1073,8 +1073,8 @@ update t set a = a + 1 where a = 10;
set debug_sync= 'now signal goforit'; set debug_sync= 'now signal goforit';
connection default; connection default;
Warnings: Warnings:
Note 1105 Key chosen: -1 Note 1105 Key chosen: 0
Note 1105 Key chosen: -1 Note 1105 Key chosen: 0
select a from t; select a from t;
a a
11 11
...@@ -1093,8 +1093,8 @@ update t set a = a + 1 where a = 10; ...@@ -1093,8 +1093,8 @@ update t set a = a + 1 where a = 10;
set debug_sync= 'now signal goforit'; set debug_sync= 'now signal goforit';
connection default; connection default;
Warnings: Warnings:
Note 1105 Key chosen: -1 Note 1105 Key chosen: 0
Note 1105 Key chosen: -1 Note 1105 Key chosen: 0
# #
# Add key for old row # Add key for old row
# #
......
...@@ -7107,11 +7107,12 @@ static bool record_compare(TABLE *table, bool vers_from_plain= false) ...@@ -7107,11 +7107,12 @@ static bool record_compare(TABLE *table, bool vers_from_plain= false)
bool Rows_log_event::is_key_usable(const KEY *key) const bool Rows_log_event::is_key_usable(const KEY *key) const
{ {
RPL_TABLE_LIST *tl= (RPL_TABLE_LIST*)m_table->pos_in_table_list; 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(uint(key - m_table->key_info))) if (!m_table->s->keys_in_use.is_set(uint(key - m_table->key_info)))
return false; return false;
if (!tl->m_online_alter_copy_fields) if (!online_alter)
{ {
if (m_cols.n_bits >= m_table->s->fields) if (m_cols.n_bits >= m_table->s->fields)
return true; return true;
...@@ -7126,8 +7127,17 @@ bool Rows_log_event::is_key_usable(const KEY *key) const ...@@ -7126,8 +7127,17 @@ bool Rows_log_event::is_key_usable(const KEY *key) const
for (uint p= 0; p < key->user_defined_key_parts; p++) for (uint p= 0; p < key->user_defined_key_parts; p++)
{ {
uint field_idx= key->key_part[p].fieldnr - 1; Field *f= key->key_part[p].field;
if (!bitmap_is_set(&m_table->has_value_set, field_idx)) /*
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 false;
} }
return true; return true;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment