1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

ALTER TABLE and replication should convert old row_end timestamps to new timestamp range

MDEV-32188 make TIMESTAMP use whole 32-bit unsigned range

- Added --update-history option to mariadb-dump to change 2038
  row_end timestamp to 2106.
- Updated ALTER TABLE ... to convert old row_end timestamps to
  2106 timestamp for tables created before MariaDB 11.4.0.
- Fixed bug in CHECK TABLE where we wrongly suggested to USE REPAIR
  TABLE when ALTER TABLE...FORCE is needed.
- mariadb-check printed table names that where used with REPAIR TABLE but
  did not print table names used with ALTER TABLE or with name repair.
  Fixed by always printing a table that is fixed if --silent is not
  used.
- Added TABLE::vers_fix_old_timestamp() that will change max-timestamp
  for versioned tables when replication from a pre-11.4.0 server.

A few test cases changed. This is caused by:
- CHECK TABLE now prints 'Please do ALTER TABLE... instead of
  'Please do REPAIR TABLE' when there is a problem with the information
  in the .frm file (for example a very old frm file).
- mariadb-check now prints repaired table names.
- mariadb-check also now prints nicer error message in case ALTER TABLE
  is needed to repair a table.
This commit is contained in:
Monty
2023-12-19 17:51:23 +02:00
committed by Sergei Golubchik
parent c4cad8d50c
commit 24c57165d5
37 changed files with 438 additions and 110 deletions

View File

@ -210,6 +210,7 @@ Tables_in_test
t1
v1
test.t1 OK
#mysql50#v-1 OK
show tables;
Tables_in_test
t1
@ -226,6 +227,7 @@ set @@character_set_client=@save_character_set_client;
set @@character_set_results=@save_character_set_client;
set @@collation_connection=@save_collation_connection;
mysqlcheck --fix-table-names --databases test
#mysql50#@ OK
SET NAMES utf8;
SHOW TABLES;
Tables_in_test
@ -258,6 +260,8 @@ TRIGGER_CATALOG TRIGGER_SCHEMA TRIGGER_NAME EVENT_MANIPULATION EVENT_OBJECT_CATA
def #mysql50#a@b tr1 INSERT def #mysql50#a@b #mysql50#c@d 1 NULL SET NEW.a = 10 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
def #mysql50#a@b tr2 INSERT def #mysql50#a@b t1 1 NULL SET NEW.a = 100 * NEW.a ROW BEFORE NULL NULL OLD NEW NULL root@localhost latin1 latin1_swedish_ci latin1_swedish_ci
mysqlcheck --fix-db-names --fix-table-names --all-databases
#mysql50#a@b OK
#mysql50#c@d OK
USE `a@b`;
SELECT * FROM INFORMATION_SCHEMA.TRIGGERS
WHERE TRIGGER_SCHEMA="a@b" ORDER BY trigger_name;
@ -281,11 +285,13 @@ USE test;
#
drop table if exists `#mysql50#t1-1`;
create table `#mysql50#t1-1` (a int) engine=myisam;
#mysql50#t1-1 OK
show tables like 't1-1';
Tables_in_test (t1-1)
t1-1
drop table `t1-1`;
create table `#mysql50#t1-1` (a int) engine=myisam;
#mysql50#t1-1 OK
show tables like 't1-1';
Tables_in_test (t1-1)
t1-1
@ -328,27 +334,27 @@ CHECK TABLE bug47205 FOR UPGRADE;
Table Op Msg_type Msg_text
test.bug47205 check error Table rebuild required. Please do "ALTER TABLE `bug47205` FORCE" or dump/reload to fix it!
# Running mysqlcheck to check and upgrade
test.bug47205
error : Table rebuild required. Please do "ALTER TABLE `bug47205` FORCE" or dump/reload to fix it!
test.bug47205 Needs upgrade with ALTER TABLE FORCE
Repairing tables
`test`.`bug47205` OK
# Table should now be ok
CHECK TABLE bug47205 FOR UPGRADE;
Table Op Msg_type Msg_text
test.bug47205 check status OK
DROP TABLE bug47205;
#
# Test 3: MyISAM - REPAIR supported
# Test 3: MyISAM - ALTER TABLE supported
# Use an old FRM that will require upgrade
# Should indicate that REPAIR TABLE is needed
# Should indicate that ALTER TABLE is needed
CHECK TABLE bug47205 FOR UPGRADE;
Table Op Msg_type Msg_text
test.bug47205 check error Upgrade required. Please do "REPAIR TABLE `bug47205`" or dump/reload to fix it!
test.bug47205 check error Table rebuild required. Please do "ALTER TABLE `bug47205` FORCE" or dump/reload to fix it!
# Running mysqlcheck to check and upgrade
test.bug47205 Needs upgrade
test.bug47205 Needs upgrade with ALTER TABLE FORCE
Repairing tables
test.bug47205 OK
`test`.`bug47205` OK
# Table should now be ok
CHECK TABLE bug47205 FOR UPGRADE;
Table Op Msg_type Msg_text
@ -370,12 +376,12 @@ create table `t.2`(a varchar(20) primary key) default character set utf8 collate
flush table `t.2`;
mysqlcheck --check-upgrade --auto-repair test
test.t.1 OK
test.t.2
error : Table rebuild required. Please do "ALTER TABLE `t.2` FORCE" or dump/reload to fix it!
test.t.3 Needs upgrade
test.t.2 Needs upgrade with ALTER TABLE FORCE
test.t.3 Needs upgrade with ALTER TABLE FORCE
Repairing tables
test.t.3 OK
`test`.`t.2` OK
`test`.`t.3` OK
check table `t.1`, `t.2`, `t.3`;
Table Op Msg_type Msg_text
test.t.1 check status OK
@ -411,13 +417,14 @@ drop view v1;
create table t1(a int);
mysqlcheck --process-views --check-upgrade --auto-repair test
test.t1 OK
test.v1 Needs upgrade
test.v1 Needs upgrade with REPAIR
Repairing views
test.v1 OK
drop view v1;
drop table t1;
create table `#mysql50#t1``1` (a int) engine=myisam;
#mysql50#t1`1 OK
show tables;
Tables_in_test
t1`1