1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Extra tests for MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"

Adding tests demonstrating that columns:
- mysql.innodb_table_stats.last_update
- mysql.innodb_index_stats.last_update

contain sane values close to NOW() rathar than a garbage.

Tests cover these three underlying TIMESTAMP data formats:

- MariaDB Field_timestamp0 - UINT4 based
  Like in a MariaDB native installation running with mysql56_temporal_format=0

- MariaDB Field_timestampf - BINARY(4) based, with UNSIGNED_FLAG
  Like in a MariaDB native installation running with mysql56_temporal_format=1

- MySQL-alike Field_timestampf - BINARY(4) based, without UNSIGNED_FLAG
  Like with a MariaDB server running over a MySQL-5.6 directory
  (e.g. during a migragion).
This commit is contained in:
Alexander Barkov
2023-05-26 16:04:02 +04:00
parent 9edb1a5ce3
commit 03a9366c73
4 changed files with 182 additions and 0 deletions

View File

@ -28,4 +28,57 @@ XA END 'test';
XA ROLLBACK 'test';
DROP TABLE t1;
--echo #
--echo # MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
--echo #
# The following tests demonstrate that these columns:
# - innodb_table_stats.last_update
# - innodb_index_stats.last_update
# have sane values close to NOW(), rather than any garbage,
# with all TIMESTAMP formats.
--echo #
--echo # Testing a non-default format: Field_timestamp0 - UINT4 based
--echo #
SET @@global.mysql56_temporal_format=0;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP;
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP;
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
DROP TABLE t1;
--echo #
--echo # Now as the table t1 is dropped, expect no statistics
--echo #
SELECT * FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT * FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
--echo #
--echo # Testing with the default format: Field_timestampf - BINARY(4) based with the UNSIGNED_FLAG
--echo #
SET @@global.mysql56_temporal_format=1;
ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP;
ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP;
SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
WHERE database_name='test' AND table_name='t1';
SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
WHERE database_name='test' AND table_name='t1' AND stat_name='size';
DROP TABLE t1;
--echo # End of 10.6 tests