Time Id Command Argument
2021-08-30T00:01:20.435547+08:00 5 Quit
2021-08-30T00:42:57.625528+08:00 6 Connect admin@10.4.45.58 on using TCP/IP
2021-08-30T00:42:57.625652+08:00 6 Query SET NAMES utf8mb4
2021-08-30T00:42:57.625767+08:00 6 Query SET autocommit=1
2021-08-30T00:42:57.625957+08:00 6 Query show variables like 'log_bin'
2021-08-30T00:42:57.626816+08:00 7 Connect ro_query@10.4.45.58 on using TCP/IP
2021-08-30T00:42:57.626939+08:00 7 Query SET NAMES utf8mb4
2021-08-30T00:42:57.627049+08:00 7 Query SET autocommit=1
2021-08-30T00:42:57.627287+08:00 6 Query show variables where Variable_name in
('innodb_large_prefix','version','sql_mode','lower_case_table_names','wsrep_on',
'explicit_defaults_for_timestamp','enforce_gtid_consistency','gtid_mode')
2021-08-30T00:42:57.628055+08:00 6 Query show databases like 'sbtest'
2021-08-30T00:42:57.628396+08:00 6 Query USE `sbtest`
2021-08-30T00:42:57.628727+08:00 6 Query SHOW FULL FIELDS FROM `sbtest`.`t2`
2021-08-30T00:42:57.637130+08:00 6 Query SHOW INDEX FROM `sbtest`.`t2`
2021-08-30T00:42:57.637544+08:00 6 Query EXPLAIN delete from t2 where id ='2'
2021-08-30T00:42:57.637876+08:00 6 Query show variables like 'read_only'
2021-08-30T00:42:57.638399+08:00 6 Query show variables like 'log_bin'
2021-08-30T00:42:57.638932+08:00 6 Query show variables like 'binlog_format'
2021-08-30T00:42:57.639456+08:00 6 Query show variables like 'binlog_row_image'
2021-08-30T00:42:57.640024+08:00 6 Query use sbtest
2021-08-30T00:42:57.640184+08:00 6 Query select connection_id()
2021-08-30T00:42:57.640353+08:00 6 Query SHOW MASTER STATUS
2021-08-30T00:42:57.640612+08:00 6 Query delete from t2 where id ='2'
2021-08-30T00:42:57.640862+08:00 6 Query SHOW MASTER STATUS
2021-08-30T00:42:57.641080+08:00 7 Query create database if not exists inception
2021-08-30T00:42:57.641667+08:00 7 Query CREATE TABLE if not exists inception.statistic(id bigint auto_increment primary key, optime timestamp not null default current_timestamp, usedb int not null default 0, deleting int not null default 0, inserting int not null default 0, updating int not null default 0, selecting int not null default 0, altertable int not null default 0, renaming int not null default 0, createindex int not null default 0, dropindex int not null default 0, addcolumn int not null default 0, dropcolumn int not null default 0, changecolumn int not null default 0, alteroption int not null default 0, alterconvert int not null default 0, createtable int not null default 0, droptable int not null default 0, createdb int not null default 0, truncating int not null default 0 )ENGINE INNODB DEFAULT CHARSET UTF8
2021-08-30T00:42:57.644396+08:00 7 Prepare INSERT INTO inception.statistic ( usedb, deleting, inserting, updating,
selecting, altertable, renaming, createindex, dropindex, addcolumn,
dropcolumn, changecolumn, alteroption, alterconvert,
createtable, droptable, CREATEDB, truncating)
VALUES(?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?, ?, ?,
?, ?, ?)
2021-08-30T00:42:57.644440+08:00 7 Execute INSERT INTO inception.statistic ( usedb, deleting, inserting, updating,
selecting, altertable, renaming, createindex, dropindex, addcolumn,
dropcolumn, changecolumn, alteroption, alterconvert,
createtable, droptable, CREATEDB, truncating)
VALUES(1, 1, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 0, 0)
2021-08-30T00:42:57.645052+08:00 7 Close stmt
2021-08-30T00:42:57.645271+08:00 7 Query create database if not exists `10_4_45_58_33071_sbtest`
2021-08-30T00:42:57.645717+08:00 7 Query CREATE TABLE if not exists `10_4_45_58_33071_sbtest`.`t2`(id bigint auto_increment primary key, rollback_statement mediumtext, opid_time varchar(50)) ENGINE INNODB DEFAULT CHARSET UTF8MB4
2021-08-30T00:42:57.646525+08:00 7 Query CREATE TABLE `10_4_45_58_33071_sbtest`.`$_$Inception_backup_information$_$`(opid_time varchar(50),start_binlog_file varchar(512),start_binlog_pos int,end_binlog_file varchar(512),end_binlog_pos int,sql_statement mediumtext,host VARCHAR(64),dbname VARCHAR(64),tablename VARCHAR(64),port INT,time TIMESTAMP,type VARCHAR(20),PRIMARY KEY(opid_time))ENGINE INNODB DEFAULT CHARSET UTF8MB4
2021-08-30T00:42:57.647005+08:00 7 Query select DATA_TYPE from information_schema.columns
where table_schema='10_4_45_58_33071_sbtest' and table_name='$_$Inception_backup_information$_$' and column_name='sql_statement'
2021-08-30T00:42:57.647749+08:00 7 Prepare insert into `10_4_45_58_33071_sbtest`.`$_$Inception_backup_information$_$` values(?,?,?,?,?,?,?,?,?,?,NOW(),?)
2021-08-30T00:42:57.647805+08:00 7 Execute insert into `10_4_45_58_33071_sbtest`.`$_$Inception_backup_information$_$` values('1630255377_6_00000001','','0','','0','delete from t2 where id =\\\'2\\\'','10.4.45.58','sbtest','t2','33071',NOW(),'DELETE')
2021-08-30T00:42:57.648193+08:00 7 Close stmt
2021-08-30T00:42:57.648319+08:00 7 Quit
2021-08-30T00:42:57.648389+08:00 6 Quit
goInception在收到sql语句后,先会解析注释中的远程数据库配置,并建立连接;
只有在审核成功时(或有警告但启用了忽略),才会进入执行阶段
有些语法是不会执行的,其在审核阶段已经执行,比如desc table;语法
接下来继续说明执行阶段:
在执行阶段,DDL语句和DML语句走不同的逻辑,其中DML通过binlog解析实现回滚,而DDL语句根据语法树规则直接生成逆向SQL即可
执行中可能想要执行KILL以中止执行,可查看 KILL操作说明