mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
SQL: UPDATE on row-based replication [closes: #94]
This commit is contained in:
41
mysql-test/suite/versioning/r/rpl_row.result
Normal file
41
mysql-test/suite/versioning/r/rpl_row.result
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
include/master-slave.inc
|
||||||
|
[connection master]
|
||||||
|
connection slave;
|
||||||
|
connection master;
|
||||||
|
CREATE TABLE t1 (x int) with system versioning ENGINE = innodb;
|
||||||
|
insert into t1 values (1);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
delete from t1;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
connection master;
|
||||||
|
insert into t1 values (2);
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
2
|
||||||
|
connection master;
|
||||||
|
update t1 set x = 3;
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
3
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
3
|
||||||
|
2
|
||||||
|
connection master;
|
||||||
|
drop table t1;
|
||||||
|
include/rpl_end.inc
|
41
mysql-test/suite/versioning/r/rpl_stmt.result
Normal file
41
mysql-test/suite/versioning/r/rpl_stmt.result
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
include/master-slave.inc
|
||||||
|
[connection master]
|
||||||
|
connection slave;
|
||||||
|
connection master;
|
||||||
|
CREATE TABLE t1 (x int) with system versioning ENGINE = innodb;
|
||||||
|
insert into t1 values (1);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
delete from t1;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
connection master;
|
||||||
|
insert into t1 values (2);
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
2
|
||||||
|
connection master;
|
||||||
|
update t1 set x = 3;
|
||||||
|
connection slave;
|
||||||
|
select * from t1;
|
||||||
|
x
|
||||||
|
3
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
x
|
||||||
|
1
|
||||||
|
3
|
||||||
|
2
|
||||||
|
connection master;
|
||||||
|
drop table t1;
|
||||||
|
include/rpl_end.inc
|
7
mysql-test/suite/versioning/t/rpl_row.test
Normal file
7
mysql-test/suite/versioning/t/rpl_row.test
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- source include/have_binlog_format_row.inc
|
||||||
|
-- source include/master-slave.inc
|
||||||
|
-- source include/have_innodb.inc
|
||||||
|
|
||||||
|
-- source rpl_test.inc
|
||||||
|
|
||||||
|
-- source include/rpl_end.inc
|
7
mysql-test/suite/versioning/t/rpl_stmt.test
Normal file
7
mysql-test/suite/versioning/t/rpl_stmt.test
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
-- source include/have_binlog_format_statement.inc
|
||||||
|
-- source include/master-slave.inc
|
||||||
|
-- source include/have_innodb.inc
|
||||||
|
|
||||||
|
-- source rpl_test.inc
|
||||||
|
|
||||||
|
-- source include/rpl_end.inc
|
33
mysql-test/suite/versioning/t/rpl_test.inc
Normal file
33
mysql-test/suite/versioning/t/rpl_test.inc
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
#BUG#12662190 - COM_COMMIT IS NOT INCREMENTED FROM THE BINARY LOGS ON SLAVE, COM_BEGIN IS
|
||||||
|
#Testing command counters -BEFORE.
|
||||||
|
#Storing the before counts of Slave
|
||||||
|
connection slave;
|
||||||
|
let $slave_com_commit_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_commit', Value, 1);
|
||||||
|
let $slave_com_insert_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_insert', Value, 1);
|
||||||
|
let $slave_com_delete_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_delete', Value, 1);
|
||||||
|
let $slave_com_update_before= query_get_value(SHOW GLOBAL STATUS LIKE 'com_update', Value, 1);
|
||||||
|
|
||||||
|
connection master;
|
||||||
|
CREATE TABLE t1 (x int) with system versioning ENGINE = innodb;
|
||||||
|
insert into t1 values (1);
|
||||||
|
SELECT * FROM t1;
|
||||||
|
delete from t1;
|
||||||
|
select * from t1;
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
sync_slave_with_master;
|
||||||
|
select * from t1;
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
|
||||||
|
connection master;
|
||||||
|
insert into t1 values (2);
|
||||||
|
sync_slave_with_master;
|
||||||
|
select * from t1;
|
||||||
|
|
||||||
|
connection master;
|
||||||
|
update t1 set x = 3;
|
||||||
|
sync_slave_with_master;
|
||||||
|
select * from t1;
|
||||||
|
select * from t1 for system_time all;
|
||||||
|
|
||||||
|
connection master;
|
||||||
|
drop table t1;
|
@ -220,7 +220,8 @@ int ha_sequence::write_row(uchar *buf)
|
|||||||
sequence->copy(&tmp_seq);
|
sequence->copy(&tmp_seq);
|
||||||
rows_changed++;
|
rows_changed++;
|
||||||
/* We have to do the logging while we hold the sequence mutex */
|
/* We have to do the logging while we hold the sequence mutex */
|
||||||
error= binlog_log_row(table, 0, buf, log_func);
|
if (table->file->check_table_binlog_row_based(1))
|
||||||
|
error= binlog_log_row(table, 0, buf, log_func);
|
||||||
row_already_logged= 1;
|
row_already_logged= 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -254,7 +255,8 @@ int ha_sequence::update_row(const uchar *old_data, uchar *new_data)
|
|||||||
sequence->copy(&tmp_seq);
|
sequence->copy(&tmp_seq);
|
||||||
rows_changed++;
|
rows_changed++;
|
||||||
/* We have to do the logging while we hold the sequence mutex */
|
/* We have to do the logging while we hold the sequence mutex */
|
||||||
error= binlog_log_row(table, old_data, new_data,
|
if (table->file->check_table_binlog_row_based(1))
|
||||||
|
error= binlog_log_row(table, old_data, new_data,
|
||||||
Update_rows_log_event::binlog_row_logging_function);
|
Update_rows_log_event::binlog_row_logging_function);
|
||||||
row_already_logged= 1;
|
row_already_logged= 1;
|
||||||
}
|
}
|
||||||
|
@ -5795,10 +5795,10 @@ static int write_locked_table_maps(THD *thd)
|
|||||||
|
|
||||||
static int check_wsrep_max_ws_rows();
|
static int check_wsrep_max_ws_rows();
|
||||||
|
|
||||||
static int binlog_log_row_internal(TABLE* table,
|
int binlog_log_row(TABLE* table,
|
||||||
const uchar *before_record,
|
const uchar *before_record,
|
||||||
const uchar *after_record,
|
const uchar *after_record,
|
||||||
Log_func *log_func)
|
Log_func *log_func)
|
||||||
{
|
{
|
||||||
bool error= 0;
|
bool error= 0;
|
||||||
THD *const thd= table->in_use;
|
THD *const thd= table->in_use;
|
||||||
@ -5833,16 +5833,6 @@ static int binlog_log_row_internal(TABLE* table,
|
|||||||
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
|
return error ? HA_ERR_RBR_LOGGING_FAILED : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int binlog_log_row(TABLE* table,
|
|
||||||
const uchar *before_record,
|
|
||||||
const uchar *after_record,
|
|
||||||
Log_func *log_func)
|
|
||||||
{
|
|
||||||
if (!table->file->check_table_binlog_row_based(1))
|
|
||||||
return 0;
|
|
||||||
return binlog_log_row_internal(table, before_record, after_record, log_func);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int handler::ha_external_lock(THD *thd, int lock_type)
|
int handler::ha_external_lock(THD *thd, int lock_type)
|
||||||
{
|
{
|
||||||
@ -5991,7 +5981,8 @@ int handler::ha_write_row(uchar *buf)
|
|||||||
if (likely(!error) && !row_already_logged)
|
if (likely(!error) && !row_already_logged)
|
||||||
{
|
{
|
||||||
rows_changed++;
|
rows_changed++;
|
||||||
error= binlog_log_row(table, 0, buf, log_func);
|
if (table->file->check_table_binlog_row_based(1))
|
||||||
|
error= binlog_log_row(table, 0, buf, log_func);
|
||||||
}
|
}
|
||||||
DEBUG_SYNC_C("ha_write_row_end");
|
DEBUG_SYNC_C("ha_write_row_end");
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(error);
|
||||||
@ -6012,6 +6003,9 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
|
|||||||
DBUG_ASSERT(new_data == table->record[0]);
|
DBUG_ASSERT(new_data == table->record[0]);
|
||||||
DBUG_ASSERT(old_data == table->record[1]);
|
DBUG_ASSERT(old_data == table->record[1]);
|
||||||
|
|
||||||
|
// InnoDB changes sys_trx_end to curr_trx_id and we need to restore MAX_TRX
|
||||||
|
if (table->file->check_table_binlog_row_based(1))
|
||||||
|
memcpy(table->record[2], table->record[1], table->s->reclength);
|
||||||
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
|
MYSQL_UPDATE_ROW_START(table_share->db.str, table_share->table_name.str);
|
||||||
mark_trx_read_write();
|
mark_trx_read_write();
|
||||||
increment_statistics(&SSV::ha_update_count);
|
increment_statistics(&SSV::ha_update_count);
|
||||||
@ -6023,7 +6017,10 @@ int handler::ha_update_row(const uchar *old_data, uchar *new_data)
|
|||||||
if (likely(!error) && !row_already_logged)
|
if (likely(!error) && !row_already_logged)
|
||||||
{
|
{
|
||||||
rows_changed++;
|
rows_changed++;
|
||||||
error= binlog_log_row(table, old_data, new_data, log_func);
|
if (table->file->check_table_binlog_row_based(1)) {
|
||||||
|
memcpy(table->record[1], table->record[2], table->s->reclength);
|
||||||
|
error= binlog_log_row(table, old_data, new_data, log_func);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@ -6072,7 +6069,8 @@ int handler::ha_delete_row(const uchar *buf)
|
|||||||
if (likely(!error))
|
if (likely(!error))
|
||||||
{
|
{
|
||||||
rows_changed++;
|
rows_changed++;
|
||||||
error= binlog_log_row(table, buf, 0, log_func);
|
if (table->file->check_table_binlog_row_based(1))
|
||||||
|
error= binlog_log_row(table, buf, 0, log_func);
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user