Files
percona-toolkit/t/pt-online-schema-change/samples/PT-2418-timestamp_null_issue.sql
Marek Knappe 4a9a4bb903 PT-2418: Fix column data loss during RENAME COLUMN operations
The pt-online-schema-change tool was not properly handling RENAME COLUMN
syntax (MySQL 8.0+), causing renamed columns to be excluded from the
data copy operation. This resulted in NULL values for renamed columns
after the schema change.

The issue was in the find_renamed_cols() function which only supported
CHANGE COLUMN syntax but not RENAME COLUMN syntax. Added support for
RENAME COLUMN parsing to properly detect column renames and include
them in the common_cols list for data copying.

Fixes: PT-2418
2025-07-02 12:45:00 +10:00

19 lines
680 B
SQL

-- Test case for timestamp NULL issue during column rename
-- This reproduces the issue where 't' column values become NULL after CHANGE COLUMN
DROP DATABASE IF EXISTS test;
CREATE DATABASE test;
USE test;
CREATE TABLE `joinit` (
`i` int(11) NOT NULL AUTO_INCREMENT,
`s` varchar(64) DEFAULT NULL,
`t1` time DEFAULT NULL,
`g` int(11) NOT NULL,
PRIMARY KEY (`i`)
);
-- Insert initial data with timestamps
INSERT INTO joinit VALUES (NULL, uuid(), time(now()), (FLOOR( 1 + RAND( ) *60 )));
INSERT INTO joinit SELECT NULL, uuid(), time(now()), (FLOOR( 1 + RAND( ) *60 )) FROM joinit;
INSERT INTO joinit SELECT NULL, uuid(), time(now()), (FLOOR( 1 + RAND( ) *60 )) FROM joinit;