mirror of
https://github.com/MariaDB/server.git
synced 2025-07-27 18:02:13 +03:00
MDEV-25444: mysql --binary-mode is not able to replay some mysqlbinlog outputs
Changes on top of Sachin’s patch. Specifically: 1) Refined the parsing break condition to only change the parser’s behavior for parsing strings in binary mode (behavior of \0 outside of strings is unchanged). 2) Prefixed binary_zero_insert.test with ‘mysql_’ to more clearly associate the purpose of the test. 3) As the input of the test contains binary zeros (0x5c00), different text editors can visualize this sequence differently, and Github would not display it at all. Therefore, the input itself was consolidated into the test and created out of hex sequences to make it easier to understand what is happening. 4) Extended test to validate that the rows which correspond to the INSERTS with 0x5c00 have the correct binary zero data. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
This commit is contained in:
54
mysql-test/main/mysql_binary_zero_insert.result
Normal file
54
mysql-test/main/mysql_binary_zero_insert.result
Normal file
@ -0,0 +1,54 @@
|
||||
# Note: This test assumes NO_BACKSLASH_ESCAPES is not set in SQL_MODE.
|
||||
##############################
|
||||
# Setup
|
||||
##############################
|
||||
#
|
||||
# Saving old state
|
||||
#
|
||||
set @old_sql_mode= @@global.SQL_MODE;
|
||||
set @@global.SQL_MODE= "";
|
||||
#
|
||||
# Create table for data entry
|
||||
#
|
||||
CREATE TABLE tb (`id` int(11) NOT NULL AUTO_INCREMENT,`cb` longblob DEFAULT NULL, PRIMARY KEY (`id`)) AUTO_INCREMENT=1 DEFAULT CHARSET=latin1;
|
||||
RESET MASTER;
|
||||
##############################
|
||||
# Test Case
|
||||
##############################
|
||||
#
|
||||
# \0 (0x5c00 in binary) should be allowed in data strings if
|
||||
# --binary-mode is enabled.
|
||||
#
|
||||
FOUND 10 /\x5c\x00/ in binary_zero_inserts.sql
|
||||
# MYSQL --binary-mode test < MYSQL_TMP_DIR/binary_zero_inserts.sql
|
||||
#
|
||||
# Ensure a row exists from each insert statement with a \0
|
||||
#
|
||||
SELECT COUNT(*)=8 from tb;
|
||||
COUNT(*)=8
|
||||
1
|
||||
#
|
||||
# Ensure that the binary zero was parsed and exists in the row data
|
||||
# Note: We only look for 00 because the 5c only served as an escape
|
||||
# in parsing.
|
||||
#
|
||||
# MYSQL_DUMP test tb --hex-blob | grep INSERT > MYSQL_TMP_DIR/dump.sql
|
||||
FOUND 10 /00/ in dump.sql
|
||||
#
|
||||
# Ensure data consistency on mysqlbinlog replay
|
||||
#
|
||||
FLUSH LOGS;
|
||||
# MYSQL_BINLOG MYSQLD_DATADIR/binlog_file > MYSQL_TMP_DIR/binlog_zeros.sql
|
||||
FOUND 10 /\x5c\x00/ in binlog_zeros.sql
|
||||
# MYSQL --binary-mode test < MYSQL_TMP_DIR/binlog_zeros.sql
|
||||
# Table checksum is equivalent before and after binlog replay
|
||||
#
|
||||
# A \0 should still be treated as end-of-query in binary mode.
|
||||
#
|
||||
# MYSQL --binary-mode -B test < MYSQL_TMP_DIR/binary_zero_eoq.sql
|
||||
##############################
|
||||
# Cleanup
|
||||
##############################
|
||||
SET @@global.sql_mode= @old_sql_mode;
|
||||
drop table tb;
|
||||
RESET MASTER;
|
Reference in New Issue
Block a user