Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions mysql-test/suite/binlog/r/binlog_signedness_parse.result
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
ALTER DATABASE test CHARACTER SET latin1 COLLATE latin1_swedish_ci;
RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;
#
# Test 1: Non-numeric column between two numeric columns does not
# consume a signedness bit (signed INT, CHAR, unsigned INT)
#
CREATE TABLE t1(c_signed INT, c_char CHAR(10), c_unsigned INT UNSIGNED);
INSERT INTO t1 VALUES(-1, 'x', 1);
# Columns(INT,
# CHAR(10) CHARSET latin1 COLLATE latin1_swedish_ci,
# INT UNSIGNED)
DROP TABLE t1;
RESET MASTER;
#
# Test 2: Byte boundary — 8 signed numerics then a non-numeric then an
# unsigned numeric. The non-numeric must not shift the bit
# cursor into the second byte prematurely.
#
CREATE TABLE t1(
c1 TINYINT, c2 TINYINT, c3 TINYINT, c4 TINYINT,
c5 TINYINT, c6 TINYINT, c7 TINYINT, c8 TINYINT,
c_text TEXT,
c9 TINYINT UNSIGNED);
INSERT INTO t1(c1) VALUES(1);
# Columns(TINYINT,
# TINYINT,
# TINYINT,
# TINYINT,
# TINYINT,
# TINYINT,
# TINYINT,
# TINYINT,
# TEXT CHARSET latin1 COLLATE latin1_swedish_ci,
# TINYINT UNSIGNED)
DROP TABLE t1;
RESET MASTER;
#
# Test 3: Multiple non-numeric columns between numeric columns across
# a byte boundary
#
CREATE TABLE t1(
c1 TINYINT UNSIGNED, c2 TINYINT UNSIGNED,
c3 TINYINT UNSIGNED, c4 TINYINT UNSIGNED,
c5 TINYINT UNSIGNED, c6 TINYINT UNSIGNED,
c7 TINYINT UNSIGNED, c8 TINYINT UNSIGNED,
c_blob BLOB, c_varchar VARCHAR(100),
c9 TINYINT, c10 TINYINT UNSIGNED);
INSERT INTO t1(c1) VALUES(1);
# Columns(TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# TINYINT UNSIGNED,
# BLOB,
# VARCHAR(100) CHARSET latin1 COLLATE latin1_swedish_ci,
# TINYINT,
# TINYINT UNSIGNED)
DROP TABLE t1;
RESET MASTER;
SET GLOBAL binlog_row_metadata = NO_LOG;
ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci;
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ c_datetime DATETIME, c_datetime_f DATETIME(3),
c_timestamp TIMESTAMP NOT NULL DEFAULT NOW(),
c_timestamp_f TIMESTAMP(3) DEFAULT "2017-1-1 10:10:10");
INSERT INTO t1(c_year) VALUES(2017);
# Columns(YEAR,
# Columns(YEAR UNSIGNED,
# DATE,
# TIME,
# TIME(3),
Expand Down
70 changes: 70 additions & 0 deletions mysql-test/suite/binlog/t/binlog_signedness_parse.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
################################################################################
# Regression tests for parse_signedness() in log_event.cc.
#
# The old implementation (upstream) pushed all bits from every byte into a flat
# vector without regard to column type. The new implementation iterates over
# column metadata and only consumes a bit for columns where is_numeric_type()
# returns true, skipping non-numeric columns.
#
# Tests focus on:
# 1. YEAR is treated as a numeric type and always shown UNSIGNED.
# 2. Non-numeric columns interspersed between numeric columns do not consume
# a signedness bit, so the second numeric column reads the correct bit.
# 3. Correct behavior at byte boundaries when non-numeric columns appear
# between the 8th and 9th numeric column.
################################################################################
--source include/have_binlog_format_row.inc
--source include/test_db_charset_latin1.inc

RESET MASTER;
SET GLOBAL binlog_row_metadata = MINIMAL;

--let $MYSQLD_DATADIR= `select @@datadir`
--let $binlog_file= $MYSQLD_DATADIR/master-bin.000001

--echo #
--echo # Test 1: Non-numeric column between two numeric columns does not
--echo # consume a signedness bit (signed INT, CHAR, unsigned INT)
--echo #
CREATE TABLE t1(c_signed INT, c_char CHAR(10), c_unsigned INT UNSIGNED);
INSERT INTO t1 VALUES(-1, 'x', 1);
--source suite/binlog/include/print_optional_metadata.inc

DROP TABLE t1;
RESET MASTER;

--echo #
--echo # Test 2: Byte boundary — 8 signed numerics then a non-numeric then an
--echo # unsigned numeric. The non-numeric must not shift the bit
--echo # cursor into the second byte prematurely.
--echo #
CREATE TABLE t1(
c1 TINYINT, c2 TINYINT, c3 TINYINT, c4 TINYINT,
c5 TINYINT, c6 TINYINT, c7 TINYINT, c8 TINYINT,
c_text TEXT,
c9 TINYINT UNSIGNED);
INSERT INTO t1(c1) VALUES(1);
--source suite/binlog/include/print_optional_metadata.inc

DROP TABLE t1;
RESET MASTER;

--echo #
--echo # Test 3: Multiple non-numeric columns between numeric columns across
--echo # a byte boundary
--echo #
CREATE TABLE t1(
c1 TINYINT UNSIGNED, c2 TINYINT UNSIGNED,
c3 TINYINT UNSIGNED, c4 TINYINT UNSIGNED,
c5 TINYINT UNSIGNED, c6 TINYINT UNSIGNED,
c7 TINYINT UNSIGNED, c8 TINYINT UNSIGNED,
c_blob BLOB, c_varchar VARCHAR(100),
c9 TINYINT, c10 TINYINT UNSIGNED);
INSERT INTO t1(c1) VALUES(1);
--source suite/binlog/include/print_optional_metadata.inc

DROP TABLE t1;
RESET MASTER;

SET GLOBAL binlog_row_metadata = NO_LOG;
--source include/test_db_charset_restore.inc
Loading