├── _config.yml ├── tests ├── events │ ├── 15_format_desc │ │ ├── sql.sql │ │ ├── log.bin │ │ └── dump.txt │ ├── 16_xid │ │ ├── log.bin │ │ ├── sql.sql │ │ └── dump.txt │ ├── 02_query │ │ ├── log.bin │ │ ├── sql.sql │ │ └── dump.txt │ ├── 03_stop │ │ ├── log.bin │ │ ├── exec.sh │ │ └── dump.txt │ ├── 13_rand │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 04_rotate │ │ ├── log.bin │ │ ├── exec.sh │ │ └── dump.txt │ ├── 05_intvar │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 14_user_var │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 17_18_load │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 19_table_map │ │ ├── log.bin │ │ ├── sql.sql │ │ └── dump.txt │ ├── 29_row_query │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 30_write_rows_v2 │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ ├── 31_update_rows_v2 │ │ ├── log.bin │ │ ├── sql.sql │ │ └── dump.txt │ ├── 32_delete_rows_v2 │ │ ├── README.md │ │ ├── log.bin │ │ └── sql.sql │ ├── 34_anonymous_gtid │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt │ └── 33_35_gtid_prev_gtid │ │ ├── log.bin │ │ ├── README.md │ │ ├── sql.sql │ │ └── dump.txt ├── scripts │ ├── README.md │ ├── lib.sh │ └── exec.sh ├── data │ └── handshake_v10.bin └── mysql │ ├── conf │ └── myconf.cnf │ └── docker-compose.yml ├── .gitignore ├── Cargo.toml ├── .github └── workflows │ └── rust.yml ├── crates ├── core │ ├── src │ │ ├── lib.rs │ │ ├── connector │ │ │ ├── auth.rs │ │ │ ├── handshake_resp.rs │ │ │ └── handshake_v10.rs │ │ ├── bin │ │ │ └── conn.rs │ │ ├── codec.rs │ │ ├── binlog.rs │ │ └── connector.rs │ └── Cargo.toml └── old │ ├── src │ ├── lib.rs │ ├── events │ │ ├── rows.rs │ │ └── query.rs │ ├── connection.rs │ ├── utils.rs │ └── cli.rs │ └── Cargo.toml ├── README.md └── LICENSE /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-merlot -------------------------------------------------------------------------------- /tests/events/15_format_desc/sql.sql: -------------------------------------------------------------------------------- 1 | reset master; 2 | flush logs; -------------------------------------------------------------------------------- /tests/scripts/README.md: -------------------------------------------------------------------------------- 1 | scripts under this dir are used to generate events. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | **/*.rs.bk 3 | /.vscode 4 | Cargo.lock 5 | 6 | src/*.bin -------------------------------------------------------------------------------- /tests/events/16_xid/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/16_xid/log.bin -------------------------------------------------------------------------------- /tests/data/handshake_v10.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/data/handshake_v10.bin -------------------------------------------------------------------------------- /tests/events/02_query/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/02_query/log.bin -------------------------------------------------------------------------------- /tests/events/03_stop/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/03_stop/log.bin -------------------------------------------------------------------------------- /tests/events/13_rand/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/13_rand/log.bin -------------------------------------------------------------------------------- /tests/events/04_rotate/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/04_rotate/log.bin -------------------------------------------------------------------------------- /tests/events/05_intvar/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/05_intvar/log.bin -------------------------------------------------------------------------------- /tests/events/14_user_var/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/14_user_var/log.bin -------------------------------------------------------------------------------- /tests/events/17_18_load/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/17_18_load/log.bin -------------------------------------------------------------------------------- /tests/events/19_table_map/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/19_table_map/log.bin -------------------------------------------------------------------------------- /tests/events/29_row_query/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/29_row_query/log.bin -------------------------------------------------------------------------------- /tests/events/15_format_desc/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/15_format_desc/log.bin -------------------------------------------------------------------------------- /tests/events/30_write_rows_v2/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/30_write_rows_v2/log.bin -------------------------------------------------------------------------------- /tests/events/05_intvar/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=statement 8 | ``` 9 | -------------------------------------------------------------------------------- /tests/events/13_rand/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=statement 8 | ``` 9 | -------------------------------------------------------------------------------- /tests/events/14_user_var/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=statement 8 | ``` 9 | -------------------------------------------------------------------------------- /tests/events/30_write_rows_v2/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=row 8 | ``` 9 | -------------------------------------------------------------------------------- /tests/events/31_update_rows_v2/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/31_update_rows_v2/log.bin -------------------------------------------------------------------------------- /tests/events/32_delete_rows_v2/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=row 8 | ``` 9 | -------------------------------------------------------------------------------- /tests/events/32_delete_rows_v2/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/32_delete_rows_v2/log.bin -------------------------------------------------------------------------------- /tests/events/34_anonymous_gtid/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/34_anonymous_gtid/log.bin -------------------------------------------------------------------------------- /tests/events/33_35_gtid_prev_gtid/log.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PrivateRookie/boxercrab/HEAD/tests/events/33_35_gtid_prev_gtid/log.bin -------------------------------------------------------------------------------- /tests/events/17_18_load/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=statement 8 | secure_file_priv='/tmp' 9 | ``` -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [workspace] 2 | members = ["crates/*"] 3 | 4 | [workspace.dependencies] 5 | bytes = { version = "1" } 6 | serde = { workspace = "1", features = ["derive"] } -------------------------------------------------------------------------------- /tests/events/29_row_query/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | binlog_format=row 8 | binlog_rows_query_log_events=true 9 | ``` 10 | -------------------------------------------------------------------------------- /tests/events/34_anonymous_gtid/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | gtid-mode = OFF 8 | enforce-gtid-consistency = 0 9 | binlog_format=row 10 | ``` 11 | -------------------------------------------------------------------------------- /tests/events/33_35_gtid_prev_gtid/README.md: -------------------------------------------------------------------------------- 1 | **NOTE** 2 | 3 | Required config 4 | 5 | ```conf 6 | [mysqld] 7 | gtid-mode = ON 8 | enforce-gtid-consistency = 1 9 | binlog_format=row 10 | ``` 11 | -------------------------------------------------------------------------------- /tests/events/04_rotate/exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source tests/scripts/lib.sh 4 | 5 | mysql_exec "echo reset master" 6 | mysql_exec "echo flush logs" 7 | dump_binlog ${PREFIX}/04_rotate/dump.txt 8 | cp_binlog ${PREFIX}/04_rotate/log.bin 9 | 10 | -------------------------------------------------------------------------------- /tests/events/05_intvar/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | i INT AUTO_INCREMENT PRIMARY KEY, 5 | c VARCHAR(10) 6 | ); 7 | 8 | INSERT INTO `boxercrab` (i, c) VALUES(LAST_INSERT_ID()+1, 'abc'); 9 | 10 | flush logs; 11 | -------------------------------------------------------------------------------- /tests/events/13_rand/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | i INT AUTO_INCREMENT PRIMARY KEY, 5 | c VARCHAR(10) 6 | ); 7 | 8 | INSERT INTO `boxercrab` (i, c) VALUES(FLOOR(RAND() * 100), 'abc'); 9 | 10 | flush logs; 11 | -------------------------------------------------------------------------------- /tests/events/03_stop/exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source tests/scripts/lib.sh 4 | 5 | mysql_exec "echo reset master" 6 | docker container restart mysql_db_1 7 | sleep 5 8 | mysql_exec "echo flush logs" 9 | dump_binlog ${PREFIX}/03_stop/dump.txt 10 | cp_binlog ${PREFIX}/03_stop/log.bin 11 | 12 | -------------------------------------------------------------------------------- /tests/events/30_write_rows_v2/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('abcde'); 10 | -------------------------------------------------------------------------------- /tests/events/19_table_map/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('hahhhhhhhhh'); 10 | -------------------------------------------------------------------------------- /tests/events/29_row_query/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('hahhhhhhhhh'); 10 | -------------------------------------------------------------------------------- /tests/events/33_35_gtid_prev_gtid/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('abcde'); 10 | -------------------------------------------------------------------------------- /tests/events/34_anonymous_gtid/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('abcde'); 10 | -------------------------------------------------------------------------------- /tests/events/16_xid/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | BEGIN; 10 | INSERT INTO `boxercrab` (`title`) VALUES ('hahhhhhhhhh'); 11 | COMMIT; -------------------------------------------------------------------------------- /tests/events/32_delete_rows_v2/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(40) NOT NULL, 6 | PRIMARY KEY (`id`) 7 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 8 | 9 | INSERT INTO `boxercrab` (`title`) VALUES ('abcde'); 10 | DELETE FROM `boxercrab`; 11 | -------------------------------------------------------------------------------- /tests/events/02_query/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `title` VARCHAR(100) NOT NULL, 6 | `author` VARCHAR(40) NOT NULL, 7 | `time` DATETIME NOT NULL, 8 | `score` INT DEFAULT 0, 9 | PRIMARY KEY (`id`) 10 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 11 | -------------------------------------------------------------------------------- /tests/mysql/conf/myconf.cnf: -------------------------------------------------------------------------------- 1 | 2 | [mysql.server] 3 | character-set = utf8mb4 4 | collation = utf8mb4_unicode_ci 5 | 6 | [mysqld] 7 | gtid-mode = ON 8 | enforce-gtid-consistency = 1 9 | server-id = 1 10 | character-set-server = utf8mb4 11 | log-bin = mysql_bin 12 | binlog-do-db = default 13 | secure_file_priv='/tmp' 14 | binlog_format=row 15 | binlog_rows_query_log_events=true -------------------------------------------------------------------------------- /.github/workflows/rust.yml: -------------------------------------------------------------------------------- 1 | name: Rust 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | CARGO_TERM_COLOR: always 11 | 12 | jobs: 13 | build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Build 20 | run: cargo build 21 | - name: Run tests 22 | run: cargo test 23 | -------------------------------------------------------------------------------- /crates/core/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub mod codec; 2 | pub mod connector; 3 | pub mod binlog; 4 | 5 | #[allow(unused_macros)] 6 | macro_rules! hex { 7 | ($data:literal) => {{ 8 | let buf = bytes::BytesMut::from_iter( 9 | (0..$data.len()) 10 | .step_by(2) 11 | .map(|i| u8::from_str_radix(&$data[i..i + 2], 16).unwrap()), 12 | ); 13 | buf 14 | }}; 15 | } 16 | -------------------------------------------------------------------------------- /tests/mysql/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | db: 4 | image: mysql:5.7.30 5 | ports: 6 | - 0.0.0.0:3306:3306 7 | volumes: 8 | - mysql-db:/var/lib/mysql 9 | - ./conf:/etc/mysql/conf.d 10 | restart: always 11 | environment: 12 | - MYSQL_ROOT_PASSWORD=1234TttT 13 | - MYSQL_USER=rookie 14 | - MYSQL_PASSWORD=1234TttT 15 | - MYSQL_DATABASE=default 16 | 17 | volumes: 18 | mysql-db: -------------------------------------------------------------------------------- /tests/scripts/lib.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | export PREFIX="$(git rev-parse --show-toplevel)/tests/events" 5 | 6 | function mysql_exec() { 7 | $1 | mysql -u root -p1234TttT -h 127.0.0.1 default 8 | } 9 | 10 | function dump_binlog() { 11 | docker container exec -it mysql_db_1 mysqlbinlog -H -vvvvvv /var/lib/mysql/mysql_bin.000001 > $1 12 | } 13 | 14 | function cp_binlog () { 15 | docker container cp mysql_db_1:/var/lib/mysql/mysql_bin.000001 $1 16 | } 17 | -------------------------------------------------------------------------------- /tests/events/14_user_var/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `str` VARCHAR(40) NOT NULL, 6 | `int` INT NOT NULL, 7 | `dec` DECIMAL(10, 4) NOT NULL, 8 | PRIMARY KEY (`id`) 9 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 10 | 11 | SET @val_s := "test blog"; 12 | SET @val_i := 100; 13 | SET @val_d := 1.00; 14 | 15 | INSERT INTO `boxercrab` (`str`, `int`, `dec`) VALUES (@val_s, @val_i, @val_d); 16 | -------------------------------------------------------------------------------- /crates/old/src/lib.rs: -------------------------------------------------------------------------------- 1 | #![allow(non_camel_case_types)] 2 | 3 | mod connection; 4 | mod events; 5 | mod mysql; 6 | mod utils; 7 | 8 | pub use connection::Connection; 9 | pub use events::{ 10 | query::{QueryStatusVar, Q_FLAGS2_CODE_VAL, Q_SQL_MODE_CODE_VAL}, 11 | rows::{ExtraData, ExtraDataFormat, Flags, Payload, Row}, 12 | DupHandlingFlags, EmptyFlags, Event, EventFlag, Header, IncidentEventType, IntVarEventType, 13 | OptFlags, UserVarType, 14 | }; 15 | pub use mysql::{ColTypes, ColValues}; 16 | -------------------------------------------------------------------------------- /crates/core/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "boxercrab" 3 | version = "0.3.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [features] 9 | default = [] 10 | serde = ["dep:serde"] 11 | 12 | [dependencies] 13 | bytes = { workspace = true } 14 | serde = { workspace = true, optional = true } 15 | parse-tool = { git = "https://github.com/PrivateRookie/parse-tool" } 16 | thiserror = "1" 17 | bitflags = "2" 18 | sha1 = "0.10.5" 19 | -------------------------------------------------------------------------------- /tests/events/17_18_load/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | i INT AUTO_INCREMENT PRIMARY KEY, 5 | c VARCHAR(10) 6 | ); 7 | 8 | INSERT INTO `boxercrab` (i, c) VALUES(1, 'abc'); 9 | 10 | SELECT * FROM `boxercrab` INTO OUTFILE '/tmp/data.txt' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'; 11 | 12 | DROP TABLE IF EXISTS `boxercrab`; 13 | 14 | CREATE TABLE `boxercrab` ( 15 | i INT AUTO_INCREMENT PRIMARY KEY, 16 | c VARCHAR(10) 17 | ); 18 | 19 | RESET MASTER; 20 | LOAD DATA INFILE '/tmp/data.txt' INTO TABLE `boxercrab`FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' LINES TERMINATED BY '\n'; 21 | 22 | flush logs; 23 | -------------------------------------------------------------------------------- /crates/old/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | authors = ["PrivateRookie <996514515@qq.com>"] 3 | edition = "2021" 4 | name = "boxercrab-old" 5 | version = "0.2.0" 6 | 7 | [dependencies] 8 | log = "0.4.11" 9 | log4rs = "1.0.0-alpha-1" 10 | nom = "5" 11 | serde = { version = "1.0.115", features = ["derive"] } 12 | serde_json = "1.0.57" 13 | serde_yaml = "0.8.13" 14 | structopt = "0.3.16" 15 | tokio = { version = "0.2.22", features = ["full"] } 16 | # sqlx = { version = "0.4.0-beta.1", default-features = false, features = ["runtime-tokio", "mysql", "json", "macros", "time", "decimal"] } 17 | sqlx = { git = "https://github.com/PrivateRookie/sqlx.git", branch = "boxercrab", default-features = false, features = ["runtime-tokio", "mysql", "json", "macros", "time", "decimal"] } 18 | lazy_static = "1.4.0" 19 | pretty_env_logger = "0.4.0" 20 | bytes = "0.5.6" 21 | 22 | # [[bin]] 23 | # name = "bcrab" 24 | # path = "src/cli.rs" 25 | -------------------------------------------------------------------------------- /tests/events/31_update_rows_v2/sql.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `boxercrab`; 2 | 3 | CREATE TABLE `boxercrab` ( 4 | `id` INT UNSIGNED AUTO_INCREMENT, 5 | `varchar_l` VARCHAR(100) NOT NULL, 6 | `varchar_s` VARCHAR(40) NOT NULL, 7 | `text_s` TEXT NOT NULL, 8 | `text_m` MEDIUMTEXT NOT NULL, 9 | `text_l` LONGTEXT NOT NULL, 10 | `num_float` FLOAT NOT NULL, 11 | `num_double` DOUBLE NOT NULL, 12 | `num_decimal` DECIMAL(10, 4), 13 | PRIMARY KEY (`id`) 14 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 15 | 16 | INSERT INTO `boxercrab` (`varchar_l`, `varchar_s`, `text_s`, `text_m`, `text_l`, `num_float`, `num_double`, `num_decimal`) VALUES ('abc', 'abc', 'abc', 'abc', 'abc', 1.0, 2.0, 3.0); 17 | 18 | reset master; 19 | 20 | UPDATE boxercrab set varchar_l='xd', varchar_s='xd', text_s='xd', text_m='xd', text_l='xd', num_float=4.0, num_double=4.0, num_decimal=4.0; 21 | 22 | flush logs; 23 | -------------------------------------------------------------------------------- /tests/scripts/exec.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | source tests/scripts/lib.sh 5 | 6 | if test -z "$1"; 7 | then 8 | echo "target dir is required!" 9 | exit 1 10 | else 11 | target_dir=${PREFIX}/${1} 12 | if [ -f ${target_dir}/exec.sh ] 13 | then 14 | echo ========================================== 15 | echo 16 | echo "running ${target_dir}/exec.sh" 17 | echo 18 | echo ========================================== 19 | source ${target_dir}/exec.sh 20 | else 21 | echo ========================================== 22 | echo 23 | echo "running ${target_dir}/sql.sql" 24 | echo 25 | echo ========================================== 26 | mysql_exec "echo reset master" 2> /dev/null 27 | mysql_exec "cat ${target_dir}/sql.sql" 28 | mysql_exec "echo flush logs" 2> /dev/null 29 | dump_binlog ${target_dir}/dump.txt 30 | cp_binlog ${target_dir}/log.bin 31 | fi 32 | fi -------------------------------------------------------------------------------- /crates/core/src/connector/auth.rs: -------------------------------------------------------------------------------- 1 | use bytes::BytesMut; 2 | use parse_tool::InputBuf; 3 | 4 | use crate::codec::{get_null_term_str, Decode, DecodeError, Encode}; 5 | 6 | use super::{decode_header, Packet}; 7 | 8 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_request.html) 9 | #[derive(Debug, Clone)] 10 | pub struct AuthSwitchReq { 11 | pub plugin_name: String, 12 | pub plugin_data: BytesMut, 13 | } 14 | 15 | impl AuthSwitchReq { 16 | pub const STATUS: u8 = 254; 17 | } 18 | 19 | impl Decode for AuthSwitchReq { 20 | fn decode(input: &mut I) -> Result { 21 | let tag = input.read_u8_le()?; 22 | if tag != 0xfe { 23 | return Err(DecodeError::InvalidData); 24 | } 25 | let plugin_name = get_null_term_str(input)?; 26 | let plugin_data = if input.left() > 0 { 27 | BytesMut::from_iter(input.read_vec(input.left() - 1)?) 28 | } else { 29 | BytesMut::new() 30 | }; 31 | Ok(AuthSwitchReq { 32 | plugin_name, 33 | plugin_data, 34 | }) 35 | } 36 | } 37 | 38 | /// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_auth_switch_response.html 39 | #[derive(Debug, Clone)] 40 | pub struct AuthSwitchResp { 41 | pub data: BytesMut, 42 | } 43 | 44 | impl Decode for Packet { 45 | fn decode(input: &mut I) -> Result { 46 | let (len, seq_id) = decode_header(input)?; 47 | let data = input.read_vec(len.int() as usize)?; 48 | let data = BytesMut::from_iter(data); 49 | Ok(Packet { 50 | len, 51 | seq_id, 52 | payload: AuthSwitchResp { data }, 53 | }) 54 | } 55 | } 56 | 57 | impl Encode for AuthSwitchResp { 58 | fn encode(&self, buf: &mut BytesMut) { 59 | buf.extend_from_slice(&self.data); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /tests/events/03_stop/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200710 15:36:01 server id 1 end_log_pos 123 CRC32 0x3d434a6f 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 e1 8a 08 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 e1 8a 08 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 6f 4a 43 3d |oJC.| 15 | # Start: binlog v 4, server v 5.7.30-log created 200710 15:36:01 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | 4YoIXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADhighfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AW9KQz0= 21 | '/*!*/; 22 | # at 123 23 | #200710 15:36:01 server id 1 end_log_pos 154 CRC32 0x1a82fe05 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b e1 8a 08 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 05 fe 82 1a |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200710 15:36:01 server id 1 end_log_pos 177 CRC32 0x78ac19db 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a e1 8a 08 5f 03 01 00 00 00 17 00 00 00 b1 00 00 00 00 00 33 | # ad db 19 ac 78 |...x| 34 | # Stop 35 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 36 | DELIMITER ; 37 | # End of log file 38 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 39 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 40 | -------------------------------------------------------------------------------- /tests/events/04_rotate/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200710 15:38:53 server id 1 end_log_pos 123 CRC32 0x5b747b95 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 8d 8b 08 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 8d 8b 08 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 95 7b 74 5b |..t.| 15 | # Start: binlog v 4, server v 5.7.30-log created 200710 15:38:53 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | jYsIXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAACNiwhfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AZV7dFs= 21 | '/*!*/; 22 | # at 123 23 | #200710 15:38:53 server id 1 end_log_pos 154 CRC32 0x401618e2 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 8d 8b 08 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 e2 18 16 40 |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200710 15:38:53 server id 1 end_log_pos 201 CRC32 0xe46bad5a 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 8d 8b 08 5f 04 01 00 00 00 2f 00 00 00 c9 00 00 00 00 00 33 | # ad 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 34 | # bd 6e 2e 30 30 30 30 30 32 5a ad 6b e4 |n.000002Z.k.| 35 | # Rotate to mysql_bin.000002 pos: 4 36 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 37 | DELIMITER ; 38 | # End of log file 39 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 40 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 41 | -------------------------------------------------------------------------------- /tests/events/15_format_desc/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 6:07:14 server id 1 end_log_pos 123 CRC32 0x5b1860c0 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 12 b5 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 12 b5 23 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 c0 60 18 5b |....| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 6:07:14 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | ErUjXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAAStSNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AcBgGFs= 21 | '/*!*/; 22 | # at 123 23 | #200731 6:07:14 server id 1 end_log_pos 154 CRC32 0x76bb032c 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 12 b5 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 2c 03 bb 76 |...........v| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 6:07:14 server id 1 end_log_pos 201 CRC32 0x728dacdd 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 12 b5 23 5f 04 01 00 00 00 2f 00 00 00 c9 00 00 00 00 00 33 | # ad 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 34 | # bd 6e 2e 30 30 30 30 30 32 dd ac 8d 72 |n.000002...r| 35 | # Rotate to mysql_bin.000002 pos: 4 36 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 37 | DELIMITER ; 38 | # End of log file 39 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 40 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 41 | -------------------------------------------------------------------------------- /crates/old/src/events/rows.rs: -------------------------------------------------------------------------------- 1 | use crate::utils::extract_string; 2 | use nom::{bytes::complete::take, combinator::map, number::complete::le_u8, IResult}; 3 | use serde::Serialize; 4 | 5 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 6 | pub struct Flags { 7 | pub end_of_stmt: bool, 8 | pub foreign_key_checks: bool, 9 | pub unique_key_checks: bool, 10 | pub has_columns: bool, 11 | } 12 | 13 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 14 | pub struct ExtraData { 15 | pub d_type: ExtraDataType, 16 | pub data: Payload, 17 | } 18 | 19 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 20 | pub enum ExtraDataType { 21 | RW_V_EXTRAINFO_TAG = 0x00, 22 | } 23 | 24 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 25 | pub enum Payload { 26 | ExtraDataInfo { 27 | length: u8, 28 | format: ExtraDataFormat, 29 | payload: String, 30 | }, 31 | } 32 | 33 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 34 | #[repr(u8)] 35 | pub enum ExtraDataFormat { 36 | NDB = 0x00, 37 | OPEN1 = 0x40, 38 | OPEN2 = 0x41, 39 | MULTI = 0xff, 40 | } 41 | 42 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 43 | pub struct Row { 44 | pub null_bit_mask: Vec, 45 | pub values: Vec, 46 | } 47 | 48 | pub fn parse_extra_data<'a>(input: &'a [u8]) -> IResult<&'a [u8], ExtraData> { 49 | let (i, d_type) = map(le_u8, |t: u8| match t { 50 | 0x00 => ExtraDataType::RW_V_EXTRAINFO_TAG, 51 | _ => { 52 | log::error!("unknown extra data type {}", t); 53 | unreachable!() 54 | } 55 | })(input)?; 56 | let (i, length) = le_u8(i)?; 57 | let (i, extra_data_format) = map(le_u8, |fmt: u8| match fmt { 58 | 0x00 => ExtraDataFormat::NDB, 59 | 0x40 => ExtraDataFormat::OPEN1, 60 | 0x41 => ExtraDataFormat::OPEN2, 61 | 0xff => ExtraDataFormat::MULTI, 62 | _ => { 63 | log::error!("unknown extract data format {}", fmt); 64 | unreachable!() 65 | } 66 | })(i)?; 67 | let (i, payload) = map(take(length), |s: &[u8]| extract_string(s))(i)?; 68 | Ok(( 69 | i, 70 | ExtraData { 71 | d_type, 72 | data: Payload::ExtraDataInfo { 73 | length, 74 | format: extra_data_format, 75 | payload, 76 | }, 77 | }, 78 | )) 79 | } 80 | -------------------------------------------------------------------------------- /crates/old/src/connection.rs: -------------------------------------------------------------------------------- 1 | use bytes::{BufMut, Bytes, BytesMut}; 2 | use sqlx::mysql::MySqlPoolOptions; 3 | use sqlx::Connection as SQLConnection; 4 | use sqlx::MySqlConnection; 5 | use std::error::Error; 6 | 7 | #[derive(Debug)] 8 | pub struct Connection { 9 | conn: Option, 10 | has_requested: bool, 11 | binlog_file: String, 12 | pub url: String, 13 | pub id: u32, 14 | } 15 | 16 | impl Connection { 17 | pub fn new(url: String, id: u32) -> Self { 18 | Connection { 19 | conn: None, 20 | has_requested: false, 21 | binlog_file: String::new(), 22 | url, 23 | id, 24 | } 25 | } 26 | 27 | pub async fn connect(&mut self) -> Result<(), Box> { 28 | let mut conn = MySqlConnection::connect(&self.url).await?; 29 | conn.ping().await?; 30 | 31 | // send a query to tell master we can handle checksum 32 | let mut enable_checksum = BytesMut::with_capacity(100); 33 | enable_checksum.put_u8(0x03); 34 | enable_checksum.put(&b"set @master_binlog_checksum= @@global.binlog_checksum"[..]); 35 | conn.stream.send_packet(enable_checksum.as_ref()).await?; 36 | 37 | self.conn = Some(conn); 38 | Ok(()) 39 | } 40 | 41 | pub async fn recv(&mut self) -> Result> { 42 | if self.conn.is_none() { 43 | self.connect().await?; 44 | } 45 | 46 | if !self.has_requested { 47 | // query server current position 48 | let pool = MySqlPoolOptions::new().connect(&self.url).await?; 49 | let (binlog_file, position, ..): (String, u32, String, String, String) = 50 | sqlx::query_as("show master status") 51 | .fetch_one(&pool) 52 | .await?; 53 | 54 | // send COM_BINLOG_DUMP command 55 | let mut com_bindump = BytesMut::new(); 56 | // COM identifier 57 | com_bindump.put_u8(0x12); 58 | // binlog position 59 | com_bindump.put_u32_le(position); 60 | // command flags, always be blocking here 61 | com_bindump.put_u16_le(0); 62 | // client id 63 | com_bindump.put_u32_le(self.id); 64 | // binlog file name 65 | com_bindump.put(binlog_file.as_bytes()); 66 | println!("{:x?}", com_bindump.as_ref()); 67 | 68 | self.conn 69 | .as_mut() 70 | .unwrap() 71 | .stream 72 | .send_packet(com_bindump.as_ref()) 73 | .await?; 74 | 75 | self.has_requested = true; 76 | } 77 | 78 | let bytes = self.conn.as_mut().unwrap().stream.recv_packet().await?; 79 | Ok(bytes.0) 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /crates/old/src/utils.rs: -------------------------------------------------------------------------------- 1 | #![allow(dead_code)] 2 | 3 | use nom::{ 4 | bytes::complete::{take, take_till}, 5 | combinator::map, 6 | number::complete::{le_u16, le_u32, le_u64, le_u8}, 7 | IResult, 8 | }; 9 | 10 | /// parse fixed len int 11 | /// 12 | /// ref: https://dev.mysql.com/doc/internals/en/integer.html#fixed-length-integer 13 | pub fn int_fixed<'a>(input: &'a [u8], len: u8) -> IResult<&'a [u8], u64> { 14 | match len { 15 | 1 => map(le_u8, |v| v as u64)(input), 16 | 2 => map(le_u16, |v| v as u64)(input), 17 | 3 | 6 => map(take(3usize), |s: &[u8]| { 18 | let mut filled = s.to_vec(); 19 | if len == 3 { 20 | filled.extend(vec![0, 0, 0, 0, 0]); 21 | } else { 22 | filled.extend(vec![0, 0]); 23 | } 24 | pu64(&filled).unwrap().1 25 | })(input), 26 | 4 => map(le_u32, |v| v as u64)(input), 27 | 8 => le_u64(input), 28 | _ => unreachable!(), 29 | } 30 | } 31 | 32 | /// parse len encoded int, return (used_bytes, value). 33 | /// 34 | /// ref: https://dev.mysql.com/doc/internals/en/integer.html#packet-Protocol::LengthEncodedInteger 35 | pub fn int_lenenc<'a>(input: &'a [u8]) -> IResult<&'a [u8], (usize, u64)> { 36 | match input[0] { 37 | 0..=0xfa => map(le_u8, |num: u8| (1, num as u64))(input), 38 | 0xfb | 0xfc => { 39 | let (i, _) = take(1usize)(input)?; 40 | map(le_u16, |num: u16| (3, num as u64))(i) 41 | } 42 | 0xfd => { 43 | let (i, _) = take(1usize)(input)?; 44 | let (i, v) = map(take(3usize), |s: &[u8]| { 45 | let mut raw = s.to_vec(); 46 | raw.push(0); 47 | raw 48 | })(i)?; 49 | let (_, num) = pu32(&v).unwrap(); 50 | Ok((i, (4, num as u64))) 51 | } 52 | 0xfe => { 53 | let (i, _) = take(1usize)(input)?; 54 | map(le_u64, |v: u64| (9, v))(i) 55 | } 56 | 0xff => unreachable!(), 57 | } 58 | } 59 | 60 | /// parse length encoded string 61 | /// 62 | /// ref: https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::LengthEncodedString 63 | pub fn string_lenenc<'a>(input: &'a [u8]) -> IResult<&'a [u8], String> { 64 | let (i, (_, str_len)) = int_lenenc(input)?; 65 | map(take(str_len), |s: &[u8]| { 66 | String::from_utf8_lossy(s).to_string() 67 | })(i) 68 | } 69 | 70 | /// parse null terminated string, consume null byte 71 | /// 72 | /// ref: https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::NulTerminatedString 73 | pub fn string_nul(input: &[u8]) -> IResult<&[u8], String> { 74 | let (i, ret) = map(take_till(|c: u8| c == 0x00), |s| { 75 | String::from_utf8_lossy(s).to_string() 76 | })(input)?; 77 | let (i, _) = take(1usize)(i)?; 78 | Ok((i, ret)) 79 | } 80 | 81 | /// extract n(n <= len(input)) bytes string 82 | pub fn extract_string(input: &[u8]) -> String { 83 | let null_end = input 84 | .iter() 85 | .position(|&c| c == b'\0') 86 | .unwrap_or(input.len()); 87 | String::from_utf8_lossy(&input[0..null_end]).to_string() 88 | } 89 | 90 | /// extract len bytes string 91 | /// 92 | /// ref: https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::VariableLengthString 93 | pub fn string_var(input: &[u8], len: usize) -> String { 94 | if input.len() <= len { 95 | String::from_utf8_lossy(&input).to_string() 96 | } else { 97 | String::from_utf8_lossy(&input[0..len]).to_string() 98 | } 99 | } 100 | 101 | /// parse fixed len string. 102 | /// 103 | /// ref: https://dev.mysql.com/doc/internals/en/string.html#packet-Protocol::FixedLengthString 104 | pub fn string_fixed(input: &[u8]) -> IResult<&[u8], (u8, String)> { 105 | let (i, len) = le_u8(input)?; 106 | map(take(len), move |s: &[u8]| { 107 | (len, String::from_utf8_lossy(s).to_string()) 108 | })(i) 109 | } 110 | 111 | pub fn pu32(input: &[u8]) -> IResult<&[u8], u32> { 112 | le_u32(input) 113 | } 114 | 115 | pub fn pu64(input: &[u8]) -> IResult<&[u8], u64> { 116 | le_u64(input) 117 | } 118 | -------------------------------------------------------------------------------- /crates/core/src/connector/handshake_resp.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | use bytes::BytesMut; 4 | use parse_tool::InputBuf; 5 | 6 | use crate::codec::{ 7 | get_null_term_str, get_var_bytes, get_var_str, put_null_term_str, put_var_bytes, put_var_str, 8 | Decode, DecodeError, Encode, Int1, Int4, VLenInt, 9 | }; 10 | 11 | use super::Capabilities; 12 | 13 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_response.html#sect_protocol_connection_phase_packets_protocol_handshake_response41) 14 | #[derive(Debug, Clone)] 15 | pub struct HandshakeResponse41 { 16 | pub caps: Capabilities, 17 | pub max_packet_size: Int4, 18 | pub charset: Int1, 19 | pub user_name: String, 20 | pub auth_resp: BytesMut, 21 | pub database: Option, 22 | pub plugin_name: Option, 23 | pub connect_attrs: HashMap, 24 | pub zstd_level: Int1, 25 | } 26 | 27 | impl Decode for HandshakeResponse41 { 28 | fn decode(input: &mut I) -> Result { 29 | let caps = Int4::decode(input)?; 30 | let caps = Capabilities::from_bits(caps.int()).unwrap(); 31 | let max_packet_size = Int4::decode(input)?; 32 | let charset = Int1::decode(input)?; 33 | input.read_vec(23)?; 34 | let user_name = get_null_term_str(input)?; 35 | let auth_resp = if caps.contains(Capabilities::CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA) { 36 | get_var_bytes(input)? 37 | } else { 38 | let len = Int1::decode(input)?.int() as usize; 39 | input.read_vec(len)? 40 | }; 41 | let auth_resp = BytesMut::from_iter(auth_resp); 42 | let database = if caps.contains(Capabilities::CLIENT_CONNECT_WITH_DB) { 43 | Some(get_null_term_str(input)?) 44 | } else { 45 | None 46 | }; 47 | let plugin_name = if caps.contains(Capabilities::CLIENT_PLUGIN_AUTH) { 48 | Some(get_null_term_str(input)?) 49 | } else { 50 | None 51 | }; 52 | let mut connect_attrs: HashMap = Default::default(); 53 | if caps.contains(Capabilities::CLIENT_CONNECT_ATTRS) { 54 | let count = Int1::decode(input)?.int(); 55 | for _ in 0..count { 56 | let key = get_var_str(input)?; 57 | let val = get_var_str(input)?; 58 | connect_attrs.insert(key, val); 59 | } 60 | } 61 | let zstd_level = Int1::decode(input)?; 62 | Ok(Self { 63 | caps, 64 | max_packet_size, 65 | charset, 66 | user_name, 67 | auth_resp, 68 | database, 69 | plugin_name, 70 | connect_attrs, 71 | zstd_level, 72 | }) 73 | } 74 | } 75 | 76 | impl Encode for HandshakeResponse41 { 77 | fn encode(&self, buf: &mut BytesMut) { 78 | Int4::from(self.caps.bits()).encode(buf); 79 | self.max_packet_size.encode(buf); 80 | self.charset.encode(buf); 81 | buf.extend_from_slice(&vec![0].repeat(23)); 82 | put_null_term_str(&self.user_name, buf); 83 | if self 84 | .caps 85 | .contains(Capabilities::CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA) 86 | { 87 | put_var_bytes(&self.auth_resp, buf) 88 | } else { 89 | let len = Int1::from(self.auth_resp.len() as u8); 90 | len.encode(buf); 91 | buf.extend_from_slice(&self.auth_resp); 92 | } 93 | if self.caps.contains(Capabilities::CLIENT_CONNECT_WITH_DB) { 94 | put_null_term_str(self.database.as_deref().unwrap_or("default"), buf); 95 | } 96 | if self.caps.contains(Capabilities::CLIENT_PLUGIN_AUTH) { 97 | put_null_term_str(self.plugin_name.as_deref().unwrap_or_default(), buf); 98 | } 99 | if self.caps.contains(Capabilities::CLIENT_CONNECT_ATTRS) { 100 | let len = VLenInt::new(self.connect_attrs.len() as u64); 101 | len.encode(buf); 102 | for (k, v) in self.connect_attrs.iter() { 103 | put_var_str(k, buf); 104 | put_var_str(v, buf); 105 | } 106 | } 107 | self.zstd_level.encode(buf); 108 | } 109 | } 110 | #[allow(unused_macros)] 111 | macro_rules! hex { 112 | ($data:literal) => {{ 113 | let buf = bytes::BytesMut::from_iter( 114 | (0..$data.len()) 115 | .step_by(2) 116 | .map(|i| u8::from_str_radix(&$data[i..i + 2], 16).unwrap()), 117 | ); 118 | buf 119 | }}; 120 | } 121 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # boxercrab 2 | MySQL binlog parser impl with Rust 3 | 4 | ![Rust](https://github.com/PrivateRookie/boxercrab/workflows/Rust/badge.svg) 5 | [![BoxerCrab](https://tokei.rs/b1/github/PrivateRookie/boxercrab?category=code)](https://github.com/PrivateRookie/boxercrab) 6 | ![Code Coverage](https://github.com/PrivateRookie/boxercrab/workflows/Code%20Coverage/badge.svg) 7 | 8 | Boxercrab tried to parse every field in binlog, but for the reasons of documentation, ability, etc., some fields could not be parsed yet. 9 | 10 | Parsed events matrix: 11 | 12 | | Hex | Event Name | Parsed | Note | 13 | | ---- | ------------------------ | ------ | ------------------ | 14 | | 0x01 | START_EVENT_V3 | N | too old to support | 15 | | 0x02 | QUERY_EVENT | Y | | 16 | | 0x03 | STOP_EVENT | Y | | 17 | | 0x04 | ROTATE_EVENT | Y | | 18 | | 0x05 | INTVAR_EVENT | Y | | 19 | | 0x06 | LOAD_EVENT | Y | not tested | 20 | | 0x07 | SLAVE_EVENT | Y | not tested | 21 | | 0x08 | CREATE_FILE_EVENT | Y | not tested | 22 | | 0x09 | APPEND_BLOCK_EVENT | Y | not tested | 23 | | 0x0a | EXEC_LOAD_EVENT | Y | | 24 | | 0x0b | DELETE_FILE_EVENT | Y | not tested | 25 | | 0x0c | NEW_LOAD_EVENT | Y | not tested | 26 | | 0x0d | RAND_EVENT | Y | | 27 | | 0x0e | USER_VAR_EVENT | Y | not fully tested | 28 | | 0x0f | FORMAT_DESCRIPTION_EVENT | Y | | 29 | | 0x10 | XID_EVENT | Y | | 30 | | 0x11 | BEGIN_LOAD_QUERY_EVENT | Y | | 31 | | 0x12 | EXECUTE_LOAD_QUERY_EVENT | Y | | 32 | | 0x13 | TABLE_MAP_EVENT | Y | not fully tested | 33 | | 0x14 | WRITE_ROWS_EVENTv0 | N | | 34 | | 0x15 | UPDATE_ROWS_EVENTv0 | N | | 35 | | 0x16 | DELETE_ROWS_EVENTv0 | N | | 36 | | 0x17 | WRITE_ROWS_EVENTv1 | N | | 37 | | 0x18 | UPDATE_ROWS_EVENTv1 | N | | 38 | | 0x19 | DELETE_ROWS_EVENTv1 | N | | 39 | | 0x1a | INCIDENT_EVENT | Y | not tested | 40 | | 0x1b | HEARTBEAT_EVENT | Y | not tested | 41 | | 0x1c | IGNORABLE_EVENT | N | | 42 | | 0x1d | ROWS_QUERY_EVENT | Y | | 43 | | 0x1e | WRITE_ROWS_EVENTv2 | Y | not fully tested | 44 | | 0x1f | UPDATE_ROWS_EVENTv2 | Y | not fully tested | 45 | | 0x20 | DELETE_ROWS_EVENTv2 | Y | not fully tested | 46 | | 0x21 | GTID_EVENT | Y | | 47 | | 0x22 | ANONYMOUS_GTID_EVENT | Y | | 48 | | 0x23 | PREVIOUS_GTIDS_EVENT | Y | | 49 | 50 | 51 | Of course, I can't guarantee that the all fields have been parsed correctly. If you encounter an error, please contact me. It is best to attach the binlog file. 52 | 53 | ## usage 54 | 55 | ### cli 56 | 57 | install cli tool 58 | 59 | ```bash 60 | cargo install --bin bcrab --git https://github.com/PrivateRookie/boxercrab.git 61 | ``` 62 | 63 | #### all commands 64 | 65 | ```bash 66 | MySQL binlog tool impl with Rust 67 | 68 | USAGE: 69 | bcrab [FLAGS] 70 | 71 | FLAGS: 72 | -d, --debug enable debug info 73 | -h, --help Prints help information 74 | -V, --version Prints version information 75 | 76 | SUBCOMMANDS: 77 | desc Show bin log desc msg 78 | help Prints this message or the help of the given subcommand(s) 79 | trans Transform a binlog file to specified format 80 | ``` 81 | 82 | 83 | #### trans 84 | 85 | this sub command transform binlog to json or yaml file 86 | 87 | ```bash 88 | bcrab-trans 0.2.0 89 | Transform a binlog file to specified format 90 | 91 | USAGE: 92 | bcrab trans [OPTIONS] [output] 93 | 94 | FLAGS: 95 | -h, --help Prints help information 96 | -V, --version Prints version information 97 | 98 | OPTIONS: 99 | -f, --format Output format [default: Json] [possible values: Json, Yaml] 100 | 101 | ARGS: 102 | Binlog file path 103 | Output file path, if not present, print to stdout 104 | ``` 105 | 106 | #### desc 107 | 108 | show desc info for a binlog 109 | 110 | ```bash 111 | bcrab-desc 0.2.0 112 | show bin log desc msg 113 | 114 | USAGE: 115 | bcrab desc 116 | 117 | FLAGS: 118 | -h, --help Prints help information 119 | -V, --version Prints version information 120 | 121 | ARGS: 122 | binlog file path 123 | ``` 124 | 125 | ### lib 126 | 127 | boxercrab can be use as a library too, but doc is not ready yeah, it's in planning. 128 | 129 | -------------------------------------------------------------------------------- /crates/core/src/bin/conn.rs: -------------------------------------------------------------------------------- 1 | use std::{ 2 | io::{Read, Write}, 3 | net::TcpStream, 4 | }; 5 | 6 | use boxercrab::{ 7 | codec::{Decode, DecodeError, Encode, Int1, Int2, Int3, Int4, VLenInt}, 8 | connector::{ 9 | encode_packet, native_password_auth, AuthSwitchReq, AuthSwitchResp, Capabilities, ColDef, 10 | ComBinLogDump, ComQuery, ComQuit, HandshakeResponse41, HandshakeV10, OkOrErr, OkPacket, 11 | Packet, TextResult, TextResultSet, 12 | }, 13 | }; 14 | use bytes::BytesMut; 15 | 16 | fn main() { 17 | let stream = TcpStream::connect("127.0.0.1:3306").unwrap(); 18 | let mut socket = MysqlSocket::new(stream); 19 | let _handshake: Packet = socket.read_packet().unwrap(); 20 | let resp = HandshakeResponse41 { 21 | caps: Capabilities::CLIENT_LONG_PASSWORD 22 | | Capabilities::CLIENT_PROTOCOL_41 23 | | Capabilities::CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA 24 | | Capabilities::CLIENT_RESERVED 25 | | Capabilities::CLIENT_RESERVED2 26 | | Capabilities::CLIENT_DEPRECATE_EOF 27 | | Capabilities::CLIENT_PLUGIN_AUTH, 28 | max_packet_size: Int4::from(1 << 24), 29 | charset: Int1::from(255), 30 | user_name: "auth".into(), 31 | auth_resp: BytesMut::new(), 32 | database: None, 33 | plugin_name: Some("mysql_native_password".into()), 34 | connect_attrs: Default::default(), 35 | zstd_level: Int1::from(0), 36 | }; 37 | socket.write_packet(1, &resp).unwrap(); 38 | let switch_req: AuthSwitchReq = socket.read_packet().unwrap().payload; 39 | if switch_req.plugin_name != "mysql_native_password" { 40 | panic!("") 41 | } 42 | let data = native_password_auth("1234".as_bytes(), &switch_req.plugin_data); 43 | let resp = AuthSwitchResp { 44 | data: BytesMut::from_iter(data), 45 | }; 46 | socket.write_packet(3, &resp).unwrap(); 47 | let _r: OkPacket = socket.read_packet().unwrap().payload; 48 | let query: ComQuery = "set @master_binlog_checksum= @@global.binlog_checksum".into(); 49 | socket.write_packet(0, &query).unwrap(); 50 | let _r: OkPacket = socket.read_packet().unwrap().payload; 51 | let query: ComQuery = "show master status".into(); 52 | socket.write_packet(0, &query).unwrap(); 53 | let result = socket.read_text_result_set().unwrap(); 54 | let file = String::from_utf8(result.rows[0].columns[0].clone()).unwrap(); 55 | let pos: u32 = String::from_utf8(result.rows[0].columns[1].clone()) 56 | .unwrap() 57 | .parse() 58 | .unwrap(); 59 | println!("{file} {pos}"); 60 | // let _r: OkPacket = socket.read_packet().unwrap().payload; 61 | let dump = ComBinLogDump { 62 | pos: Int4::from(pos), 63 | flags: Int2::from(0), 64 | server_id: Int4::from(100), 65 | filename: file, 66 | }; 67 | socket.write_packet(0, &dump).unwrap(); 68 | loop { 69 | let buf: Vec = socket.read_packet().unwrap().payload; 70 | println!("{buf:x?}"); 71 | } 72 | // println!("{oe:?}"); 73 | } 74 | 75 | pub struct MysqlSocket { 76 | stream: TcpStream, 77 | } 78 | 79 | #[derive(Debug)] 80 | pub enum PacketError { 81 | IOError(std::io::Error), 82 | Decode(DecodeError), 83 | } 84 | 85 | impl From for PacketError { 86 | fn from(value: std::io::Error) -> Self { 87 | Self::IOError(value) 88 | } 89 | } 90 | 91 | impl From for PacketError { 92 | fn from(value: DecodeError) -> Self { 93 | Self::Decode(value) 94 | } 95 | } 96 | 97 | impl MysqlSocket { 98 | pub fn new(stream: TcpStream) -> Self { 99 | Self { stream } 100 | } 101 | 102 | pub fn read_packet>(&mut self) -> Result, PacketError> { 103 | let mut buf = BytesMut::new(); 104 | buf.resize(4, 0); 105 | self.stream.read_exact(&mut buf)?; 106 | let len = Int3::decode(&mut buf)?; 107 | let seq_id = Int1::decode(&mut buf)?; 108 | let mut buf = BytesMut::with_capacity(len.int() as usize); 109 | buf.resize(len.int() as usize, 0); 110 | self.stream.read_exact(&mut buf)?; 111 | let payload = P::decode(&mut buf)?; 112 | Ok(Packet { 113 | len, 114 | seq_id, 115 | payload, 116 | }) 117 | } 118 | 119 | pub fn read_text_result_set(&mut self) -> Result { 120 | let column_count: VLenInt = self.read_packet()?.payload; 121 | let mut col_defs = vec![]; 122 | for _ in 0..(column_count.int() as usize) { 123 | let col_def: ColDef = self.read_packet()?.payload; 124 | col_defs.push(col_def); 125 | } 126 | let mut rows = vec![]; 127 | loop { 128 | let buf: Vec = self.read_packet()?.payload; 129 | let mut buf = BytesMut::from_iter(buf); 130 | if buf.first() == Some(&0xfe) && buf.len() < 9 { 131 | let _ = OkPacket::decode(&mut buf).unwrap(); 132 | break; 133 | } 134 | let row = TextResult::decode(&mut buf).unwrap(); 135 | rows.push(row); 136 | } 137 | Ok(TextResultSet { 138 | column_count, 139 | col_defs, 140 | rows, 141 | }) 142 | } 143 | 144 | pub fn write_packet( 145 | &mut self, 146 | seq_id: u8, 147 | payload: &P, 148 | ) -> Result<(), std::io::Error> { 149 | let mut buf = BytesMut::new(); 150 | encode_packet(seq_id, payload, &mut buf); 151 | self.stream.write_all(&buf) 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /tests/events/31_update_rows_v2/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200728 15:19:29 server id 1 end_log_pos 123 CRC32 0x438c06c3 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 01 42 20 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 01 42 20 5f 13 38 0d 00 08 00 12 00 |.....B...8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 c3 06 8c 43 |...C| 15 | # Start: binlog v 4, server v 5.7.30-log created 200728 15:19:29 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | AUIgXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAABQiBfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AcMGjEM= 21 | '/*!*/; 22 | # at 123 23 | #200728 15:19:29 server id 1 end_log_pos 154 CRC32 0xc5ed0c22 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 01 42 20 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 22 0c ed c5 |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200728 15:19:29 server id 1 end_log_pos 219 CRC32 0xb76a1ccc 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 01 42 20 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 00 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 cc 1c 6a b7 |............j.| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=yes 37 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 38 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 39 | # at 219 40 | #200728 15:19:29 server id 1 end_log_pos 294 CRC32 0xfc6ed171 41 | # Position Timestamp Type Master ID Size Master Pos Flags 42 | # db 01 42 20 5f 02 01 00 00 00 4b 00 00 00 26 01 00 00 08 00 43 | # ee f8 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 44 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 45 | # 10e 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 46 | # 11e 45 47 49 4e 71 d1 6e fc |EGINq.n.| 47 | # Query thread_id=248 exec_time=0 error_code=0 48 | SET TIMESTAMP=1595949569/*!*/; 49 | SET @@session.pseudo_thread_id=248/*!*/; 50 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 51 | SET @@session.sql_mode=1436549152/*!*/; 52 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 53 | /*!\C utf8 *//*!*/; 54 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 55 | SET @@session.lc_time_names=0/*!*/; 56 | SET @@session.collation_database=DEFAULT/*!*/; 57 | BEGIN 58 | /*!*/; 59 | # at 294 60 | #200728 15:19:29 server id 1 end_log_pos 369 CRC32 0x6b852797 61 | # Position Timestamp Type Master ID Size Master Pos Flags 62 | # 126 01 42 20 5f 13 01 00 00 00 4b 00 00 00 71 01 00 00 00 00 63 | # 139 d0 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |.........default| 64 | # 149 00 09 62 6f 78 65 72 63 72 61 62 00 09 03 0f 0f |..boxercrab.....| 65 | # 159 fc fc fc 04 05 f6 0b 90 01 a0 00 02 03 04 04 08 |................| 66 | # 169 0a 04 00 01 97 27 85 6b |.......k| 67 | # Table_map: `default`.`boxercrab` mapped to number 208 68 | # at 369 69 | #200728 15:19:29 server id 1 end_log_pos 502 CRC32 0xd3665ffb 70 | # Position Timestamp Type Master ID Size Master Pos Flags 71 | # 171 01 42 20 5f 1f 01 00 00 00 85 00 00 00 f6 01 00 00 00 00 72 | # 184 d0 00 00 00 00 00 01 00 02 00 09 ff ff ff ff 00 |................| 73 | # 194 fe 01 00 00 00 03 00 61 62 63 03 61 62 63 03 00 |.......abc.abc..| 74 | # 1a4 61 62 63 03 00 00 61 62 63 03 00 00 00 61 62 63 |abc...abc....abc| 75 | # 1b4 00 00 80 3f 00 00 00 00 00 00 00 40 80 00 03 00 |................| 76 | # 1c4 00 00 fe 01 00 00 00 02 00 78 64 02 78 64 02 00 |.........xd.xd..| 77 | # 1d4 78 64 02 00 00 78 64 02 00 00 00 78 64 00 00 80 |xd...xd....xd...| 78 | # 1e4 40 00 00 00 00 00 00 10 40 80 00 04 00 00 fb 5f |................| 79 | # 1f4 66 d3 |f.| 80 | # Update_rows: table id 208 flags: STMT_END_F 81 | 82 | BINLOG ' 83 | AUIgXxMBAAAASwAAAHEBAAAAANAAAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgAJAw8P/Pz8BAX2 84 | C5ABoAACAwQECAoEAAGXJ4Vr 85 | AUIgXx8BAAAAhQAAAPYBAAAAANAAAAAAAAEAAgAJ/////wD+AQAAAAMAYWJjA2FiYwMAYWJjAwAA 86 | YWJjAwAAAGFiYwAAgD8AAAAAAAAAQIAAAwAAAP4BAAAAAgB4ZAJ4ZAIAeGQCAAB4ZAIAAAB4ZAAA 87 | gEAAAAAAAAAQQIAABAAA+19m0w== 88 | '/*!*/; 89 | # at 502 90 | #200728 15:19:29 server id 1 end_log_pos 533 CRC32 0xfc082779 91 | # Position Timestamp Type Master ID Size Master Pos Flags 92 | # 1f6 01 42 20 5f 10 01 00 00 00 1f 00 00 00 15 02 00 00 00 00 93 | # 209 ca 04 00 00 00 00 00 00 79 27 08 fc |........y...| 94 | # Xid = 1226 95 | COMMIT/*!*/; 96 | # at 533 97 | #200728 15:19:29 server id 1 end_log_pos 580 CRC32 0xc18e92c5 98 | # Position Timestamp Type Master ID Size Master Pos Flags 99 | # 215 01 42 20 5f 04 01 00 00 00 2f 00 00 00 44 02 00 00 00 00 100 | # 228 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 101 | # 238 6e 2e 30 30 30 30 30 32 c5 92 8e c1 |n.000002....| 102 | # Rotate to mysql_bin.000002 pos: 4 103 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 104 | DELIMITER ; 105 | # End of log file 106 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 107 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 108 | -------------------------------------------------------------------------------- /crates/old/src/cli.rs: -------------------------------------------------------------------------------- 1 | use boxercrab::{Connection, Event}; 2 | use log::LevelFilter; 3 | use log4rs::{ 4 | append::console::{ConsoleAppender, Target}, 5 | config::{Appender, Config, Root}, 6 | Handle, 7 | }; 8 | use std::fs::File; 9 | use std::io::prelude::*; 10 | use structopt::{clap::arg_enum, StructOpt}; 11 | use tokio::runtime::Runtime; 12 | 13 | #[derive(Debug, StructOpt)] 14 | #[structopt(name = "boxercrab-cli", about = "MySQL binlog tool impl with Rust")] 15 | pub struct Args { 16 | /// enable debug info 17 | #[structopt(short, long)] 18 | debug: bool, 19 | 20 | #[structopt(subcommand)] 21 | sub: Cmd, 22 | } 23 | 24 | #[derive(Debug, StructOpt)] 25 | enum Cmd { 26 | /// Transform a binlog file to specified format 27 | Trans { 28 | /// Binlog file path 29 | input: String, 30 | 31 | /// Output file path, if not present, print to stdout 32 | output: Option, 33 | 34 | /// Output format 35 | #[structopt(short, long, possible_values = &Format::variants(), case_insensitive = true, default_value = "Json")] 36 | format: Format, 37 | }, 38 | 39 | /// Show bin log desc msg 40 | Desc { 41 | /// Binlog file path 42 | input: String, 43 | }, 44 | 45 | /// Connect to a server 46 | Conn { 47 | /// Connection url 48 | url: String, 49 | 50 | /// client id 51 | id: u32, 52 | }, 53 | } 54 | 55 | arg_enum! { 56 | #[derive(Debug)] 57 | enum Format { 58 | Json, 59 | Yaml, 60 | } 61 | } 62 | 63 | fn init_log(debug: bool) -> Handle { 64 | let level = if debug { 65 | LevelFilter::Debug 66 | } else { 67 | LevelFilter::Warn 68 | }; 69 | let stdout = ConsoleAppender::builder().target(Target::Stdout).build(); 70 | let config = Config::builder() 71 | .appender(Appender::builder().build("stdout", Box::new(stdout))) 72 | .build(Root::builder().appender("stdout").build(level)) 73 | .unwrap(); 74 | log4rs::init_config(config).unwrap() 75 | } 76 | 77 | fn read_input(path: &str) -> std::io::Result<(usize, Vec)> { 78 | let mut f = File::open(path)?; 79 | let mut buf = vec![]; 80 | let size = f.read_to_end(&mut buf)?; 81 | Ok((size, buf)) 82 | } 83 | 84 | fn parse_from_file(path: &str) -> Result, String> { 85 | match read_input(path) { 86 | Err(e) => Err(format!("failed to read {}: {}", path, e)), 87 | Ok((size, data)) => { 88 | log::debug!("read {} bytes", size); 89 | match Event::from_bytes(&data) { 90 | Err(e) => Err(format!("failed to parse binlog: {}", e)), 91 | Ok((remain, events)) => { 92 | if remain.len() != 0 { 93 | Err(format!("remain: {:?}", remain)) 94 | } else { 95 | Ok(events) 96 | } 97 | } 98 | } 99 | } 100 | } 101 | } 102 | 103 | fn main() { 104 | let args = Args::from_args(); 105 | let _handle = init_log(args.debug); 106 | match args.sub { 107 | Cmd::Trans { 108 | input, 109 | output, 110 | format, 111 | } => match parse_from_file(&input) { 112 | Err(e) => { 113 | println!("{}", e); 114 | } 115 | Ok(events) => { 116 | if let Some(output) = output { 117 | if let Ok(mut output) = File::create(output) { 118 | match format { 119 | Format::Json => { 120 | output 121 | .write_all( 122 | serde_json::to_string_pretty(&events).unwrap().as_bytes(), 123 | ) 124 | .unwrap(); 125 | } 126 | Format::Yaml => { 127 | output 128 | .write_all(serde_yaml::to_string(&events).unwrap().as_bytes()) 129 | .unwrap(); 130 | } 131 | } 132 | } 133 | } else { 134 | match format { 135 | Format::Json => { 136 | println!("{}", serde_json::to_string_pretty(&events).unwrap()); 137 | } 138 | Format::Yaml => println!("{}", serde_yaml::to_string(&events).unwrap()), 139 | } 140 | } 141 | } 142 | }, 143 | Cmd::Desc { input } => match parse_from_file(&input) { 144 | Err(e) => println!("{}", e), 145 | Ok(events) => { 146 | println!("Total: Events: {}", events.len()); 147 | match events.first().unwrap() { 148 | Event::FormatDesc { 149 | binlog_version, 150 | mysql_server_version, 151 | create_timestamp, 152 | .. 153 | } => { 154 | println!("Binlog version: {}", binlog_version); 155 | println!("Server version: {}", mysql_server_version); 156 | println!("Create_timestamp: {}", create_timestamp); 157 | } 158 | _ => unreachable!(), 159 | } 160 | } 161 | }, 162 | Cmd::Conn { url, id } => { 163 | let mut rt = Runtime::new().expect("unable to launch runtime"); 164 | rt.block_on(async { 165 | let mut conn = Connection::new(url, id); 166 | loop { 167 | match conn.recv().await { 168 | Ok(bytes) => match Event::parse(bytes.slice(1..).as_ref()) { 169 | Ok((_, event)) => { 170 | println!("\n{:#x?}\n", event); 171 | } 172 | Err(e) => log::error!( 173 | "failed to parse packet: {:?} due to{}", 174 | bytes.as_ref(), 175 | e 176 | ), 177 | }, 178 | Err(e) => { 179 | log::error!("failed to recv packet: {}", e); 180 | break; 181 | } 182 | } 183 | } 184 | }) 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /tests/events/17_18_load/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200729 14:35:14 server id 1 end_log_pos 123 CRC32 0x8568a6da 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 22 89 21 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 22 89 21 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 da a6 68 85 |..h.| 15 | # Start: binlog v 4, server v 5.7.30-log created 200729 14:35:14 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | IokhXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAAiiSFfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AdqmaIU= 21 | '/*!*/; 22 | # at 123 23 | #200729 14:35:14 server id 1 end_log_pos 154 CRC32 0x5e7a8825 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 22 89 21 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 25 88 7a 5e |..........z.| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200729 14:35:14 server id 1 end_log_pos 219 CRC32 0x91a5e6e2 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 22 89 21 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 e2 e6 a5 91 |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 38 | # at 219 39 | #200729 14:35:14 server id 1 end_log_pos 304 CRC32 0x357d0216 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 22 89 21 5f 02 01 00 00 00 55 00 00 00 30 01 00 00 08 00 42 | # ee 17 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 42 45 47 49 4e 16 02 |.default.BEGIN..| 46 | # 12e 7d 35 |.5| 47 | # Query thread_id=23 exec_time=0 error_code=0 48 | SET TIMESTAMP=1596033314/*!*/; 49 | SET @@session.pseudo_thread_id=23/*!*/; 50 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 51 | SET @@session.sql_mode=1436549152/*!*/; 52 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 53 | /*!\C utf8 *//*!*/; 54 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 55 | SET @@session.lc_time_names=0/*!*/; 56 | SET @@session.collation_database=DEFAULT/*!*/; 57 | BEGIN 58 | /*!*/; 59 | # at 304 60 | #200729 14:35:14 server id 1 end_log_pos 339 CRC32 0xbb82789e 61 | # Position Timestamp Type Master ID Size Master Pos Flags 62 | # 130 22 89 21 5f 11 01 00 00 00 23 00 00 00 53 01 00 00 00 00 63 | # 143 01 00 00 00 31 2c 22 61 62 63 22 0a 9e 78 82 bb |....1..abc...x..| 64 | # 65 | #Begin_load_query: file_id: 1 block_len: 8 66 | # at 339 67 | #200729 14:35:14 server id 1 end_log_pos 592 CRC32 0xf17d694e 68 | # Position Timestamp Type Master ID Size Master Pos Flags 69 | # 153 22 89 21 5f 12 01 00 00 00 fd 00 00 00 50 02 00 00 00 00 70 | # 166 17 00 00 00 00 00 00 00 07 00 00 24 00 01 00 00 |................| 71 | # 176 00 09 00 00 00 25 00 00 00 00 00 00 00 00 00 01 |................| 72 | # 186 20 00 a0 55 00 00 00 00 06 03 73 74 64 04 21 00 |...U......std...| 73 | # 196 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 00 64 65 |......default.de| 74 | # 1a6 66 61 75 6c 74 00 4c 4f 41 44 20 44 41 54 41 20 |fault.LOAD.DATA.| 75 | # 1b6 49 4e 46 49 4c 45 20 27 2f 74 6d 70 2f 64 61 74 |INFILE...tmp.dat| 76 | # 1c6 61 2e 74 78 74 27 20 49 4e 54 4f 20 54 41 42 4c |a.txt..INTO.TABL| 77 | # 1d6 45 20 60 62 6f 78 65 72 63 72 61 62 60 20 46 49 |E..boxercrab..FI| 78 | # 1e6 45 4c 44 53 20 54 45 52 4d 49 4e 41 54 45 44 20 |ELDS.TERMINATED.| 79 | # 1f6 42 59 20 27 2c 27 20 4f 50 54 49 4f 4e 41 4c 4c |BY.....OPTIONALL| 80 | # 206 59 20 20 45 4e 43 4c 4f 53 45 44 20 42 59 20 27 |Y..ENCLOSED.BY..| 81 | # 216 22 27 20 45 53 43 41 50 45 44 20 42 59 20 27 5c |...ESCAPED.BY...| 82 | # 226 5c 27 20 4c 49 4e 45 53 20 54 45 52 4d 49 4e 41 |...LINES.TERMINA| 83 | # 236 54 45 44 20 42 59 20 27 5c 6e 27 20 28 60 69 60 |TED.BY...n....i.| 84 | # 246 2c 20 60 63 60 29 4e 69 7d f1 |...c..Ni..| 85 | # Execute_load_query thread_id=23 exec_time=0 error_code=0 86 | use `default`/*!*/; 87 | SET TIMESTAMP=1596033314/*!*/; 88 | LOAD DATA LOCAL INFILE '/tmp/SQL_LOAD_MB-1-0' INTO TABLE `boxercrab` FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' (`i`, `c`) 89 | /*!*/; 90 | # file_id: 1 91 | # at 592 92 | #200729 14:35:14 server id 1 end_log_pos 623 CRC32 0x54e3faf9 93 | # Position Timestamp Type Master ID Size Master Pos Flags 94 | # 250 22 89 21 5f 10 01 00 00 00 1f 00 00 00 6f 02 00 00 00 00 95 | # 263 3a 00 00 00 00 00 00 00 f9 fa e3 54 |...........T| 96 | # Xid = 58 97 | COMMIT/*!*/; 98 | # at 623 99 | #200729 14:35:14 server id 1 end_log_pos 670 CRC32 0x923d4480 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 26f 22 89 21 5f 04 01 00 00 00 2f 00 00 00 9e 02 00 00 00 00 102 | # 282 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 103 | # 292 6e 2e 30 30 30 30 30 32 80 44 3d 92 |n.000002.D..| 104 | # Rotate to mysql_bin.000002 pos: 4 105 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 106 | DELIMITER ; 107 | # End of log file 108 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 109 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 110 | -------------------------------------------------------------------------------- /crates/core/src/connector/handshake_v10.rs: -------------------------------------------------------------------------------- 1 | use bytes::BytesMut; 2 | use parse_tool::InputBuf; 3 | 4 | use crate::codec::{get_null_term_str, Decode, DecodeError, Int1, Int2, Int4}; 5 | 6 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_connection_phase_packets_protocol_handshake_v10.html) 7 | #[derive(Debug, Clone)] 8 | pub struct HandshakeV10 { 9 | pub protocol_version: Int1, 10 | pub server_version: String, 11 | pub thread_id: Int4, 12 | pub caps: Capabilities, 13 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_character_set.html#a_protocol_character_set) 14 | pub charset: Int1, 15 | pub status: Int2, 16 | pub auth_plugin_name: String, 17 | pub auth_plugin_data: BytesMut, 18 | } 19 | 20 | impl Decode for HandshakeV10 { 21 | fn decode(input: &mut I) -> Result { 22 | let protocol_version = Int1::decode(input)?; 23 | if protocol_version.int() != 10 { 24 | return Err(DecodeError::InvalidData); 25 | } 26 | let server_version = get_null_term_str(input)?; 27 | let thread_id = Int4::decode(input)?; 28 | let mut auth_plugin_data = BytesMut::from_iter(input.read_vec(8)?); 29 | input.read_vec(1)?; 30 | let l_cap = Int2::decode(input)?; 31 | let charset = Int1::decode(input)?; 32 | let status = Int2::decode(input)?; 33 | let h_cap = Int2::decode(input)?; 34 | 35 | let mut caps = [0u8; 4]; 36 | caps[..2].copy_from_slice(l_cap.bytes()); 37 | caps[2..].copy_from_slice(h_cap.bytes()); 38 | let caps = Capabilities::from_bits(u32::from_le_bytes(caps)).unwrap(); 39 | let auth_data_len = Int1::decode(input)?.int(); 40 | input.read_vec(10)?; 41 | if auth_data_len > 0 { 42 | let len = 13.max(auth_data_len - 8) as usize; 43 | auth_plugin_data.extend_from_slice(&input.read_vec(len)?); 44 | } 45 | let auth_plugin_name = if caps.contains(Capabilities::CLIENT_PLUGIN_AUTH) { 46 | get_null_term_str(input)? 47 | } else { 48 | Default::default() 49 | }; 50 | Ok(Self { 51 | protocol_version, 52 | server_version, 53 | thread_id, 54 | caps, 55 | charset, 56 | status, 57 | auth_plugin_name, 58 | auth_plugin_data, 59 | }) 60 | } 61 | } 62 | 63 | bitflags::bitflags! { 64 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__capabilities__flags.html#ga07344a4eb8f5c74ea8875bb4e9852fb0) 65 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 66 | pub struct Capabilities: u32 { 67 | /// Use the improved version of Old Password Authentication. More... 68 | const CLIENT_LONG_PASSWORD = 1; 69 | 70 | /// Send found rows instead of affected rows in EOF_Packet. More... 71 | const CLIENT_FOUND_ROWS = 2; 72 | 73 | /// Get all column flags. More... 74 | const CLIENT_LONG_FLAG = 4; 75 | 76 | /// Database (schema) name can be specified on connect in Handshake Response Packet. More... 77 | const CLIENT_CONNECT_WITH_DB = 8; 78 | 79 | /// DEPRECATED: Don't allow database.table.column. More... 80 | const CLIENT_NO_SCHEMA = 16; 81 | 82 | /// Compression protocol supported. More... 83 | const CLIENT_COMPRESS = 32; 84 | 85 | /// Special handling of ODBC behavior. More... 86 | const CLIENT_ODBC = 64; 87 | 88 | /// Can use LOAD DATA LOCAL. More... 89 | const CLIENT_LOCAL_FILES = 128; 90 | 91 | /// Ignore spaces before '('. More... 92 | const CLIENT_IGNORE_SPACE = 256; 93 | 94 | /// New 4.1 protocol. More... 95 | const CLIENT_PROTOCOL_41 = 512; 96 | 97 | /// This is an interactive client. More... 98 | const CLIENT_INTERACTIVE = 1024; 99 | 100 | /// Use SSL encryption for the session. More... 101 | const CLIENT_SSL = 2048; 102 | 103 | /// Client only flag. More... 104 | const CLIENT_IGNORE_SIGPIPE = 4096; 105 | 106 | /// Client knows about transactions. More... 107 | const CLIENT_TRANSACTIONS = 8192; 108 | 109 | /// DEPRECATED: Old flag for 4.1 protocol 110 | const CLIENT_RESERVED = 16384; 111 | 112 | /// DEPRECATED: Old flag for 4.1 authentication \ CLIENT_SECURE_CONNECTION. More... 113 | const CLIENT_RESERVED2 = 32768; 114 | 115 | /// Enable/disable multi-stmt support. More... 116 | const CLIENT_MULTI_STATEMENTS = (1u32 << 16); 117 | 118 | /// Enable/disable multi-results. More... 119 | const CLIENT_MULTI_RESULTS = (1u32 << 17); 120 | 121 | /// Multi-results and OUT parameters in PS-protocol. More... 122 | const CLIENT_PS_MULTI_RESULTS = (1u32 << 18); 123 | 124 | /// Client supports plugin authentication. More... 125 | const CLIENT_PLUGIN_AUTH = (1u32 << 19); 126 | 127 | /// Client supports connection attributes. More... 128 | const CLIENT_CONNECT_ATTRS = (1u32 << 20); 129 | 130 | /// Enable authentication response packet to be larger than 255 bytes. More... 131 | const CLIENT_PLUGIN_AUTH_LENENC_CLIENT_DATA = (1u32 << 21); 132 | 133 | /// Don't close the connection for a user account with expired password. More... 134 | const CLIENT_CAN_HANDLE_EXPIRED_PASSWORDS = (1u32 << 22); 135 | 136 | /// Capable of handling server state change information. More... 137 | const CLIENT_SESSION_TRACK = (1u32 << 23); 138 | 139 | /// Client no longer needs EOF_Packet and will use OK_Packet instead. More... 140 | const CLIENT_DEPRECATE_EOF = (1u32 << 24); 141 | 142 | /// The client can handle optional metadata information in the resultset. More... 143 | const CLIENT_OPTIONAL_RESULTSET_METADATA = (1u32 << 25); 144 | 145 | /// Compression protocol extended to support zstd compression method. More... 146 | const CLIENT_ZSTD_COMPRESSION_ALGORITHM = (1u32 << 26); 147 | 148 | /// Support optional extension for query parameters into the COM_QUERY and COM_STMT_EXECUTE packets. More... 149 | const CLIENT_QUERY_ATTRIBUTES = (1u32 << 27); 150 | 151 | /// Support Multi factor authentication. More... 152 | const MULTI_FACTOR_AUTHENTICATION = (1u32 << 28); 153 | 154 | /// This flag will be reserved to extend the 32bit capabilities structure to 64bits. More... 155 | const CLIENT_CAPABILITY_EXTENSION = (1u32 << 29); 156 | 157 | /// Verify server certificate. More... 158 | const CLIENT_SSL_VERIFY_SERVER_CERT = (1u32 << 30); 159 | 160 | /// Don't reset the options after an unsuccessful connect. More... 161 | const CLIENT_REMEMBER_OPTIONS = (1u32 << 31); 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /crates/core/src/codec.rs: -------------------------------------------------------------------------------- 1 | use bytes::BufMut; 2 | use bytes::BytesMut; 3 | 4 | use parse_tool::{CheckError, InputBuf}; 5 | use thiserror::Error; 6 | #[derive(Debug, Clone, Error)] 7 | pub enum DecodeError { 8 | #[error("no enough data")] 9 | NoEnoughData, 10 | #[error("invalid utf-8 string")] 11 | InvalidUtf8, 12 | #[error("missing terminal null bytes")] 13 | MissingNull, 14 | #[error("invalid data")] 15 | InvalidData, 16 | } 17 | 18 | impl From for DecodeError { 19 | fn from(_: CheckError) -> Self { 20 | Self::NoEnoughData 21 | } 22 | } 23 | 24 | pub trait Decode: Sized { 25 | fn decode(input: &mut I) -> Result; 26 | } 27 | pub type DecodeResult = Result; 28 | 29 | pub trait Encode { 30 | fn encode(&self, buf: &mut BytesMut); 31 | } 32 | 33 | impl Decode for Vec { 34 | fn decode(input: &mut I) -> Result { 35 | Ok(input.read_to_end()) 36 | } 37 | } 38 | 39 | macro_rules! from_prime { 40 | ($t:ty, $name:ident) => { 41 | impl From<$t> for $name { 42 | fn from(value: $t) -> Self { 43 | Self(value.to_le_bytes()) 44 | } 45 | } 46 | }; 47 | ($t:ty, $name:ident, $max:expr, $idx:expr) => { 48 | impl From<$t> for $name { 49 | fn from(value: $t) -> Self { 50 | assert!(value <= $max); 51 | let mut val = Self::default(); 52 | val.0.copy_from_slice(&value.to_le_bytes()[..($idx + 1)]); 53 | val 54 | } 55 | } 56 | }; 57 | } 58 | 59 | macro_rules! custom_impl { 60 | ($t:ty, $name:ident, $len:literal) => { 61 | impl $name { 62 | pub fn new(value: [u8; $len]) -> $name { 63 | Self(value) 64 | } 65 | 66 | pub fn int(&self) -> $t { 67 | let data: $t = 0; 68 | let mut data = data.to_le_bytes(); 69 | let len = self.0.len(); 70 | data[..len].copy_from_slice(&self.0); 71 | <$t>::from_le_bytes(data) 72 | } 73 | 74 | pub fn bytes(&self) -> &[u8] { 75 | &self.0 76 | } 77 | } 78 | 79 | impl std::fmt::Display for $name { 80 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { 81 | write!(f, "{}", self.int()) 82 | } 83 | } 84 | 85 | impl Decode for $name { 86 | fn decode(input: &mut I) -> Result { 87 | Ok(Self(input.read_array()?)) 88 | } 89 | } 90 | 91 | impl Encode for $name { 92 | fn encode(&self, buf: &mut BytesMut) { 93 | buf.extend_from_slice(&self.0); 94 | } 95 | } 96 | }; 97 | } 98 | 99 | macro_rules! fix { 100 | ($name:ident, $len:literal, $min_ty:ty, $max:expr) => { 101 | #[derive(Default, Debug, Clone, Copy)] 102 | pub struct $name(pub(crate) [u8; $len]); 103 | 104 | from_prime!($min_ty, $name, $max, $len - 1); 105 | custom_impl!($min_ty, $name, $len); 106 | }; 107 | ($name:ident, $len:literal, $min_ty:ty) => { 108 | #[derive(Default, Debug, Clone, Copy)] 109 | pub struct $name(pub(crate) [u8; $len]); 110 | from_prime!($min_ty, $name); 111 | custom_impl!($min_ty, $name, $len); 112 | }; 113 | } 114 | 115 | fix!(Int1, 1, u8); 116 | fix!(Int2, 2, u16); 117 | fix!(Int3, 3, u32, u32::MAX >> 1); 118 | fix!(Int4, 4, u32); 119 | fix!(Int6, 6, u64, u64::MAX >> 2); 120 | fix!(Int8, 8, u64); 121 | 122 | /// variable length int 123 | #[derive(Default, Debug, Clone, Copy)] 124 | pub struct VLenInt(pub u64); 125 | 126 | impl VLenInt { 127 | pub fn new(val: u64) -> Self { 128 | Self(val) 129 | } 130 | 131 | pub fn int(&self) -> u64 { 132 | self.0 133 | } 134 | 135 | pub fn bytes(&self) -> BytesMut { 136 | let mut data = BytesMut::new(); 137 | self.encode(&mut data); 138 | data 139 | } 140 | } 141 | 142 | impl Decode for VLenInt { 143 | fn decode(input: &mut I) -> Result { 144 | match input.read_u8_le()? { 145 | val @ 0..=0xfb => Ok(Self(val as u64)), 146 | 0xfc => Ok(Self(input.read_u16_le()? as u64)), 147 | 0xfd => { 148 | let i = Int3::decode(input)?; 149 | Ok(Self(i.int() as u64)) 150 | } 151 | 0xfe => Ok(Self(input.read_u64_le()?)), 152 | 0xff => Err(DecodeError::InvalidData), 153 | } 154 | } 155 | } 156 | 157 | impl Encode for VLenInt { 158 | fn encode(&self, buf: &mut BytesMut) { 159 | match self.0 { 160 | 0..=250 => buf.put_u8(self.0 as u8), 161 | 251..=65535 => { 162 | buf.put_u8(0xfc); 163 | buf.extend_from_slice(&(self.0 as u16).to_le_bytes()); 164 | } 165 | 65536..=16777215 => { 166 | buf.put_u8(0xfd); 167 | buf.extend_from_slice(&(self.0 as u32).to_le_bytes()[..2]); 168 | } 169 | 16777216.. => { 170 | buf.put_u8(0xfe); 171 | buf.extend_from_slice(&self.0.to_le_bytes()); 172 | } 173 | } 174 | } 175 | } 176 | 177 | pub fn get_null_term_bytes(input: &mut I) -> Result, DecodeError> { 178 | let pos = input 179 | .slice() 180 | .iter() 181 | .position(|b| *b == b'\0') 182 | .ok_or(DecodeError::MissingNull)?; 183 | let data = input.read_vec(pos)?; 184 | input.jump_to(1)?; 185 | Ok(data) 186 | } 187 | 188 | pub fn put_null_term_bytes(input: impl AsRef<[u8]>, buf: &mut BytesMut) { 189 | buf.extend_from_slice(input.as_ref()); 190 | buf.put_u8(b'\0'); 191 | } 192 | 193 | pub fn get_var_bytes(input: &mut I) -> Result, DecodeError> { 194 | let len = VLenInt::decode(input)?.0 as usize; 195 | let data = input.read_vec(len)?; 196 | Ok(data) 197 | } 198 | 199 | pub fn put_var_bytes(input: impl AsRef<[u8]>, buf: &mut BytesMut) { 200 | let len = input.as_ref().len() as u64; 201 | let len = VLenInt::new(len); 202 | len.encode(buf); 203 | buf.extend_from_slice(input.as_ref()); 204 | } 205 | 206 | pub fn get_null_term_str(input: &mut I) -> Result { 207 | let raw = get_null_term_bytes(input)?; 208 | String::from_utf8(raw).map_err(|_| DecodeError::InvalidUtf8) 209 | } 210 | 211 | pub fn put_null_term_str(s: &str, buf: &mut BytesMut) { 212 | put_null_term_bytes(s.as_bytes(), buf) 213 | } 214 | 215 | pub fn get_var_str(input: &mut I) -> Result { 216 | let raw = get_var_bytes(input)?; 217 | String::from_utf8(raw).map_err(|_| DecodeError::InvalidUtf8) 218 | } 219 | 220 | pub fn put_var_str(s: &str, buf: &mut BytesMut) { 221 | let data = s.as_bytes(); 222 | put_var_bytes(data, buf) 223 | } 224 | -------------------------------------------------------------------------------- /tests/events/02_query/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200710 15:35:28 server id 1 end_log_pos 123 CRC32 0x1eec66a6 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 c0 8a 08 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 c0 8a 08 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 a6 66 ec 1e |.f..| 15 | # Start: binlog v 4, server v 5.7.30-log created 200710 15:35:28 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | wIoIXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADAighfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AaZm7B4= 21 | '/*!*/; 22 | # at 123 23 | #200710 15:35:28 server id 1 end_log_pos 154 CRC32 0xc8e7b3ee 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b c0 8a 08 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 ee b3 e7 c8 |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200710 15:35:28 server id 1 end_log_pos 219 CRC32 0xa74fb9c0 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a c0 8a 08 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 c0 b9 4f a7 |............O.| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 38 | # at 219 39 | #200710 15:35:28 server id 1 end_log_pos 357 CRC32 0x5c6f88d2 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db c0 8a 08 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 0c 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f d2 88 6f 5c |.....o.| 50 | # Query thread_id=12 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1594395328/*!*/; 53 | SET @@session.pseudo_thread_id=12/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200710 15:35:28 server id 1 end_log_pos 422 CRC32 0xfc33ed06 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 c0 8a 08 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 06 ed 33 fc |............3.| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:2'/*!*/; 72 | # at 422 73 | #200710 15:35:28 server id 1 end_log_pos 755 CRC32 0xf5b3c53d 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 c0 8a 08 5f 02 01 00 00 00 4d 01 00 00 f3 02 00 00 00 00 76 | # 1b9 0c 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 31 30 |itle..VARCHAR.10| 85 | # 249 30 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 |0..NOT.NULL.....| 86 | # 259 20 60 61 75 74 68 6f 72 60 20 56 41 52 43 48 41 |..author..VARCHA| 87 | # 269 52 28 34 30 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a |R.40..NOT.NULL..| 88 | # 279 20 20 20 20 60 74 69 6d 65 60 20 44 41 54 45 54 |.....time..DATET| 89 | # 289 49 4d 45 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 |IME.NOT.NULL....| 90 | # 299 20 20 60 73 63 6f 72 65 60 20 49 4e 54 20 44 45 |...score..INT.DE| 91 | # 2a9 46 41 55 4c 54 20 30 2c 0a 20 20 20 20 50 52 49 |FAULT.0......PRI| 92 | # 2b9 4d 41 52 59 20 4b 45 59 20 28 60 69 64 60 29 0a |MARY.KEY...id...| 93 | # 2c9 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 42 20 44 |.ENGINE.InnoDB.D| 94 | # 2d9 45 46 41 55 4c 54 20 43 48 41 52 53 45 54 3d 75 |EFAULT.CHARSET.u| 95 | # 2e9 74 66 38 6d 62 34 3d c5 b3 f5 |tf8mb4....| 96 | # Query thread_id=12 exec_time=0 error_code=0 97 | SET TIMESTAMP=1594395328/*!*/; 98 | CREATE TABLE `boxercrab` ( 99 | `id` INT UNSIGNED AUTO_INCREMENT, 100 | `title` VARCHAR(100) NOT NULL, 101 | `author` VARCHAR(40) NOT NULL, 102 | `time` DATETIME NOT NULL, 103 | `score` INT DEFAULT 0, 104 | PRIMARY KEY (`id`) 105 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 106 | /*!*/; 107 | # at 755 108 | #200710 15:35:28 server id 1 end_log_pos 802 CRC32 0x44c06f48 109 | # Position Timestamp Type Master ID Size Master Pos Flags 110 | # 2f3 c0 8a 08 5f 04 01 00 00 00 2f 00 00 00 22 03 00 00 00 00 111 | # 306 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 112 | # 316 6e 2e 30 30 30 30 30 32 48 6f c0 44 |n.000002Ho.D| 113 | # Rotate to mysql_bin.000002 pos: 4 114 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 115 | DELIMITER ; 116 | # End of log file 117 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 118 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 119 | -------------------------------------------------------------------------------- /crates/old/src/events/query.rs: -------------------------------------------------------------------------------- 1 | use crate::utils::{string_var, extract_string, pu32, string_nul}; 2 | use nom::{ 3 | bytes::complete::take, 4 | combinator::map, 5 | multi::many_m_n, 6 | number::complete::{le_u16, le_u32, le_u64, le_u8}, 7 | sequence::tuple, 8 | IResult, 9 | }; 10 | use serde::Serialize; 11 | 12 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 13 | pub enum QueryStatusVar { 14 | Q_FLAGS2_CODE(Q_FLAGS2_CODE_VAL), 15 | Q_SQL_MODE_CODE(Q_SQL_MODE_CODE_VAL), 16 | Q_CATALOG(String), 17 | Q_AUTO_INCREMENT(u16, u16), 18 | Q_CHARSET_CODE(u16, u16, u16), 19 | Q_TIME_ZONE_CODE(String), 20 | Q_CATALOG_NZ_CODE(String), 21 | Q_LC_TIME_NAMES_CODE(u16), 22 | Q_CHARSET_DATABASE_CODE(u16), 23 | Q_TABLE_MAP_FOR_UPDATE_CODE(u64), 24 | Q_MASTER_DATA_WRITTEN_CODE(u32), 25 | Q_INVOKERS(String, String), 26 | Q_UPDATED_DB_NAMES(Vec), 27 | // NOTE this field take 3 bytes 28 | Q_MICROSECONDS(u32), 29 | } 30 | 31 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 32 | pub struct Q_FLAGS2_CODE_VAL { 33 | pub auto_is_null: bool, 34 | pub auto_commit: bool, 35 | pub foreign_key_checks: bool, 36 | pub unique_checks: bool, 37 | } 38 | 39 | #[derive(Debug, Serialize, PartialEq, Eq, Clone)] 40 | pub struct Q_SQL_MODE_CODE_VAL { 41 | pub real_as_float: bool, 42 | pub pipes_as_concat: bool, 43 | pub ansi_quotes: bool, 44 | pub ignore_space: bool, 45 | pub not_used: bool, 46 | pub only_full_group_by: bool, 47 | pub no_unsigned_subtraction: bool, 48 | pub no_dir_in_create: bool, 49 | pub postgresql: bool, 50 | pub oracle: bool, 51 | pub mssql: bool, 52 | pub db2: bool, 53 | pub maxdb: bool, 54 | pub no_key_options: bool, 55 | pub no_table_options: bool, 56 | pub no_field_options: bool, 57 | pub mysql323: bool, 58 | pub mysql40: bool, 59 | pub ansi: bool, 60 | pub no_auto_value_on_zero: bool, 61 | pub no_backslash_escapes: bool, 62 | pub strict_trans_tables: bool, 63 | pub strict_all_tables: bool, 64 | pub no_zero_in_date: bool, 65 | pub no_zero_date: bool, 66 | pub invalid_dates: bool, 67 | pub error_for_division_by_zero: bool, 68 | pub traditional: bool, 69 | pub no_auto_create_user: bool, 70 | pub high_not_precedence: bool, 71 | pub no_engine_substitution: bool, 72 | pub pad_char_to_full_length: bool, 73 | } 74 | 75 | pub fn parse_status_var<'a>(input: &'a [u8]) -> IResult<&'a [u8], QueryStatusVar> { 76 | let (i, key) = le_u8(input)?; 77 | match key { 78 | 0x00 => { 79 | let (i, code) = le_u32(i)?; 80 | let auto_is_null = (code >> 14) % 2 == 1; 81 | let auto_commit = (code >> 19) % 2 == 0; 82 | let foreign_key_checks = (code >> 26) % 2 == 0; 83 | let unique_checks = (code >> 27) % 2 == 0; 84 | Ok(( 85 | i, 86 | QueryStatusVar::Q_FLAGS2_CODE(Q_FLAGS2_CODE_VAL { 87 | auto_is_null, 88 | auto_commit, 89 | foreign_key_checks, 90 | unique_checks, 91 | }), 92 | )) 93 | } 94 | 0x01 => { 95 | let (i, code) = le_u64(i)?; 96 | let val = Q_SQL_MODE_CODE_VAL { 97 | real_as_float: (code >> 0) % 2 == 1, 98 | pipes_as_concat: (code >> 1) % 2 == 1, 99 | ansi_quotes: (code >> 2) % 2 == 1, 100 | ignore_space: (code >> 3) % 2 == 1, 101 | not_used: (code >> 4) % 2 == 1, 102 | only_full_group_by: (code >> 5) % 2 == 1, 103 | no_unsigned_subtraction: (code >> 6) % 2 == 1, 104 | no_dir_in_create: (code >> 7) % 2 == 1, 105 | postgresql: (code >> 8) % 2 == 1, 106 | oracle: (code >> 9) % 2 == 1, 107 | mssql: (code >> 10) % 2 == 1, 108 | db2: (code >> 11) % 2 == 1, 109 | maxdb: (code >> 12) % 2 == 1, 110 | no_key_options: (code >> 13) % 2 == 1, 111 | no_table_options: (code >> 14) % 2 == 1, 112 | no_field_options: (code >> 15) % 2 == 1, 113 | mysql323: (code >> 16) % 2 == 1, 114 | mysql40: (code >> 17) % 2 == 1, 115 | ansi: (code >> 18) % 2 == 1, 116 | no_auto_value_on_zero: (code >> 19) % 2 == 1, 117 | no_backslash_escapes: (code >> 20) % 2 == 1, 118 | strict_trans_tables: (code >> 21) % 2 == 1, 119 | strict_all_tables: (code >> 22) % 2 == 1, 120 | no_zero_in_date: (code >> 23) % 2 == 1, 121 | no_zero_date: (code >> 24) % 2 == 1, 122 | invalid_dates: (code >> 25) % 2 == 1, 123 | error_for_division_by_zero: (code >> 26) % 2 == 1, 124 | traditional: (code >> 27) % 2 == 1, 125 | no_auto_create_user: (code >> 28) % 2 == 1, 126 | high_not_precedence: (code >> 29) % 2 == 1, 127 | no_engine_substitution: (code >> 30) % 2 == 1, 128 | pad_char_to_full_length: (code >> 31) % 2 == 1, 129 | }; 130 | Ok((i, QueryStatusVar::Q_SQL_MODE_CODE(val))) 131 | } 132 | 0x02 => { 133 | let (i, len) = le_u8(i)?; 134 | let (i, val) = map(take(len), |s: &[u8]| string_var(s, len as usize))(i)?; 135 | let (i, term) = le_u8(i)?; 136 | assert_eq!(term, 0x00); 137 | Ok((i, QueryStatusVar::Q_CATALOG(val))) 138 | } 139 | 0x03 => { 140 | let (i, incr) = le_u16(i)?; 141 | let (i, offset) = le_u16(i)?; 142 | Ok((i, QueryStatusVar::Q_AUTO_INCREMENT(incr, offset))) 143 | } 144 | 0x04 => { 145 | let (i, (client, conn, server)) = tuple((le_u16, le_u16, le_u16))(i)?; 146 | Ok((i, QueryStatusVar::Q_CHARSET_CODE(client, conn, server))) 147 | } 148 | 0x05 => { 149 | let (i, len) = le_u8(i)?; 150 | let (i, tz) = map(take(len), |s: &[u8]| extract_string(s))(i)?; 151 | Ok((i, QueryStatusVar::Q_TIME_ZONE_CODE(tz))) 152 | } 153 | 0x06 => { 154 | let (i, len) = le_u8(i)?; 155 | let (i, val) = map(take(len), |s: &[u8]| extract_string(s))(i)?; 156 | Ok((i, QueryStatusVar::Q_CATALOG_NZ_CODE(val))) 157 | } 158 | 0x07 => map(le_u16, |v| QueryStatusVar::Q_LC_TIME_NAMES_CODE(v))(i), 159 | 0x08 => map(le_u16, |v| QueryStatusVar::Q_CHARSET_DATABASE_CODE(v))(i), 160 | 0x09 => map(le_u64, |v| QueryStatusVar::Q_TABLE_MAP_FOR_UPDATE_CODE(v))(i), 161 | 0x0a => map(le_u32, |v| QueryStatusVar::Q_MASTER_DATA_WRITTEN_CODE(v))(i), 162 | 0x0b => { 163 | let (i, len) = le_u8(i)?; 164 | let (i, user) = map(take(len), |s: &[u8]| string_var(s, len as usize))(i)?; 165 | let (i, len) = le_u8(i)?; 166 | let (i, host) = map(take(len), |s: &[u8]| string_var(s, len as usize))(i)?; 167 | Ok((i, QueryStatusVar::Q_INVOKERS(user, host))) 168 | } 169 | 0x0c => { 170 | let (i, count) = le_u8(i)?; 171 | let (i, val) = many_m_n(count as usize, count as usize, string_nul)(i)?; 172 | Ok((i, QueryStatusVar::Q_UPDATED_DB_NAMES(val))) 173 | } 174 | 0x0d => map(pu32, |val| QueryStatusVar::Q_MICROSECONDS(val))(i), 175 | __ => unreachable!(), 176 | } 177 | } 178 | -------------------------------------------------------------------------------- /crates/core/src/binlog.rs: -------------------------------------------------------------------------------- 1 | use parse_tool::InputBuf; 2 | 3 | use crate::codec::{Decode, DecodeError, Int1, Int2, Int4, Int8}; 4 | 5 | bitflags::bitflags! { 6 | /// https://dev.mysql.com/doc/dev/mysql-server/latest/group__group__cs__binglog__event__header__flags.html 7 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 8 | #[cfg_attr(feature="serde", serde::Serialize, serde::DeSerialize)] 9 | pub struct EventHeaderFlag: u16 { 10 | /// If the query depends on the thread (for example: TEMPORARY TABLE) 11 | const LOG_EVENT_THREAD_SPECIFIC_F= 0x4; 12 | /// Suppress the generation of 'USE' statements before the actual statement 13 | const LOG_EVENT_SUPPRESS_USE_F =0x8; 14 | /// Artificial events are created arbitrarily and not written to binary log 15 | const LOG_EVENT_ARTIFICIAL_F = 0x20; 16 | /// Events with this flag set are created by slave IO thread and written to relay log 17 | const LOG_EVENT_RELAY_LOG_F = 0x40; 18 | /// For an event, 'e', carrying a type code, that a slave, 's', does not recognize, 's' will check 'e' for LOG_EVENT_IGNORABLE_F, and if the flag is set, then 'e' is ignored 19 | const LOG_EVENT_IGNORABLE_F = 0x80; 20 | /// Events with this flag are not filtered 21 | const LOG_EVENT_NO_FILTER_F = 0x100; 22 | /// MTS: group of events can be marked to force its execution in isolation from any other Workers 23 | const LOG_EVENT_MTS_ISOLATE_F = 0x200; 24 | } 25 | } 26 | 27 | impl Decode for EventHeaderFlag { 28 | fn decode(input: &mut I) -> Result { 29 | let flags = Int2::decode(input)?; 30 | Self::from_bits(flags.int()).ok_or(DecodeError::InvalidData) 31 | } 32 | } 33 | 34 | #[derive(Debug, Clone)] 35 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 36 | pub struct EventHeader { 37 | pub timestamp: Int4, 38 | pub event_type: Int1, 39 | pub server_id: Int4, 40 | pub event_size: Int4, 41 | pub log_pos: Int4, 42 | pub flags: EventHeaderFlag, 43 | } 44 | 45 | impl Decode for EventHeader { 46 | fn decode(input: &mut I) -> Result { 47 | let timestamp = Int4::decode(input)?; 48 | let event_type = Int1::decode(input)?; 49 | let server_id = Int4::decode(input)?; 50 | let event_size = Int4::decode(input)?; 51 | let log_pos = Int4::decode(input)?; 52 | let flags = EventHeaderFlag::decode(input)?; 53 | 54 | Ok(Self { 55 | timestamp, 56 | event_type, 57 | server_id, 58 | event_size, 59 | log_pos, 60 | flags, 61 | }) 62 | } 63 | } 64 | 65 | #[derive(Debug, Clone)] 66 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 67 | pub struct EventRaw { 68 | pub header: EventHeader, 69 | pub payload: Vec, 70 | } 71 | 72 | #[derive(Debug, Clone)] 73 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 74 | pub struct Event

{ 75 | pub header: EventHeader, 76 | pub payload: P, 77 | } 78 | 79 | #[derive(Debug, Clone)] 80 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 81 | pub struct QueryEvent { 82 | /// thread id 83 | pub slave_proxy_id: Int4, 84 | pub exec_time: Int4, 85 | pub schema_len: Int1, 86 | pub error_code: Int2, 87 | pub status_vars_length: Int2, 88 | } 89 | 90 | pub enum QueryStatusVar { 91 | QFlags2Code(), 92 | } 93 | 94 | bitflags::bitflags! { 95 | /// bit mask of flags that are usually set with the SET command 96 | /// 97 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query_00) 98 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 99 | #[cfg_attr(feature="serde", serde::Serialize, serde::DeSerialize)] 100 | pub struct QFlag2Code : u32 { 101 | const OPTION_AUTO_IS_NULL = 0x00004000; 102 | const OPTION_NOT_AUTOCOMMIT = 0x00080000; 103 | const OPTION_NO_FOREIGN_KEY_CHECKS = 0x04000000; 104 | const OPTION_RELAXED_UNIQUE_CHECKS = 0x08000000; 105 | } 106 | 107 | /// bit mask of flags that are usually set with SET sql_mode 108 | /// 109 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_query_00) 110 | #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 111 | #[cfg_attr(feature="serde", serde::Serialize, serde::DeSerialize)] 112 | pub struct QSqlModeCode : u64 { 113 | const MODE_REAL_AS_FLOAT = 0x00000001; 114 | const MODE_PIPES_AS_CONCAT = 0x00000002; 115 | const MODE_ANSI_QUOTES = 0x00000004; 116 | const MODE_IGNORE_SPACE = 0x00000008; 117 | const MODE_NOT_USED = 0x00000010; 118 | const MODE_ONLY_FULL_GROUP_BY = 0x00000020; 119 | const MODE_NO_UNSIGNED_SUBTRACTION = 0x00000040; 120 | const MODE_NO_DIR_IN_CREATE = 0x00000080; 121 | const MODE_POSTGRESQL = 0x00000100; 122 | const MODE_ORACLE = 0x00000200; 123 | const MODE_MSSQL = 0x00000400; 124 | const MODE_DB2 = 0x00000800; 125 | const MODE_MAXDB = 0x00001000; 126 | const MODE_NO_KEY_OPTIONS = 0x00002000; 127 | const MODE_NO_TABLE_OPTIONS = 0x00004000; 128 | const MODE_NO_FIELD_OPTIONS = 0x00008000; 129 | const MODE_MYSQL323 = 0x00010000; 130 | const MODE_MYSQL40 = 0x00020000; 131 | const MODE_ANSI = 0x00040000; 132 | const MODE_NO_AUTO_VALUE_ON_ZERO = 0x00080000; 133 | const MODE_NO_BACKSLASH_ESCAPES = 0x00100000; 134 | const MODE_STRICT_TRANS_TABLES = 0x00200000; 135 | const MODE_STRICT_ALL_TABLES = 0x00400000; 136 | const MODE_NO_ZERO_IN_DATE = 0x00800000; 137 | const MODE_NO_ZERO_DATE = 0x01000000; 138 | const MODE_INVALID_DATES = 0x02000000; 139 | const MODE_ERROR_FOR_DIVISION_BY_ZERO = 0x04000000; 140 | const MODE_TRADITIONAL = 0x08000000; 141 | const MODE_NO_AUTO_CREATE_USER = 0x10000000; 142 | const MODE_HIGH_NOT_PRECEDENCE = 0x20000000; 143 | const MODE_NO_ENGINE_SUBSTITUTION = 0x40000000; 144 | const MODE_PAD_CHAR_TO_FULL_LENGTH = 0x80000000; 145 | } 146 | } 147 | 148 | #[derive(Debug, Clone)] 149 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 150 | pub struct QAutoIncrement {} 151 | 152 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_stop) 153 | #[derive(Debug, Clone)] 154 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 155 | 156 | pub struct StopEvent; 157 | 158 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_replication_binlog_event.html#sect_protocol_replication_event_rotate) 159 | #[derive(Debug, Clone)] 160 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 161 | pub struct RotateEvent { 162 | pub pos: Int8, 163 | pub log: String, 164 | } 165 | 166 | /// [source](https://dev.mysql.com/doc/dev/mysql-server/latest/classbinary__log_1_1Intvar__event.html#details) 167 | #[derive(Debug, Clone)] 168 | #[cfg_attr(feature = "serde", serde::Serialize, serde::DeSerialize)] 169 | pub struct IntVarEvent { 170 | pub ty: u8, 171 | pub value: u64, 172 | } 173 | 174 | #[repr(u8)] 175 | pub enum IntVarEventType { 176 | InvalidIntEvent = 0, 177 | LastInsertIdEvent = 1, 178 | InsertIdEvent = 2, 179 | } 180 | -------------------------------------------------------------------------------- /crates/core/src/connector.rs: -------------------------------------------------------------------------------- 1 | use crate::codec::{ 2 | get_var_bytes, get_var_str, Decode, DecodeError, DecodeResult, Encode, Int1, Int2, Int3, Int4, 3 | VLenInt, 4 | }; 5 | 6 | mod handshake_v10; 7 | use bytes::{BufMut, BytesMut}; 8 | pub use handshake_v10::*; 9 | mod handshake_resp; 10 | pub use handshake_resp::*; 11 | mod auth; 12 | pub use auth::*; 13 | use parse_tool::InputBuf; 14 | 15 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_basic_packets.html#sect_protocol_basic_packets_packet) 16 | #[derive(Debug, Clone)] 17 | pub struct Packet

{ 18 | pub len: Int3, 19 | pub seq_id: Int1, 20 | pub payload: P, 21 | } 22 | 23 | pub fn decode_header(input: &mut I) -> DecodeResult<(Int3, Int1)> { 24 | let len = Int3::decode(input)?; 25 | let seq_id = Int1::decode(input)?; 26 | if input.left() < len.int() as usize { 27 | return Err(DecodeError::NoEnoughData); 28 | } 29 | Ok((len, seq_id)) 30 | } 31 | 32 | pub fn decode_packet>(input: &mut I) -> DecodeResult> { 33 | let (len, seq_id) = decode_header(input)?; 34 | let payload = P::decode(input)?; 35 | Ok(Packet { 36 | len, 37 | seq_id, 38 | payload, 39 | }) 40 | } 41 | 42 | pub fn encode_packet(seq_id: u8, payload: &P, buf: &mut BytesMut) { 43 | let start = buf.len(); 44 | buf.extend_from_slice(&[0, 0, 0]); 45 | Int1::from(seq_id).encode(buf); 46 | payload.encode(buf); 47 | let end = buf.len(); 48 | let len = end - start - 4; 49 | buf[start..(start + 3)].copy_from_slice(Int3::from(len as u32).bytes()) 50 | } 51 | 52 | #[allow(unused_macros)] 53 | macro_rules! hex { 54 | ($data:literal) => {{ 55 | let buf = bytes::BytesMut::from_iter( 56 | (0..$data.len()) 57 | .step_by(2) 58 | .map(|i| u8::from_str_radix(&$data[i..i + 2], 16).unwrap()), 59 | ); 60 | buf 61 | }}; 62 | } 63 | 64 | macro_rules! sha1 { 65 | ($($d:expr),*) => {{ 66 | let mut hasher = Sha1::new(); 67 | $(hasher.update($d);)* 68 | let i: [u8; 20] = hasher.finalize().into(); 69 | i 70 | }}; 71 | } 72 | 73 | pub fn native_password_auth(password: &[u8], auth_data: &[u8]) -> [u8; 20] { 74 | use sha1::{Digest, Sha1}; 75 | let mut h1 = sha1!(password); 76 | let h2 = sha1!(&h1); 77 | let multi = sha1!(&auth_data, h2); 78 | for i in 0..20 { 79 | h1[i] ^= multi[i]; 80 | } 81 | h1 82 | } 83 | 84 | #[derive(Debug, Clone)] 85 | pub struct OkPacket { 86 | pub header: Int1, 87 | pub affected_rows: VLenInt, 88 | pub last_insert_id: VLenInt, 89 | pub status_flags: Int2, 90 | pub warnings: Int2, 91 | pub info: String, 92 | } 93 | 94 | impl OkPacket { 95 | pub fn is_ok(&self) -> bool { 96 | self.header.int() == 0x00 97 | } 98 | 99 | pub fn is_eof(&self) -> bool { 100 | self.header.int() == 0xfe 101 | } 102 | } 103 | 104 | impl Decode for OkPacket { 105 | fn decode(input: &mut I) -> Result { 106 | let header = Int1::decode(input)?; 107 | let affected_rows = VLenInt::decode(input)?; 108 | let last_insert_id = VLenInt::decode(input)?; 109 | let status_flags = Int2::decode(input)?; 110 | let warnings = Int2::decode(input)?; 111 | let info = String::new(); 112 | Ok(Self { 113 | header, 114 | affected_rows, 115 | last_insert_id, 116 | status_flags, 117 | warnings, 118 | info, 119 | }) 120 | } 121 | } 122 | 123 | #[derive(Debug, Clone)] 124 | pub struct ErrPacket { 125 | pub header: Int1, 126 | pub code: Int2, 127 | pub sql_state_marker: Int1, 128 | pub sql_state: String, 129 | pub error_msg: String, 130 | } 131 | 132 | impl Decode for ErrPacket { 133 | fn decode(input: &mut I) -> Result { 134 | let header = Int1::decode(input)?; 135 | let code = Int2::decode(input)?; 136 | let sql_state_marker = Int1::decode(input)?; 137 | let sql_state = 138 | String::from_utf8(input.read_vec(5)?).map_err(|_| DecodeError::InvalidUtf8)?; 139 | let error_msg = 140 | String::from_utf8(input.read_to_end()).map_err(|_| DecodeError::InvalidUtf8)?; 141 | Ok(Self { 142 | header, 143 | code, 144 | sql_state, 145 | sql_state_marker, 146 | error_msg, 147 | }) 148 | } 149 | } 150 | 151 | #[derive(Debug, Clone)] 152 | pub enum OkOrErr { 153 | Ok(OkPacket), 154 | Err(ErrPacket), 155 | } 156 | 157 | impl Decode for OkOrErr { 158 | fn decode(input: &mut I) -> Result { 159 | match input.slice()[0] { 160 | 0xff => ErrPacket::decode(input).map(Self::Err), 161 | 0xfe | 0x0 => OkPacket::decode(input).map(Self::Ok), 162 | _ => Err(DecodeError::InvalidData), 163 | } 164 | } 165 | } 166 | 167 | #[derive(Debug, Clone, Copy)] 168 | pub struct ComQuit; 169 | 170 | impl Encode for ComQuit { 171 | fn encode(&self, buf: &mut BytesMut) { 172 | buf.put_u8(0x01); 173 | } 174 | } 175 | 176 | /// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query.html 177 | #[derive(Debug, Clone)] 178 | pub struct ComQuery { 179 | pub query: String, 180 | } 181 | 182 | impl Encode for ComQuery { 183 | fn encode(&self, buf: &mut BytesMut) { 184 | buf.put_u8(0x03); 185 | buf.extend_from_slice(self.query.as_bytes()); 186 | } 187 | } 188 | 189 | impl From for ComQuery { 190 | fn from(value: T) -> Self { 191 | Self { 192 | query: value.to_string(), 193 | } 194 | } 195 | } 196 | 197 | #[derive(Debug, Clone)] 198 | pub struct TextResultSet { 199 | pub column_count: VLenInt, 200 | pub col_defs: Vec, 201 | pub rows: Vec 202 | } 203 | 204 | /// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query_response.html 205 | #[derive(Debug, Clone)] 206 | pub struct TextResult { 207 | pub columns: Vec>, 208 | } 209 | 210 | impl Decode for TextResult { 211 | fn decode(input: &mut I) -> Result { 212 | let mut columns = vec![]; 213 | while input.left() > 0 { 214 | let col = get_var_bytes(input)?; 215 | columns.push(col); 216 | } 217 | Ok(Self { columns }) 218 | } 219 | } 220 | 221 | /// https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_query_response_text_resultset_column_definition.html 222 | #[derive(Debug, Clone)] 223 | pub struct ColDef { 224 | pub catalog: String, 225 | pub schema: String, 226 | pub table: String, 227 | pub original_table: String, 228 | pub name: String, 229 | pub original_name: String, 230 | pub length_of_fixed_length_fields: VLenInt, 231 | pub charset: Int2, 232 | pub column_length: Int4, 233 | pub ty: Int1, 234 | pub flags: Int2, 235 | pub decimals: Int1, 236 | } 237 | 238 | impl Decode for ColDef { 239 | fn decode(input: &mut I) -> Result { 240 | let catalog = get_var_str(input)?; 241 | let schema = get_var_str(input)?; 242 | let table = get_var_str(input)?; 243 | let original_table = get_var_str(input)?; 244 | let name = get_var_str(input)?; 245 | let original_name = get_var_str(input)?; 246 | let length_of_fixed_length_fields = VLenInt::decode(input)?; 247 | let charset = Int2::decode(input)?; 248 | let column_length = Int4::decode(input)?; 249 | let ty = Int1::decode(input)?; 250 | let flags = Int2::decode(input)?; 251 | let decimals = Int1::decode(input)?; 252 | Ok(Self { 253 | catalog, 254 | schema, 255 | table, 256 | original_table, 257 | name, 258 | original_name, 259 | length_of_fixed_length_fields, 260 | charset, 261 | column_length, 262 | ty, 263 | flags, 264 | decimals, 265 | }) 266 | } 267 | } 268 | 269 | /// [doc](https://dev.mysql.com/doc/dev/mysql-server/latest/page_protocol_com_binlog_dump.html) 270 | #[derive(Debug, Clone)] 271 | pub struct ComBinLogDump { 272 | pub pos: Int4, 273 | pub flags: Int2, 274 | pub server_id: Int4, 275 | pub filename: String, 276 | } 277 | 278 | impl Encode for ComBinLogDump { 279 | fn encode(&self, buf: &mut BytesMut) { 280 | buf.put_u8(0x12); 281 | self.pos.encode(buf); 282 | self.flags.encode(buf); 283 | self.server_id.encode(buf); 284 | buf.extend_from_slice(self.filename.as_bytes()); 285 | } 286 | } 287 | -------------------------------------------------------------------------------- /tests/events/05_intvar/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200729 13:29:52 server id 1 end_log_pos 123 CRC32 0x4c9c16f1 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 d0 79 21 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 d0 79 21 5f 13 38 0d 00 08 00 12 00 |.....y...8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 f1 16 9c 4c |...L| 15 | # Start: binlog v 4, server v 5.7.30-log created 200729 13:29:52 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | 0HkhXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADQeSFfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AfEWnEw= 21 | '/*!*/; 22 | # at 123 23 | #200729 13:29:52 server id 1 end_log_pos 154 CRC32 0xeef2fccb 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b d0 79 21 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 cb fc f2 ee |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200729 13:29:52 server id 1 end_log_pos 219 CRC32 0xdb8bf1cc 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a d0 79 21 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 cc f1 8b db |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 38 | # at 219 39 | #200729 13:29:52 server id 1 end_log_pos 357 CRC32 0x19b66ca0 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db d0 79 21 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 03 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f a0 6c b6 19 |....l..| 50 | # Query thread_id=3 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596029392/*!*/; 53 | SET @@session.pseudo_thread_id=3/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200729 13:29:52 server id 1 end_log_pos 422 CRC32 0x80f7a50a 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 d0 79 21 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 0a a5 f7 80 |..............| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:2'/*!*/; 72 | # at 422 73 | #200729 13:29:52 server id 1 end_log_pos 586 CRC32 0x121caf25 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 d0 79 21 5f 02 01 00 00 00 a4 00 00 00 4a 02 00 00 00 00 76 | # 1b9 03 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 69 20 49 4e 54 20 41 55 |........i.INT.AU| 82 | # 219 54 4f 5f 49 4e 43 52 45 4d 45 4e 54 20 50 52 49 |TO.INCREMENT.PRI| 83 | # 229 4d 41 52 59 20 4b 45 59 2c 0a 20 20 20 20 63 20 |MARY.KEY......c.| 84 | # 239 56 41 52 43 48 41 52 28 31 30 29 0a 29 25 af 1c |VARCHAR.10......| 85 | # 249 12 |.| 86 | # Query thread_id=3 exec_time=0 error_code=0 87 | SET TIMESTAMP=1596029392/*!*/; 88 | CREATE TABLE `boxercrab` ( 89 | i INT AUTO_INCREMENT PRIMARY KEY, 90 | c VARCHAR(10) 91 | ) 92 | /*!*/; 93 | # at 586 94 | #200729 13:29:52 server id 1 end_log_pos 651 CRC32 0x5de4214e 95 | # Position Timestamp Type Master ID Size Master Pos Flags 96 | # 24a d0 79 21 5f 21 01 00 00 00 41 00 00 00 8b 02 00 00 00 00 97 | # 25d 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 98 | # 26d 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 99 | # 27d 00 00 03 00 00 00 00 00 00 00 4e 21 e4 5d |..........N...| 100 | # GTID last_committed=2 sequence_number=3 rbr_only=no 101 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:3'/*!*/; 102 | # at 651 103 | #200729 13:29:52 server id 1 end_log_pos 736 CRC32 0x87b62815 104 | # Position Timestamp Type Master ID Size Master Pos Flags 105 | # 28b d0 79 21 5f 02 01 00 00 00 55 00 00 00 e0 02 00 00 08 00 106 | # 29e 03 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 107 | # 2ae 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 108 | # 2be 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 109 | # 2ce 00 64 65 66 61 75 6c 74 00 42 45 47 49 4e 15 28 |.default.BEGIN..| 110 | # 2de b6 87 |..| 111 | # Query thread_id=3 exec_time=0 error_code=0 112 | SET TIMESTAMP=1596029392/*!*/; 113 | BEGIN 114 | /*!*/; 115 | # at 736 116 | # at 768 117 | #200729 13:29:52 server id 1 end_log_pos 768 CRC32 0x97f96756 118 | # Position Timestamp Type Master ID Size Master Pos Flags 119 | # 2e0 d0 79 21 5f 05 01 00 00 00 20 00 00 00 00 03 00 00 00 00 120 | # 2f3 01 00 00 00 00 00 00 00 00 56 67 f9 97 |.........Vg..| 121 | # Intvar 122 | SET LAST_INSERT_ID=0/*!*/; 123 | #200729 13:29:52 server id 1 end_log_pos 912 CRC32 0x76624c99 124 | # Position Timestamp Type Master ID Size Master Pos Flags 125 | # 300 d0 79 21 5f 02 01 00 00 00 90 00 00 00 90 03 00 00 00 00 126 | # 313 03 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 127 | # 323 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 128 | # 333 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 129 | # 343 00 64 65 66 61 75 6c 74 00 49 4e 53 45 52 54 20 |.default.INSERT.| 130 | # 353 49 4e 54 4f 20 60 62 6f 78 65 72 63 72 61 62 60 |INTO..boxercrab.| 131 | # 363 20 28 69 2c 20 63 29 20 56 41 4c 55 45 53 28 4c |..i..c..VALUES.L| 132 | # 373 41 53 54 5f 49 4e 53 45 52 54 5f 49 44 28 29 2b |AST.INSERT.ID...| 133 | # 383 31 2c 20 27 61 62 63 27 29 99 4c 62 76 |1...abc...Lbv| 134 | # Query thread_id=3 exec_time=0 error_code=0 135 | SET TIMESTAMP=1596029392/*!*/; 136 | INSERT INTO `boxercrab` (i, c) VALUES(LAST_INSERT_ID()+1, 'abc') 137 | /*!*/; 138 | # at 912 139 | #200729 13:29:52 server id 1 end_log_pos 943 CRC32 0x3cdf1b81 140 | # Position Timestamp Type Master ID Size Master Pos Flags 141 | # 390 d0 79 21 5f 10 01 00 00 00 1f 00 00 00 af 03 00 00 00 00 142 | # 3a3 08 00 00 00 00 00 00 00 81 1b df 3c |............| 143 | # Xid = 8 144 | COMMIT/*!*/; 145 | # at 943 146 | #200729 13:29:52 server id 1 end_log_pos 990 CRC32 0x37dc7b16 147 | # Position Timestamp Type Master ID Size Master Pos Flags 148 | # 3af d0 79 21 5f 04 01 00 00 00 2f 00 00 00 de 03 00 00 00 00 149 | # 3c2 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 150 | # 3d2 6e 2e 30 30 30 30 30 32 16 7b dc 37 |n.000002...7| 151 | # Rotate to mysql_bin.000002 pos: 4 152 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 153 | DELIMITER ; 154 | # End of log file 155 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 156 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 157 | -------------------------------------------------------------------------------- /tests/events/13_rand/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200730 14:12:39 server id 1 end_log_pos 123 CRC32 0x1e06b1b5 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 57 d5 22 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 57 d5 22 5f 13 38 0d 00 08 00 12 00 |....W....8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 b5 b1 06 1e |....| 15 | # Start: binlog v 4, server v 5.7.30-log created 200730 14:12:39 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | V9UiXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAABX1SJfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AbWxBh4= 21 | '/*!*/; 22 | # at 123 23 | #200730 14:12:39 server id 1 end_log_pos 154 CRC32 0x35519fa1 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 57 d5 22 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 a1 9f 51 35 |..........Q5| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200730 14:12:39 server id 1 end_log_pos 219 CRC32 0xd0412269 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 57 d5 22 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 69 22 41 d0 |..........i.A.| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 38 | # at 219 39 | #200730 14:12:39 server id 1 end_log_pos 357 CRC32 0x854ceff6 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 57 d5 22 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f f6 ef 4c 85 |.....L.| 50 | # Query thread_id=10 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596118359/*!*/; 53 | SET @@session.pseudo_thread_id=10/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200730 14:12:39 server id 1 end_log_pos 422 CRC32 0x8b3d76af 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 57 d5 22 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 af 76 3d 8b |...........v..| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:2'/*!*/; 72 | # at 422 73 | #200730 14:12:39 server id 1 end_log_pos 586 CRC32 0x3060e19f 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 57 d5 22 5f 02 01 00 00 00 a4 00 00 00 4a 02 00 00 00 00 76 | # 1b9 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 69 20 49 4e 54 20 41 55 |........i.INT.AU| 82 | # 219 54 4f 5f 49 4e 43 52 45 4d 45 4e 54 20 50 52 49 |TO.INCREMENT.PRI| 83 | # 229 4d 41 52 59 20 4b 45 59 2c 0a 20 20 20 20 63 20 |MARY.KEY......c.| 84 | # 239 56 41 52 43 48 41 52 28 31 30 29 0a 29 9f e1 60 |VARCHAR.10......| 85 | # 249 30 |0| 86 | # Query thread_id=10 exec_time=0 error_code=0 87 | SET TIMESTAMP=1596118359/*!*/; 88 | CREATE TABLE `boxercrab` ( 89 | i INT AUTO_INCREMENT PRIMARY KEY, 90 | c VARCHAR(10) 91 | ) 92 | /*!*/; 93 | # at 586 94 | #200730 14:12:39 server id 1 end_log_pos 651 CRC32 0x562ef2eb 95 | # Position Timestamp Type Master ID Size Master Pos Flags 96 | # 24a 57 d5 22 5f 21 01 00 00 00 41 00 00 00 8b 02 00 00 00 00 97 | # 25d 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 98 | # 26d 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 99 | # 27d 00 00 03 00 00 00 00 00 00 00 eb f2 2e 56 |.............V| 100 | # GTID last_committed=2 sequence_number=3 rbr_only=no 101 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:3'/*!*/; 102 | # at 651 103 | #200730 14:12:39 server id 1 end_log_pos 736 CRC32 0x0f46d6b5 104 | # Position Timestamp Type Master ID Size Master Pos Flags 105 | # 28b 57 d5 22 5f 02 01 00 00 00 55 00 00 00 e0 02 00 00 08 00 106 | # 29e 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 107 | # 2ae 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 108 | # 2be 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 109 | # 2ce 00 64 65 66 61 75 6c 74 00 42 45 47 49 4e b5 d6 |.default.BEGIN..| 110 | # 2de 46 0f |F.| 111 | # Query thread_id=10 exec_time=0 error_code=0 112 | SET TIMESTAMP=1596118359/*!*/; 113 | BEGIN 114 | /*!*/; 115 | # at 736 116 | # at 775 117 | #200730 14:12:39 server id 1 end_log_pos 775 CRC32 0x140ee955 118 | # Position Timestamp Type Master ID Size Master Pos Flags 119 | # 2e0 57 d5 22 5f 0d 01 00 00 00 27 00 00 00 07 03 00 00 00 00 120 | # 2f3 77 12 6b 29 00 00 00 00 14 04 69 11 00 00 00 00 |w.k.......i.....| 121 | # 303 55 e9 0e 14 |U...| 122 | # Rand 123 | SET @@RAND_SEED1=694882935, @@RAND_SEED2=292094996/*!*/; 124 | #200730 14:12:39 server id 1 end_log_pos 920 CRC32 0xc94fcc8b 125 | # Position Timestamp Type Master ID Size Master Pos Flags 126 | # 307 57 d5 22 5f 02 01 00 00 00 91 00 00 00 98 03 00 00 00 00 127 | # 31a 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 128 | # 32a 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 129 | # 33a 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 130 | # 34a 00 64 65 66 61 75 6c 74 00 49 4e 53 45 52 54 20 |.default.INSERT.| 131 | # 35a 49 4e 54 4f 20 60 62 6f 78 65 72 63 72 61 62 60 |INTO..boxercrab.| 132 | # 36a 20 28 69 2c 20 63 29 20 56 41 4c 55 45 53 28 46 |..i..c..VALUES.F| 133 | # 37a 4c 4f 4f 52 28 52 41 4e 44 28 29 20 2a 20 31 30 |LOOR.RAND.....10| 134 | # 38a 30 29 2c 20 27 61 62 63 27 29 8b cc 4f c9 |0....abc....O.| 135 | # Query thread_id=10 exec_time=0 error_code=0 136 | SET TIMESTAMP=1596118359/*!*/; 137 | INSERT INTO `boxercrab` (i, c) VALUES(FLOOR(RAND() * 100), 'abc') 138 | /*!*/; 139 | # at 920 140 | #200730 14:12:39 server id 1 end_log_pos 951 CRC32 0xac5f1c1d 141 | # Position Timestamp Type Master ID Size Master Pos Flags 142 | # 398 57 d5 22 5f 10 01 00 00 00 1f 00 00 00 b7 03 00 00 00 00 143 | # 3ab 35 00 00 00 00 00 00 00 1d 1c 5f ac |5...........| 144 | # Xid = 53 145 | COMMIT/*!*/; 146 | # at 951 147 | #200730 14:12:39 server id 1 end_log_pos 998 CRC32 0x7c702604 148 | # Position Timestamp Type Master ID Size Master Pos Flags 149 | # 3b7 57 d5 22 5f 04 01 00 00 00 2f 00 00 00 e6 03 00 00 00 00 150 | # 3ca 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 151 | # 3da 6e 2e 30 30 30 30 30 32 04 26 70 7c |n.000002..p.| 152 | # Rotate to mysql_bin.000002 pos: 4 153 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 154 | DELIMITER ; 155 | # End of log file 156 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 157 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 158 | -------------------------------------------------------------------------------- /tests/events/16_xid/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 6:24:55 server id 1 end_log_pos 123 CRC32 0xf0bd8e51 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 37 b9 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 37 b9 23 5f 13 38 0d 00 08 00 12 00 |....7....8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 51 8e bd f0 |Q...| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 6:24:55 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | N7kjXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAA3uSNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AVGOvfA= 21 | '/*!*/; 22 | # at 123 23 | #200731 6:24:55 server id 1 end_log_pos 154 CRC32 0xba229ee0 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 37 b9 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 e0 9e 22 ba |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 6:24:55 server id 1 end_log_pos 219 CRC32 0xf85fe2c9 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 37 b9 23 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 c9 e2 5f f8 |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:1'/*!*/; 38 | # at 219 39 | #200731 6:24:55 server id 1 end_log_pos 357 CRC32 0x40a6649d 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 37 b9 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 0b 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f 9d 64 a6 40 |....d..| 50 | # Query thread_id=11 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596176695/*!*/; 53 | SET @@session.pseudo_thread_id=11/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 6:24:55 server id 1 end_log_pos 422 CRC32 0xa323b60f 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 37 b9 23 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 0f b6 23 a3 |..............| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:2'/*!*/; 72 | # at 422 73 | #200731 6:24:55 server id 1 end_log_pos 662 CRC32 0xec3977c1 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 37 b9 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 0b 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 c1 77 39 ec |T.utf8mb4.w9.| 90 | # Query thread_id=11 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596176695/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 6:24:55 server id 1 end_log_pos 727 CRC32 0x1e4ea77f 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 37 b9 23 5f 21 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 103 | # 2b9 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 7f a7 4e 1e |............N.| 105 | # GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:3'/*!*/; 108 | # at 727 109 | #200731 6:24:55 server id 1 end_log_pos 802 CRC32 0x36374c57 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 37 b9 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 0b 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e 57 4c 37 36 |EGINWL76| 116 | # Query thread_id=11 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596176695/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 6:24:55 server id 1 end_log_pos 860 CRC32 0x60ae5d62 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 37 b9 23 5f 13 01 00 00 00 3a 00 00 00 5c 03 00 00 00 00 124 | # 335 6d 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |m........default| 125 | # 345 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 126 | # 355 a0 00 00 62 5d ae 60 |...b...| 127 | # Table_map: `default`.`boxercrab` mapped to number 109 128 | # at 860 129 | #200731 6:24:55 server id 1 end_log_pos 912 CRC32 0x6a60f64b 130 | # Position Timestamp Type Master ID Size Master Pos Flags 131 | # 35c 37 b9 23 5f 1e 01 00 00 00 34 00 00 00 90 03 00 00 00 00 132 | # 36f 6d 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |m...............| 133 | # 37f 00 0b 68 61 68 68 68 68 68 68 68 68 68 4b f6 60 |..hahhhhhhhhhK..| 134 | # 38f 6a |j| 135 | # Write_rows: table id 109 flags: STMT_END_F 136 | 137 | BINLOG ' 138 | N7kjXxMBAAAAOgAAAFwDAAAAAG0AAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAAYl2u 139 | YA== 140 | N7kjXx4BAAAANAAAAJADAAAAAG0AAAAAAAEAAgAC//wBAAAAC2hhaGhoaGhoaGhoS/Zgag== 141 | '/*!*/; 142 | # at 912 143 | #200731 6:24:55 server id 1 end_log_pos 943 CRC32 0x5dd31b62 144 | # Position Timestamp Type Master ID Size Master Pos Flags 145 | # 390 37 b9 23 5f 10 01 00 00 00 1f 00 00 00 af 03 00 00 00 00 146 | # 3a3 29 00 00 00 00 00 00 00 62 1b d3 5d |........b...| 147 | # Xid = 41 148 | COMMIT/*!*/; 149 | # at 943 150 | #200731 6:24:55 server id 1 end_log_pos 990 CRC32 0xfdcba63c 151 | # Position Timestamp Type Master ID Size Master Pos Flags 152 | # 3af 37 b9 23 5f 04 01 00 00 00 2f 00 00 00 de 03 00 00 00 00 153 | # 3c2 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 154 | # 3d2 6e 2e 30 30 30 30 30 32 3c a6 cb fd |n.000002....| 155 | # Rotate to mysql_bin.000002 pos: 4 156 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 157 | DELIMITER ; 158 | # End of log file 159 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 160 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 161 | -------------------------------------------------------------------------------- /tests/events/19_table_map/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 6:31:52 server id 1 end_log_pos 123 CRC32 0xaed19301 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 d8 ba 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 d8 ba 23 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 01 93 d1 ae |....| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 6:31:52 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | 2LojXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADYuiNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AQGT0a4= 21 | '/*!*/; 22 | # at 123 23 | #200731 6:31:52 server id 1 end_log_pos 154 CRC32 0xd85e4ec0 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b d8 ba 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 c0 4e 5e d8 |.........N..| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 6:31:52 server id 1 end_log_pos 219 CRC32 0x16900142 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a d8 ba 23 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 42 01 90 16 |..........B...| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:1'/*!*/; 38 | # at 219 39 | #200731 6:31:52 server id 1 end_log_pos 357 CRC32 0xb88f6c55 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db d8 ba 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 0e 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f 55 6c 8f b8 |...Ul..| 50 | # Query thread_id=14 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596177112/*!*/; 53 | SET @@session.pseudo_thread_id=14/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 6:31:52 server id 1 end_log_pos 422 CRC32 0x4dec5584 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 d8 ba 23 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 84 55 ec 4d |...........U.M| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:2'/*!*/; 72 | # at 422 73 | #200731 6:31:52 server id 1 end_log_pos 662 CRC32 0x87b4790e 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 d8 ba 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 0e 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 0e 79 b4 87 |T.utf8mb4.y..| 90 | # Query thread_id=14 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596177112/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 6:31:52 server id 1 end_log_pos 727 CRC32 0xf08144f4 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 d8 ba 23 5f 21 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 103 | # 2b9 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 f4 44 81 f0 |...........D..| 105 | # GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:3'/*!*/; 108 | # at 727 109 | #200731 6:31:52 server id 1 end_log_pos 802 CRC32 0xcefe8126 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 d8 ba 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 0e 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e 26 81 fe ce |EGIN....| 116 | # Query thread_id=14 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596177112/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 6:31:52 server id 1 end_log_pos 860 CRC32 0xee4a224a 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 d8 ba 23 5f 13 01 00 00 00 3a 00 00 00 5c 03 00 00 00 00 124 | # 335 6e 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |n........default| 125 | # 345 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 126 | # 355 a0 00 00 4a 22 4a ee |...J.J.| 127 | # Table_map: `default`.`boxercrab` mapped to number 110 128 | # at 860 129 | #200731 6:31:52 server id 1 end_log_pos 912 CRC32 0x9c77e162 130 | # Position Timestamp Type Master ID Size Master Pos Flags 131 | # 35c d8 ba 23 5f 1e 01 00 00 00 34 00 00 00 90 03 00 00 00 00 132 | # 36f 6e 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |n...............| 133 | # 37f 00 0b 68 61 68 68 68 68 68 68 68 68 68 62 e1 77 |..hahhhhhhhhhb.w| 134 | # 38f 9c |.| 135 | # Write_rows: table id 110 flags: STMT_END_F 136 | 137 | BINLOG ' 138 | 2LojXxMBAAAAOgAAAFwDAAAAAG4AAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAASiJK 139 | 7g== 140 | 2LojXx4BAAAANAAAAJADAAAAAG4AAAAAAAEAAgAC//wBAAAAC2hhaGhoaGhoaGhoYuF3nA== 141 | '/*!*/; 142 | ### INSERT INTO `default`.`boxercrab` 143 | ### SET 144 | ### @1=1 /* INT meta=0 nullable=0 is_null=0 */ 145 | ### @2='hahhhhhhhhh' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */ 146 | # at 912 147 | #200731 6:31:52 server id 1 end_log_pos 943 CRC32 0x9a34e8c5 148 | # Position Timestamp Type Master ID Size Master Pos Flags 149 | # 390 d8 ba 23 5f 10 01 00 00 00 1f 00 00 00 af 03 00 00 00 00 150 | # 3a3 36 00 00 00 00 00 00 00 c5 e8 34 9a |6.........4.| 151 | # Xid = 54 152 | COMMIT/*!*/; 153 | # at 943 154 | #200731 6:31:52 server id 1 end_log_pos 990 CRC32 0x84df84b5 155 | # Position Timestamp Type Master ID Size Master Pos Flags 156 | # 3af d8 ba 23 5f 04 01 00 00 00 2f 00 00 00 de 03 00 00 00 00 157 | # 3c2 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 158 | # 3d2 6e 2e 30 30 30 30 30 32 b5 84 df 84 |n.000002....| 159 | # Rotate to mysql_bin.000002 pos: 4 160 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 161 | DELIMITER ; 162 | # End of log file 163 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 164 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 165 | -------------------------------------------------------------------------------- /tests/events/34_anonymous_gtid/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 7:51:39 server id 1 end_log_pos 123 CRC32 0xfcd95922 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 8b cd 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 8b cd 23 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 22 59 d9 fc |.Y..| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 7:51:39 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | i80jXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAACLzSNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | ASJZ2fw= 21 | '/*!*/; 22 | # at 123 23 | #200731 7:51:39 server id 1 end_log_pos 154 CRC32 0xae83948f 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 8b cd 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 8f 94 83 ae |............| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 7:51:39 server id 1 end_log_pos 219 CRC32 0x4c7fe988 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 8b cd 23 5f 22 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 34 | # bd 00 00 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 88 e9 7f 4c |.............L| 36 | # Anonymous_GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; 38 | # at 219 39 | #200731 7:51:39 server id 1 end_log_pos 357 CRC32 0x93826114 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 8b cd 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 04 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f 14 61 82 93 |....a..| 50 | # Query thread_id=4 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596181899/*!*/; 53 | SET @@session.pseudo_thread_id=4/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 7:51:39 server id 1 end_log_pos 422 CRC32 0x22ee0b1d 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 8b cd 23 5f 22 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 68 | # 188 00 00 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 1d 0b ee 22 |..............| 70 | # Anonymous_GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; 72 | # at 422 73 | #200731 7:51:39 server id 1 end_log_pos 662 CRC32 0x316f0e81 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 8b cd 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 04 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 81 0e 6f 31 |T.utf8mb4..o1| 90 | # Query thread_id=4 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596181899/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 7:51:39 server id 1 end_log_pos 727 CRC32 0x3a088a63 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 8b cd 23 5f 22 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 103 | # 2b9 00 00 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 63 8a 08 3a |..........c...| 105 | # Anonymous_GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= 'ANONYMOUS'/*!*/; 108 | # at 727 109 | #200731 7:51:39 server id 1 end_log_pos 802 CRC32 0x123d2598 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 8b cd 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 04 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e 98 25 3d 12 |EGIN....| 116 | # Query thread_id=4 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596181899/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 7:51:39 server id 1 end_log_pos 876 CRC32 0x3cb3b610 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 8b cd 23 5f 1d 01 00 00 00 4a 00 00 00 6c 03 00 00 80 00 124 | # 335 32 49 4e 53 45 52 54 20 49 4e 54 4f 20 60 62 6f |2INSERT.INTO..bo| 125 | # 345 78 65 72 63 72 61 62 60 20 28 60 74 69 74 6c 65 |xercrab....title| 126 | # 355 60 29 20 56 41 4c 55 45 53 20 28 27 61 62 63 64 |...VALUES...abcd| 127 | # 365 65 27 29 10 b6 b3 3c |e......| 128 | # Rows_query 129 | # INSERT INTO `boxercrab` (`title`) VALUES ('abcde') 130 | # at 876 131 | #200731 7:51:39 server id 1 end_log_pos 934 CRC32 0x43a88704 132 | # Position Timestamp Type Master ID Size Master Pos Flags 133 | # 36c 8b cd 23 5f 13 01 00 00 00 3a 00 00 00 a6 03 00 00 00 00 134 | # 37f 6d 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |m........default| 135 | # 38f 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 136 | # 39f a0 00 00 04 87 a8 43 |......C| 137 | # Table_map: `default`.`boxercrab` mapped to number 109 138 | # at 934 139 | #200731 7:51:39 server id 1 end_log_pos 980 CRC32 0x22a0a735 140 | # Position Timestamp Type Master ID Size Master Pos Flags 141 | # 3a6 8b cd 23 5f 1e 01 00 00 00 2e 00 00 00 d4 03 00 00 00 00 142 | # 3b9 6d 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |m...............| 143 | # 3c9 00 05 61 62 63 64 65 35 a7 a0 22 |..abcde5...| 144 | # Write_rows: table id 109 flags: STMT_END_F 145 | 146 | BINLOG ' 147 | i80jXx0BAAAASgAAAGwDAACAADJJTlNFUlQgSU5UTyBgYm94ZXJjcmFiYCAoYHRpdGxlYCkgVkFM 148 | VUVTICgnYWJjZGUnKRC2szw= 149 | i80jXxMBAAAAOgAAAKYDAAAAAG0AAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAABIeo 150 | Qw== 151 | i80jXx4BAAAALgAAANQDAAAAAG0AAAAAAAEAAgAC//wBAAAABWFiY2RlNaegIg== 152 | '/*!*/; 153 | ### INSERT INTO `default`.`boxercrab` 154 | ### SET 155 | ### @1=1 /* INT meta=0 nullable=0 is_null=0 */ 156 | ### @2='abcde' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */ 157 | # at 980 158 | #200731 7:51:39 server id 1 end_log_pos 1011 CRC32 0x39b02711 159 | # Position Timestamp Type Master ID Size Master Pos Flags 160 | # 3d4 8b cd 23 5f 10 01 00 00 00 1f 00 00 00 f3 03 00 00 00 00 161 | # 3e7 0d 00 00 00 00 00 00 00 11 27 b0 39 |...........9| 162 | # Xid = 13 163 | COMMIT/*!*/; 164 | # at 1011 165 | #200731 7:51:39 server id 1 end_log_pos 1058 CRC32 0x092c4ed6 166 | # Position Timestamp Type Master ID Size Master Pos Flags 167 | # 3f3 8b cd 23 5f 04 01 00 00 00 2f 00 00 00 22 04 00 00 00 00 168 | # 406 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 169 | # 416 6e 2e 30 30 30 30 30 32 d6 4e 2c 09 |n.000002.N..| 170 | # Rotate to mysql_bin.000002 pos: 4 171 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 172 | DELIMITER ; 173 | # End of log file 174 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 175 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 176 | -------------------------------------------------------------------------------- /tests/events/30_write_rows_v2/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 7:06:13 server id 1 end_log_pos 123 CRC32 0xcd3ce32d 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 e5 c2 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 e5 c2 23 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 2d e3 3c cd |....| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 7:06:13 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | 5cIjXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADlwiNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AS3jPM0= 21 | '/*!*/; 22 | # at 123 23 | #200731 7:06:13 server id 1 end_log_pos 154 CRC32 0x43f8b4e7 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b e5 c2 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 e7 b4 f8 43 |...........C| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 7:06:13 server id 1 end_log_pos 219 CRC32 0xb613197b 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a e5 c2 23 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 7b 19 13 b6 |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:1'/*!*/; 38 | # at 219 39 | #200731 7:06:13 server id 1 end_log_pos 357 CRC32 0xb63292c5 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db e5 c2 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f c5 92 32 b6 |.....2.| 50 | # Query thread_id=10 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596179173/*!*/; 53 | SET @@session.pseudo_thread_id=10/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 7:06:13 server id 1 end_log_pos 422 CRC32 0xed6f4dbd 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 e5 c2 23 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 bd 4d 6f ed |...........Mo.| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:2'/*!*/; 72 | # at 422 73 | #200731 7:06:13 server id 1 end_log_pos 662 CRC32 0x9069f08b 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 e5 c2 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 0a 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 8b f0 69 90 |T.utf8mb4..i.| 90 | # Query thread_id=10 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596179173/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 7:06:13 server id 1 end_log_pos 727 CRC32 0x50025ccd 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 e5 c2 23 5f 21 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 103 | # 2b9 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 cd 5c 02 50 |.............P| 105 | # GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:3'/*!*/; 108 | # at 727 109 | #200731 7:06:13 server id 1 end_log_pos 802 CRC32 0xab5d6f9f 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 e5 c2 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 0a 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e 9f 6f 5d ab |EGIN.o..| 116 | # Query thread_id=10 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596179173/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 7:06:13 server id 1 end_log_pos 876 CRC32 0x0c7a1812 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 e5 c2 23 5f 1d 01 00 00 00 4a 00 00 00 6c 03 00 00 80 00 124 | # 335 32 49 4e 53 45 52 54 20 49 4e 54 4f 20 60 62 6f |2INSERT.INTO..bo| 125 | # 345 78 65 72 63 72 61 62 60 20 28 60 74 69 74 6c 65 |xercrab....title| 126 | # 355 60 29 20 56 41 4c 55 45 53 20 28 27 61 62 63 64 |...VALUES...abcd| 127 | # 365 65 27 29 12 18 7a 0c |e....z.| 128 | # Rows_query 129 | # INSERT INTO `boxercrab` (`title`) VALUES ('abcde') 130 | # at 876 131 | #200731 7:06:13 server id 1 end_log_pos 934 CRC32 0xb197d49d 132 | # Position Timestamp Type Master ID Size Master Pos Flags 133 | # 36c e5 c2 23 5f 13 01 00 00 00 3a 00 00 00 a6 03 00 00 00 00 134 | # 37f 6f 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |o........default| 135 | # 38f 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 136 | # 39f a0 00 00 9d d4 97 b1 |.......| 137 | # Table_map: `default`.`boxercrab` mapped to number 111 138 | # at 934 139 | #200731 7:06:13 server id 1 end_log_pos 980 CRC32 0x04e24441 140 | # Position Timestamp Type Master ID Size Master Pos Flags 141 | # 3a6 e5 c2 23 5f 1e 01 00 00 00 2e 00 00 00 d4 03 00 00 00 00 142 | # 3b9 6f 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |o...............| 143 | # 3c9 00 05 61 62 63 64 65 41 44 e2 04 |..abcdeAD..| 144 | # Write_rows: table id 111 flags: STMT_END_F 145 | 146 | BINLOG ' 147 | 5cIjXx0BAAAASgAAAGwDAACAADJJTlNFUlQgSU5UTyBgYm94ZXJjcmFiYCAoYHRpdGxlYCkgVkFM 148 | VUVTICgnYWJjZGUnKRIYegw= 149 | 5cIjXxMBAAAAOgAAAKYDAAAAAG8AAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAAndSX 150 | sQ== 151 | 5cIjXx4BAAAALgAAANQDAAAAAG8AAAAAAAEAAgAC//wBAAAABWFiY2RlQUTiBA== 152 | '/*!*/; 153 | ### INSERT INTO `default`.`boxercrab` 154 | ### SET 155 | ### @1=1 /* INT meta=0 nullable=0 is_null=0 */ 156 | ### @2='abcde' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */ 157 | # at 980 158 | #200731 7:06:13 server id 1 end_log_pos 1011 CRC32 0xfe587e9a 159 | # Position Timestamp Type Master ID Size Master Pos Flags 160 | # 3d4 e5 c2 23 5f 10 01 00 00 00 1f 00 00 00 f3 03 00 00 00 00 161 | # 3e7 25 00 00 00 00 00 00 00 9a 7e 58 fe |..........X.| 162 | # Xid = 37 163 | COMMIT/*!*/; 164 | # at 1011 165 | #200731 7:06:13 server id 1 end_log_pos 1058 CRC32 0x8759751f 166 | # Position Timestamp Type Master ID Size Master Pos Flags 167 | # 3f3 e5 c2 23 5f 04 01 00 00 00 2f 00 00 00 22 04 00 00 00 00 168 | # 406 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 169 | # 416 6e 2e 30 30 30 30 30 32 1f 75 59 87 |n.000002.uY.| 170 | # Rotate to mysql_bin.000002 pos: 4 171 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 172 | DELIMITER ; 173 | # End of log file 174 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 175 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 176 | -------------------------------------------------------------------------------- /tests/events/33_35_gtid_prev_gtid/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 9:02:47 server id 1 end_log_pos 123 CRC32 0x8e336304 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 37 de 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 37 de 23 5f 13 38 0d 00 08 00 12 00 |....7....8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 04 63 33 8e |.c3.| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 9:02:47 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | N94jXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAA33iNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AQRjM44= 21 | '/*!*/; 22 | # at 123 23 | #200731 9:02:47 server id 1 end_log_pos 154 CRC32 0x29ee3254 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 37 de 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 54 32 ee 29 |........T2..| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 9:02:47 server id 1 end_log_pos 219 CRC32 0xbb3ea13d 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 37 de 23 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 3d a1 3e bb |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:1'/*!*/; 38 | # at 219 39 | #200731 9:02:47 server id 1 end_log_pos 357 CRC32 0x5b68659f 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 37 de 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 10 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f 9f 65 68 5b |....eh.| 50 | # Query thread_id=16 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596186167/*!*/; 53 | SET @@session.pseudo_thread_id=16/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 9:02:47 server id 1 end_log_pos 422 CRC32 0xe042f5fb 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 37 de 23 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 fb f5 42 e0 |............B.| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:2'/*!*/; 72 | # at 422 73 | #200731 9:02:47 server id 1 end_log_pos 662 CRC32 0xd6b71c8b 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 37 de 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 10 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 8b 1c b7 d6 |T.utf8mb4....| 90 | # Query thread_id=16 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596186167/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 9:02:47 server id 1 end_log_pos 727 CRC32 0x5d2fe48b 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 37 de 23 5f 21 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 103 | # 2b9 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 8b e4 2f 5d |..............| 105 | # GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:3'/*!*/; 108 | # at 727 109 | #200731 9:02:47 server id 1 end_log_pos 802 CRC32 0xc987a7df 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 37 de 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 10 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e df a7 87 c9 |EGIN....| 116 | # Query thread_id=16 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596186167/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 9:02:47 server id 1 end_log_pos 876 CRC32 0xb615e40f 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 37 de 23 5f 1d 01 00 00 00 4a 00 00 00 6c 03 00 00 80 00 124 | # 335 32 49 4e 53 45 52 54 20 49 4e 54 4f 20 60 62 6f |2INSERT.INTO..bo| 125 | # 345 78 65 72 63 72 61 62 60 20 28 60 74 69 74 6c 65 |xercrab....title| 126 | # 355 60 29 20 56 41 4c 55 45 53 20 28 27 61 62 63 64 |...VALUES...abcd| 127 | # 365 65 27 29 0f e4 15 b6 |e......| 128 | # Rows_query 129 | # INSERT INTO `boxercrab` (`title`) VALUES ('abcde') 130 | # at 876 131 | #200731 9:02:47 server id 1 end_log_pos 934 CRC32 0x75b5763f 132 | # Position Timestamp Type Master ID Size Master Pos Flags 133 | # 36c 37 de 23 5f 13 01 00 00 00 3a 00 00 00 a6 03 00 00 00 00 134 | # 37f 70 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |p........default| 135 | # 38f 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 136 | # 39f a0 00 00 3f 76 b5 75 |....v.u| 137 | # Table_map: `default`.`boxercrab` mapped to number 112 138 | # at 934 139 | #200731 9:02:47 server id 1 end_log_pos 980 CRC32 0x4dfb7bac 140 | # Position Timestamp Type Master ID Size Master Pos Flags 141 | # 3a6 37 de 23 5f 1e 01 00 00 00 2e 00 00 00 d4 03 00 00 00 00 142 | # 3b9 70 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |p...............| 143 | # 3c9 00 05 61 62 63 64 65 ac 7b fb 4d |..abcde...M| 144 | # Write_rows: table id 112 flags: STMT_END_F 145 | 146 | BINLOG ' 147 | N94jXx0BAAAASgAAAGwDAACAADJJTlNFUlQgSU5UTyBgYm94ZXJjcmFiYCAoYHRpdGxlYCkgVkFM 148 | VUVTICgnYWJjZGUnKQ/kFbY= 149 | N94jXxMBAAAAOgAAAKYDAAAAAHAAAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAAP3a1 150 | dQ== 151 | N94jXx4BAAAALgAAANQDAAAAAHAAAAAAAAEAAgAC//wBAAAABWFiY2RlrHv7TQ== 152 | '/*!*/; 153 | ### INSERT INTO `default`.`boxercrab` 154 | ### SET 155 | ### @1=1 /* INT meta=0 nullable=0 is_null=0 */ 156 | ### @2='abcde' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */ 157 | # at 980 158 | #200731 9:02:47 server id 1 end_log_pos 1011 CRC32 0x7935d5ca 159 | # Position Timestamp Type Master ID Size Master Pos Flags 160 | # 3d4 37 de 23 5f 10 01 00 00 00 1f 00 00 00 f3 03 00 00 00 00 161 | # 3e7 3f 00 00 00 00 00 00 00 ca d5 35 79 |..........5y| 162 | # Xid = 63 163 | COMMIT/*!*/; 164 | # at 1011 165 | #200731 9:02:47 server id 1 end_log_pos 1058 CRC32 0xc5d58611 166 | # Position Timestamp Type Master ID Size Master Pos Flags 167 | # 3f3 37 de 23 5f 04 01 00 00 00 2f 00 00 00 22 04 00 00 00 00 168 | # 406 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 169 | # 416 6e 2e 30 30 30 30 30 32 11 86 d5 c5 |n.000002....| 170 | # Rotate to mysql_bin.000002 pos: 4 171 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 172 | DELIMITER ; 173 | # End of log file 174 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 175 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 176 | -------------------------------------------------------------------------------- /tests/events/29_row_query/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200731 6:50:34 server id 1 end_log_pos 123 CRC32 0x8f6a764f 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 3a bf 23 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 3a bf 23 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 4f 76 6a 8f |Ovj.| 15 | # Start: binlog v 4, server v 5.7.30-log created 200731 6:50:34 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | Or8jXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAAA6vyNfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | AU92ao8= 21 | '/*!*/; 22 | # at 123 23 | #200731 6:50:34 server id 1 end_log_pos 154 CRC32 0x48b3e5df 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b 3a bf 23 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 df e5 b3 48 |...........H| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200731 6:50:34 server id 1 end_log_pos 219 CRC32 0x2224d5d0 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a 3a bf 23 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 d0 d5 24 22 |..............| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:1'/*!*/; 38 | # at 219 39 | #200731 6:50:34 server id 1 end_log_pos 357 CRC32 0x72c929ec 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db 3a bf 23 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 04 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f ec 29 c9 72 |......r| 50 | # Query thread_id=4 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596178234/*!*/; 53 | SET @@session.pseudo_thread_id=4/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200731 6:50:34 server id 1 end_log_pos 422 CRC32 0x79588116 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 3a bf 23 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 16 81 58 79 |............Xy| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:2'/*!*/; 72 | # at 422 73 | #200731 6:50:34 server id 1 end_log_pos 662 CRC32 0x0355e864 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 3a bf 23 5f 02 01 00 00 00 f0 00 00 00 96 02 00 00 00 00 76 | # 1b9 04 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 74 |NCREMENT.......t| 84 | # 239 69 74 6c 65 60 20 56 41 52 43 48 41 52 28 34 30 |itle..VARCHAR.40| 85 | # 249 29 20 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 |..NOT.NULL......| 86 | # 259 50 52 49 4d 41 52 59 20 4b 45 59 20 28 60 69 64 |PRIMARY.KEY...id| 87 | # 269 60 29 0a 29 45 4e 47 49 4e 45 3d 49 6e 6e 6f 44 |....ENGINE.InnoD| 88 | # 279 42 20 44 45 46 41 55 4c 54 20 43 48 41 52 53 45 |B.DEFAULT.CHARSE| 89 | # 289 54 3d 75 74 66 38 6d 62 34 64 e8 55 03 |T.utf8mb4d.U.| 90 | # Query thread_id=4 exec_time=0 error_code=0 91 | SET TIMESTAMP=1596178234/*!*/; 92 | CREATE TABLE `boxercrab` ( 93 | `id` INT UNSIGNED AUTO_INCREMENT, 94 | `title` VARCHAR(40) NOT NULL, 95 | PRIMARY KEY (`id`) 96 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 97 | /*!*/; 98 | # at 662 99 | #200731 6:50:34 server id 1 end_log_pos 727 CRC32 0xc4359066 100 | # Position Timestamp Type Master ID Size Master Pos Flags 101 | # 296 3a bf 23 5f 21 01 00 00 00 41 00 00 00 d7 02 00 00 00 00 102 | # 2a9 00 80 54 9e cc d2 f2 11 ea b7 90 02 42 ac 13 00 |..T.........B...| 103 | # 2b9 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 104 | # 2c9 00 00 03 00 00 00 00 00 00 00 66 90 35 c4 |..........f.5.| 105 | # GTID last_committed=2 sequence_number=3 rbr_only=yes 106 | /*!50718 SET TRANSACTION ISOLATION LEVEL READ COMMITTED*//*!*/; 107 | SET @@SESSION.GTID_NEXT= '80549ecc-d2f2-11ea-b790-0242ac130002:3'/*!*/; 108 | # at 727 109 | #200731 6:50:34 server id 1 end_log_pos 802 CRC32 0x67c7842b 110 | # Position Timestamp Type Master ID Size Master Pos Flags 111 | # 2d7 3a bf 23 5f 02 01 00 00 00 4b 00 00 00 22 03 00 00 08 00 112 | # 2ea 04 00 00 00 00 00 00 00 07 00 00 1a 00 00 00 00 |................| 113 | # 2fa 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 114 | # 30a 04 21 00 21 00 2d 00 64 65 66 61 75 6c 74 00 42 |.......default.B| 115 | # 31a 45 47 49 4e 2b 84 c7 67 |EGIN...g| 116 | # Query thread_id=4 exec_time=0 error_code=0 117 | SET TIMESTAMP=1596178234/*!*/; 118 | BEGIN 119 | /*!*/; 120 | # at 802 121 | #200731 6:50:34 server id 1 end_log_pos 882 CRC32 0xe69ac0ed 122 | # Position Timestamp Type Master ID Size Master Pos Flags 123 | # 322 3a bf 23 5f 1d 01 00 00 00 50 00 00 00 72 03 00 00 80 00 124 | # 335 38 49 4e 53 45 52 54 20 49 4e 54 4f 20 60 62 6f |8INSERT.INTO..bo| 125 | # 345 78 65 72 63 72 61 62 60 20 28 60 74 69 74 6c 65 |xercrab....title| 126 | # 355 60 29 20 56 41 4c 55 45 53 20 28 27 68 61 68 68 |...VALUES...hahh| 127 | # 365 68 68 68 68 68 68 68 27 29 ed c0 9a e6 |hhhhhhh......| 128 | # Rows_query 129 | # INSERT INTO `boxercrab` (`title`) VALUES ('hahhhhhhhhh') 130 | # at 882 131 | #200731 6:50:34 server id 1 end_log_pos 940 CRC32 0x52aedc71 132 | # Position Timestamp Type Master ID Size Master Pos Flags 133 | # 372 3a bf 23 5f 13 01 00 00 00 3a 00 00 00 ac 03 00 00 00 00 134 | # 385 6d 00 00 00 00 00 01 00 07 64 65 66 61 75 6c 74 |m........default| 135 | # 395 00 09 62 6f 78 65 72 63 72 61 62 00 02 03 0f 02 |..boxercrab.....| 136 | # 3a5 a0 00 00 71 dc ae 52 |...q..R| 137 | # Table_map: `default`.`boxercrab` mapped to number 109 138 | # at 940 139 | #200731 6:50:34 server id 1 end_log_pos 992 CRC32 0x0f192fe9 140 | # Position Timestamp Type Master ID Size Master Pos Flags 141 | # 3ac 3a bf 23 5f 1e 01 00 00 00 34 00 00 00 e0 03 00 00 00 00 142 | # 3bf 6d 00 00 00 00 00 01 00 02 00 02 ff fc 01 00 00 |m...............| 143 | # 3cf 00 0b 68 61 68 68 68 68 68 68 68 68 68 e9 2f 19 |..hahhhhhhhhh...| 144 | # 3df 0f |.| 145 | # Write_rows: table id 109 flags: STMT_END_F 146 | 147 | BINLOG ' 148 | Or8jXx0BAAAAUAAAAHIDAACAADhJTlNFUlQgSU5UTyBgYm94ZXJjcmFiYCAoYHRpdGxlYCkgVkFM 149 | VUVTICgnaGFoaGhoaGhoaGgnKe3AmuY= 150 | Or8jXxMBAAAAOgAAAKwDAAAAAG0AAAAAAAEAB2RlZmF1bHQACWJveGVyY3JhYgACAw8CoAAAcdyu 151 | Ug== 152 | Or8jXx4BAAAANAAAAOADAAAAAG0AAAAAAAEAAgAC//wBAAAAC2hhaGhoaGhoaGho6S8ZDw== 153 | '/*!*/; 154 | ### INSERT INTO `default`.`boxercrab` 155 | ### SET 156 | ### @1=1 /* INT meta=0 nullable=0 is_null=0 */ 157 | ### @2='hahhhhhhhhh' /* VARSTRING(160) meta=160 nullable=0 is_null=0 */ 158 | # at 992 159 | #200731 6:50:34 server id 1 end_log_pos 1023 CRC32 0xf575c76c 160 | # Position Timestamp Type Master ID Size Master Pos Flags 161 | # 3e0 3a bf 23 5f 10 01 00 00 00 1f 00 00 00 ff 03 00 00 00 00 162 | # 3f3 0d 00 00 00 00 00 00 00 6c c7 75 f5 |........l.u.| 163 | # Xid = 13 164 | COMMIT/*!*/; 165 | # at 1023 166 | #200731 6:50:34 server id 1 end_log_pos 1070 CRC32 0x128d71f7 167 | # Position Timestamp Type Master ID Size Master Pos Flags 168 | # 3ff 3a bf 23 5f 04 01 00 00 00 2f 00 00 00 2e 04 00 00 00 00 169 | # 412 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 170 | # 422 6e 2e 30 30 30 30 30 32 f7 71 8d 12 |n.000002.q..| 171 | # Rotate to mysql_bin.000002 pos: 4 172 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 173 | DELIMITER ; 174 | # End of log file 175 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 176 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 177 | -------------------------------------------------------------------------------- /tests/events/14_user_var/dump.txt: -------------------------------------------------------------------------------- 1 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; 2 | /*!50003 SET @OLD_COMPLETION_TYPE=@@COMPLETION_TYPE,COMPLETION_TYPE=0*/; 3 | DELIMITER /*!*/; 4 | # at 4 5 | #200730 15:22:48 server id 1 end_log_pos 123 CRC32 0x995ec6cd 6 | # Position Timestamp Type Master ID Size Master Pos Flags 7 | # 4 c8 e5 22 5f 0f 01 00 00 00 77 00 00 00 7b 00 00 00 00 00 8 | # 17 04 00 35 2e 37 2e 33 30 2d 6c 6f 67 00 00 00 00 |..5.7.30.log....| 9 | # 27 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 10 | # 37 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| 11 | # 47 00 00 00 00 c8 e5 22 5f 13 38 0d 00 08 00 12 00 |.........8......| 12 | # 57 04 04 04 04 12 00 00 5f 00 04 1a 08 00 00 00 08 |................| 13 | # 67 08 08 02 00 00 00 0a 0a 0a 2a 2a 00 12 34 00 01 |.............4..| 14 | # 77 cd c6 5e 99 |....| 15 | # Start: binlog v 4, server v 5.7.30-log created 200730 15:22:48 at startup 16 | ROLLBACK/*!*/; 17 | BINLOG ' 18 | yOUiXw8BAAAAdwAAAHsAAAAAAAQANS43LjMwLWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 19 | AAAAAAAAAAAAAAAAAADI5SJfEzgNAAgAEgAEBAQEEgAAXwAEGggAAAAICAgCAAAACgoKKioAEjQA 20 | Ac3GXpk= 21 | '/*!*/; 22 | # at 123 23 | #200730 15:22:48 server id 1 end_log_pos 154 CRC32 0xc0c31f5a 24 | # Position Timestamp Type Master ID Size Master Pos Flags 25 | # 7b c8 e5 22 5f 23 01 00 00 00 1f 00 00 00 9a 00 00 00 80 00 26 | # 8e 00 00 00 00 00 00 00 00 5a 1f c3 c0 |........Z...| 27 | # Previous-GTIDs 28 | # [empty] 29 | # at 154 30 | #200730 15:22:48 server id 1 end_log_pos 219 CRC32 0x367f5c31 31 | # Position Timestamp Type Master ID Size Master Pos Flags 32 | # 9a c8 e5 22 5f 21 01 00 00 00 41 00 00 00 db 00 00 00 00 00 33 | # ad 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 34 | # bd 02 01 00 00 00 00 00 00 00 02 00 00 00 00 00 00 |................| 35 | # cd 00 00 01 00 00 00 00 00 00 00 31 5c 7f 36 |..........1..6| 36 | # GTID last_committed=0 sequence_number=1 rbr_only=no 37 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:1'/*!*/; 38 | # at 219 39 | #200730 15:22:48 server id 1 end_log_pos 357 CRC32 0x8bcd8ffb 40 | # Position Timestamp Type Master ID Size Master Pos Flags 41 | # db c8 e5 22 5f 02 01 00 00 00 8a 00 00 00 65 01 00 00 04 00 42 | # ee 12 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 43 | # fe 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 44 | # 10e 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 45 | # 11e 00 64 65 66 61 75 6c 74 00 44 52 4f 50 20 54 41 |.default.DROP.TA| 46 | # 12e 42 4c 45 20 49 46 20 45 58 49 53 54 53 20 60 62 |BLE.IF.EXISTS..b| 47 | # 13e 6f 78 65 72 63 72 61 62 60 20 2f 2a 20 67 65 6e |oxercrab.....gen| 48 | # 14e 65 72 61 74 65 64 20 62 79 20 73 65 72 76 65 72 |erated.by.server| 49 | # 15e 20 2a 2f fb 8f cd 8b |.......| 50 | # Query thread_id=18 exec_time=0 error_code=0 51 | use `default`/*!*/; 52 | SET TIMESTAMP=1596122568/*!*/; 53 | SET @@session.pseudo_thread_id=18/*!*/; 54 | SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; 55 | SET @@session.sql_mode=1436549152/*!*/; 56 | SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; 57 | /*!\C utf8 *//*!*/; 58 | SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=45/*!*/; 59 | SET @@session.lc_time_names=0/*!*/; 60 | SET @@session.collation_database=DEFAULT/*!*/; 61 | DROP TABLE IF EXISTS `boxercrab` /* generated by server */ 62 | /*!*/; 63 | # at 357 64 | #200730 15:22:48 server id 1 end_log_pos 422 CRC32 0x6d0308f7 65 | # Position Timestamp Type Master ID Size Master Pos Flags 66 | # 165 c8 e5 22 5f 21 01 00 00 00 41 00 00 00 a6 01 00 00 00 00 67 | # 178 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 68 | # 188 02 02 00 00 00 00 00 00 00 02 01 00 00 00 00 00 |................| 69 | # 198 00 00 02 00 00 00 00 00 00 00 f7 08 03 6d |.............m| 70 | # GTID last_committed=1 sequence_number=2 rbr_only=no 71 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:2'/*!*/; 72 | # at 422 73 | #200730 15:22:48 server id 1 end_log_pos 719 CRC32 0xc27db9a9 74 | # Position Timestamp Type Master ID Size Master Pos Flags 75 | # 1a6 c8 e5 22 5f 02 01 00 00 00 29 01 00 00 cf 02 00 00 00 00 76 | # 1b9 12 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 77 | # 1c9 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 78 | # 1d9 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 79 | # 1e9 00 64 65 66 61 75 6c 74 00 43 52 45 41 54 45 20 |.default.CREATE.| 80 | # 1f9 54 41 42 4c 45 20 60 62 6f 78 65 72 63 72 61 62 |TABLE..boxercrab| 81 | # 209 60 20 28 0a 20 20 20 20 60 69 64 60 20 49 4e 54 |.........id..INT| 82 | # 219 20 55 4e 53 49 47 4e 45 44 20 41 55 54 4f 5f 49 |.UNSIGNED.AUTO.I| 83 | # 229 4e 43 52 45 4d 45 4e 54 2c 0a 20 20 20 20 60 73 |NCREMENT.......s| 84 | # 239 74 72 60 20 56 41 52 43 48 41 52 28 34 30 29 20 |tr..VARCHAR.40..| 85 | # 249 4e 4f 54 20 4e 55 4c 4c 2c 0a 20 20 20 20 60 69 |NOT.NULL.......i| 86 | # 259 6e 74 60 20 49 4e 54 20 4e 4f 54 20 4e 55 4c 4c |nt..INT.NOT.NULL| 87 | # 269 2c 0a 20 20 20 20 60 64 65 63 60 20 44 45 43 49 |.......dec..DECI| 88 | # 279 4d 41 4c 28 31 30 2c 20 34 29 20 4e 4f 54 20 4e |MAL.10..4..NOT.N| 89 | # 289 55 4c 4c 2c 0a 20 20 20 20 50 52 49 4d 41 52 59 |ULL......PRIMARY| 90 | # 299 20 4b 45 59 20 28 60 69 64 60 29 0a 29 45 4e 47 |.KEY...id....ENG| 91 | # 2a9 49 4e 45 3d 49 6e 6e 6f 44 42 20 44 45 46 41 55 |INE.InnoDB.DEFAU| 92 | # 2b9 4c 54 20 43 48 41 52 53 45 54 3d 75 74 66 38 6d |LT.CHARSET.utf8m| 93 | # 2c9 62 34 a9 b9 7d c2 |b4....| 94 | # Query thread_id=18 exec_time=0 error_code=0 95 | SET TIMESTAMP=1596122568/*!*/; 96 | CREATE TABLE `boxercrab` ( 97 | `id` INT UNSIGNED AUTO_INCREMENT, 98 | `str` VARCHAR(40) NOT NULL, 99 | `int` INT NOT NULL, 100 | `dec` DECIMAL(10, 4) NOT NULL, 101 | PRIMARY KEY (`id`) 102 | )ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 103 | /*!*/; 104 | # at 719 105 | #200730 15:22:48 server id 1 end_log_pos 784 CRC32 0x1dbd15c3 106 | # Position Timestamp Type Master ID Size Master Pos Flags 107 | # 2cf c8 e5 22 5f 21 01 00 00 00 41 00 00 00 10 03 00 00 00 00 108 | # 2e2 01 e3 e2 a4 ee b6 dc 11 ea 8b cf 02 42 ac 15 00 |............B...| 109 | # 2f2 02 03 00 00 00 00 00 00 00 02 02 00 00 00 00 00 |................| 110 | # 302 00 00 03 00 00 00 00 00 00 00 c3 15 bd 1d |..............| 111 | # GTID last_committed=2 sequence_number=3 rbr_only=no 112 | SET @@SESSION.GTID_NEXT= 'e3e2a4ee-b6dc-11ea-8bcf-0242ac150002:3'/*!*/; 113 | # at 784 114 | #200730 15:22:48 server id 1 end_log_pos 869 CRC32 0x4437bfcc 115 | # Position Timestamp Type Master ID Size Master Pos Flags 116 | # 310 c8 e5 22 5f 02 01 00 00 00 55 00 00 00 65 03 00 00 08 00 117 | # 323 12 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 118 | # 333 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 119 | # 343 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 120 | # 353 00 64 65 66 61 75 6c 74 00 42 45 47 49 4e cc bf |.default.BEGIN..| 121 | # 363 37 44 |7D| 122 | # Query thread_id=18 exec_time=0 error_code=0 123 | SET TIMESTAMP=1596122568/*!*/; 124 | BEGIN 125 | /*!*/; 126 | # at 869 127 | # at 901 128 | # at 952 129 | # at 1003 130 | # at 1049 131 | #200730 15:22:48 server id 1 end_log_pos 901 CRC32 0x98f8870c 132 | # Position Timestamp Type Master ID Size Master Pos Flags 133 | # 365 c8 e5 22 5f 05 01 00 00 00 20 00 00 00 85 03 00 00 00 00 134 | # 378 02 01 00 00 00 00 00 00 00 0c 87 f8 98 |.............| 135 | # Intvar 136 | SET INSERT_ID=1/*!*/; 137 | #200730 15:22:48 server id 1 end_log_pos 952 CRC32 0x648fc14f 138 | # Position Timestamp Type Master ID Size Master Pos Flags 139 | # 385 c8 e5 22 5f 0e 01 00 00 00 33 00 00 00 b8 03 00 00 00 00 140 | # 398 05 00 00 00 76 61 6c 5f 73 00 00 21 00 00 00 09 |....val.s.......| 141 | # 3a8 00 00 00 74 65 73 74 20 62 6c 6f 67 4f c1 8f 64 |...test.blogO..d| 142 | # User_var 143 | SET @`val_s`:=_utf8 0x7465737420626C6F67 COLLATE `utf8_general_ci`/*!*/; 144 | #200730 15:22:48 server id 1 end_log_pos 1003 CRC32 0x8c9e3cb3 145 | # Position Timestamp Type Master ID Size Master Pos Flags 146 | # 3b8 c8 e5 22 5f 0e 01 00 00 00 33 00 00 00 eb 03 00 00 00 00 147 | # 3cb 05 00 00 00 76 61 6c 5f 69 00 02 21 00 00 00 08 |....val.i.......| 148 | # 3db 00 00 00 64 00 00 00 00 00 00 00 00 b3 3c 9e 8c |...d............| 149 | # User_var 150 | SET @`val_i`:=100/*!*/; 151 | #200730 15:22:48 server id 1 end_log_pos 1049 CRC32 0xa18847dd 152 | # Position Timestamp Type Master ID Size Master Pos Flags 153 | # 3eb c8 e5 22 5f 0e 01 00 00 00 2e 00 00 00 19 04 00 00 00 00 154 | # 3fe 05 00 00 00 76 61 6c 5f 64 00 04 21 00 00 00 04 |....val.d.......| 155 | # 40e 00 00 00 03 02 81 00 dd 47 88 a1 |........G..| 156 | # User_var 157 | SET @`val_d`:=1.00/*!*/; 158 | #200730 15:22:48 server id 1 end_log_pos 1206 CRC32 0x613d0b41 159 | # Position Timestamp Type Master ID Size Master Pos Flags 160 | # 419 c8 e5 22 5f 02 01 00 00 00 9d 00 00 00 b6 04 00 00 00 00 161 | # 42c 12 00 00 00 00 00 00 00 07 00 00 24 00 00 00 00 |................| 162 | # 43c 00 00 01 20 00 a0 55 00 00 00 00 06 03 73 74 64 |......U......std| 163 | # 44c 04 21 00 21 00 2d 00 0c 01 64 65 66 61 75 6c 74 |.........default| 164 | # 45c 00 64 65 66 61 75 6c 74 00 49 4e 53 45 52 54 20 |.default.INSERT.| 165 | # 46c 49 4e 54 4f 20 60 62 6f 78 65 72 63 72 61 62 60 |INTO..boxercrab.| 166 | # 47c 20 28 60 73 74 72 60 2c 20 60 69 6e 74 60 2c 20 |...str....int...| 167 | # 48c 60 64 65 63 60 29 20 56 41 4c 55 45 53 20 28 40 |.dec...VALUES...| 168 | # 49c 76 61 6c 5f 73 2c 20 40 76 61 6c 5f 69 2c 20 40 |val.s...val.i...| 169 | # 4ac 76 61 6c 5f 64 29 41 0b 3d 61 |val.d.A..a| 170 | # Query thread_id=18 exec_time=0 error_code=0 171 | SET TIMESTAMP=1596122568/*!*/; 172 | INSERT INTO `boxercrab` (`str`, `int`, `dec`) VALUES (@val_s, @val_i, @val_d) 173 | /*!*/; 174 | # at 1206 175 | #200730 15:22:48 server id 1 end_log_pos 1237 CRC32 0x5f897806 176 | # Position Timestamp Type Master ID Size Master Pos Flags 177 | # 4b6 c8 e5 22 5f 10 01 00 00 00 1f 00 00 00 d5 04 00 00 00 00 178 | # 4c9 53 00 00 00 00 00 00 00 06 78 89 5f |S........x..| 179 | # Xid = 83 180 | COMMIT/*!*/; 181 | # at 1237 182 | #200730 15:22:48 server id 1 end_log_pos 1284 CRC32 0xc9932a1a 183 | # Position Timestamp Type Master ID Size Master Pos Flags 184 | # 4d5 c8 e5 22 5f 04 01 00 00 00 2f 00 00 00 04 05 00 00 00 00 185 | # 4e8 04 00 00 00 00 00 00 00 6d 79 73 71 6c 5f 62 69 |........mysql.bi| 186 | # 4f8 6e 2e 30 30 30 30 30 32 1a 2a 93 c9 |n.000002....| 187 | # Rotate to mysql_bin.000002 pos: 4 188 | SET @@SESSION.GTID_NEXT= 'AUTOMATIC' /* added by mysqlbinlog */ /*!*/; 189 | DELIMITER ; 190 | # End of log file 191 | /*!50003 SET COMPLETION_TYPE=@OLD_COMPLETION_TYPE*/; 192 | /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; 193 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------