mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-31776 Online ALTER reports the number of affected rows incorrectly
Add a new virtual function that will increase the inserted rows count for the insert log event and decrease it for the delete event. Reuses Rows_log_event::m_row_count on the replication side, which was only set on the logging side.
This commit is contained in:
committed by
Sergei Golubchik
parent
9c8554259a
commit
e026a366bf
@ -16,6 +16,8 @@ connection con2;
|
|||||||
insert into t1 values (123), (456), (789);
|
insert into t1 values (123), (456), (789);
|
||||||
set debug_sync= 'now SIGNAL end';
|
set debug_sync= 'now SIGNAL end';
|
||||||
connection default;
|
connection default;
|
||||||
|
affected rows: 4
|
||||||
|
info: Records: 4 Duplicates: 0 Warnings: 0
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b
|
a b
|
||||||
5 NULL
|
5 NULL
|
||||||
@ -123,6 +125,8 @@ connection con2;
|
|||||||
update t1 set b= 55 where a = 1;
|
update t1 set b= 55 where a = 1;
|
||||||
set debug_sync= 'now SIGNAL end';
|
set debug_sync= 'now SIGNAL end';
|
||||||
connection default;
|
connection default;
|
||||||
|
affected rows: 2
|
||||||
|
info: Records: 2 Duplicates: 0 Warnings: 0
|
||||||
select * from t1;
|
select * from t1;
|
||||||
a b c
|
a b c
|
||||||
1 55 1
|
1 55 1
|
||||||
|
@ -33,7 +33,9 @@ insert into t1 values (123), (456), (789);
|
|||||||
set debug_sync= 'now SIGNAL end';
|
set debug_sync= 'now SIGNAL end';
|
||||||
|
|
||||||
--connection default
|
--connection default
|
||||||
|
--enable_info
|
||||||
--reap
|
--reap
|
||||||
|
--disable_info
|
||||||
select * from t1;
|
select * from t1;
|
||||||
|
|
||||||
--echo # Insert, error
|
--echo # Insert, error
|
||||||
@ -167,7 +169,9 @@ update t1 set b= 55 where a = 1;
|
|||||||
set debug_sync= 'now SIGNAL end';
|
set debug_sync= 'now SIGNAL end';
|
||||||
|
|
||||||
--connection default
|
--connection default
|
||||||
|
--enable_info
|
||||||
--reap
|
--reap
|
||||||
|
--disable_info
|
||||||
select * from t1;
|
select * from t1;
|
||||||
|
|
||||||
--echo # Update and add a column in the middle
|
--echo # Update and add a column in the middle
|
||||||
|
@ -1564,6 +1564,12 @@ public:
|
|||||||
|
|
||||||
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
||||||
|
|
||||||
|
/**
|
||||||
|
Increase or decrease the rows inserted during ALTER TABLE based on the event
|
||||||
|
type.
|
||||||
|
*/
|
||||||
|
virtual void online_alter_update_row_count(ha_rows *) const {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Apply the event to the database.
|
Apply the event to the database.
|
||||||
|
|
||||||
@ -4973,6 +4979,11 @@ public:
|
|||||||
|
|
||||||
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
||||||
uint8 get_trg_event_map() const override;
|
uint8 get_trg_event_map() const override;
|
||||||
|
|
||||||
|
void online_alter_update_row_count(ha_rows *rows) const override
|
||||||
|
{
|
||||||
|
*rows += m_row_count;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -5148,6 +5159,11 @@ public:
|
|||||||
|
|
||||||
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
#if defined(MYSQL_SERVER) && defined(HAVE_REPLICATION)
|
||||||
uint8 get_trg_event_map() const override;
|
uint8 get_trg_event_map() const override;
|
||||||
|
|
||||||
|
void online_alter_update_row_count(ha_rows *rows) const override
|
||||||
|
{
|
||||||
|
*rows -= m_row_count;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -5184,6 +5184,7 @@ int Rows_log_event::do_apply_event(rpl_group_info *rgi)
|
|||||||
thd->transaction->stmt.modified_non_trans_table= TRUE;
|
thd->transaction->stmt.modified_non_trans_table= TRUE;
|
||||||
if (likely(error == 0))
|
if (likely(error == 0))
|
||||||
{
|
{
|
||||||
|
m_row_count++;
|
||||||
error= thd->killed_errno();
|
error= thd->killed_errno();
|
||||||
if (error && !thd->is_error())
|
if (error && !thd->is_error())
|
||||||
my_error(error, MYF(0));
|
my_error(error, MYF(0));
|
||||||
|
@ -11656,7 +11656,8 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
|
static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
|
||||||
Cache_flip_event_log *log)
|
Cache_flip_event_log *log,
|
||||||
|
ha_rows *found_rows)
|
||||||
{
|
{
|
||||||
int error= 0;
|
int error= 0;
|
||||||
|
|
||||||
@ -11681,8 +11682,11 @@ static int online_alter_read_from_binlog(THD *thd, rpl_group_info *rgi,
|
|||||||
|
|
||||||
ev->thd= thd;
|
ev->thd= thd;
|
||||||
error= ev->apply_event(rgi);
|
error= ev->apply_event(rgi);
|
||||||
if (thd->is_error())
|
|
||||||
error= 1;
|
error= error || thd->is_error();
|
||||||
|
if(likely(!error))
|
||||||
|
ev->online_alter_update_row_count(found_rows);
|
||||||
|
|
||||||
if (ev != rgi->rli->relay_log.description_event_for_exec)
|
if (ev != rgi->rli->relay_log.description_event_for_exec)
|
||||||
delete ev;
|
delete ev;
|
||||||
thd_progress_report(thd, my_b_tell(log_file), thd->progress.max_counter);
|
thd_progress_report(thd, my_b_tell(log_file), thd->progress.max_counter);
|
||||||
@ -12108,7 +12112,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
mysql_unlock_tables(thd, thd->lock);
|
mysql_unlock_tables(thd, thd->lock);
|
||||||
thd->lock= NULL;
|
thd->lock= NULL;
|
||||||
|
|
||||||
error= online_alter_read_from_binlog(thd, &rgi, binlog);
|
error= online_alter_read_from_binlog(thd, &rgi, binlog, &found_count);
|
||||||
if (start_alter_id)
|
if (start_alter_id)
|
||||||
{
|
{
|
||||||
DBUG_ASSERT(thd->slave_thread);
|
DBUG_ASSERT(thd->slave_thread);
|
||||||
@ -12129,7 +12133,7 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
if (!error)
|
if (!error)
|
||||||
{
|
{
|
||||||
thd_progress_next_stage(thd);
|
thd_progress_next_stage(thd);
|
||||||
error= online_alter_read_from_binlog(thd, &rgi, binlog);
|
error= online_alter_read_from_binlog(thd, &rgi, binlog, &found_count);
|
||||||
}
|
}
|
||||||
if (error)
|
if (error)
|
||||||
from->s->tdc->flush_unused(1); // to free the binlog
|
from->s->tdc->flush_unused(1); // to free the binlog
|
||||||
|
Reference in New Issue
Block a user