diff options
author | Sergei Golubchik <serg@mariadb.org> | 2022-05-31 22:06:27 +0200 |
---|---|---|
committer | Nikita Malyavin <nikitamalyavin@gmail.com> | 2022-08-23 16:36:25 +0300 |
commit | 0538097659144437602ebf771714e415b44c39a6 (patch) | |
tree | 64622d8f78b00588832af34e8b03a06de0ebf8cb | |
parent | 6bdbcfbbbeeaa2cdb0000fe00c5cba5aa7eb6e6f (diff) | |
download | mariadb-git-0538097659144437602ebf771714e415b44c39a6.tar.gz |
set read_set early, before row reads
also
* don't modify write_set
* backup/restore rpl_write_set
-rw-r--r-- | sql/handler.cc | 9 | ||||
-rw-r--r-- | sql/table.cc | 24 |
2 files changed, 29 insertions, 4 deletions
diff --git a/sql/handler.cc b/sql/handler.cc index e4798416bed..72e806a7ed5 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -7056,14 +7056,17 @@ static int binlog_log_row_online_alter(TABLE* table, trans_register_ha(thd, true, binlog_hton, 0); } - // We need to log all columns for the case if alter table changes primary key. - table->use_all_columns(); - bitmap_set_all(table->rpl_write_set); + // We need to log all columns for the case if alter table changes primary key + DBUG_ASSERT(!before_record || bitmap_is_set_all(table->read_set)); + MY_BITMAP *old_rpl_write_set= table->rpl_write_set; + table->rpl_write_set= &table->s->all_set; int error= (*log_func)(thd, table, table->s->online_alter_binlog, table->online_alter_cache, has_trans, before_record, after_record); + table->rpl_write_set= old_rpl_write_set; + return unlikely(error) ? HA_ERR_RBR_LOGGING_FAILED : 0; } #endif // HAVE_REPLICATION diff --git a/sql/table.cc b/sql/table.cc index d5a541b5cc7..5fa2f3fd748 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -7506,6 +7506,17 @@ void TABLE::mark_columns_needed_for_delete() bitmap_set_bit(write_set, s->vers.end_fieldno); need_signal= true; } +#ifdef HAVE_REPLICATION + if (s->online_alter_binlog) + { + /* + For online alter we have to read all columns, because we need PK columns + in the row event, and we don't know what columns will be in PK after ALTER + */ + bitmap_set_all(read_set); + need_signal= true; + } +#endif if (need_signal) file->column_bitmaps_signal(); @@ -7590,9 +7601,20 @@ void TABLE::mark_columns_needed_for_update() For System Versioning we have to read all columns since we store a copy of previous row with modified row_end back to a table. */ - bitmap_union(read_set, &s->all_set); + bitmap_set_all(read_set); need_signal= true; } +#ifdef HAVE_REPLICATION + if (s->online_alter_binlog) + { + /* + For online alter we have to read all columns, because we need PK columns + in the row event, and we don't know what columns will be in PK after ALTER + */ + bitmap_set_all(read_set); + need_signal= true; + } +#endif if (check_constraints) { mark_check_constraint_columns_for_read(); |