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

MDEV-35866 CHECK TABLE get number of rows without HA_STATS_RECORDS_IS_EXACT

Call ha_rnd_init followed by two ha_rnd_next's to find whether there
is more than one row.
This commit is contained in:
Yuchen Pei
2025-04-15 11:17:57 +10:00
parent d52ddae57b
commit 495d96709f
3 changed files with 83 additions and 2 deletions

View File

@ -115,3 +115,29 @@ create sequence s;
update s set minimum_value=500, maximum_value=200;
ERROR HY000: Storage engine SEQUENCE of the table `test`.`s` doesn't have this option
drop sequence s;
#
# MDEV-35866 mariadb-check does not return warning for incorrect sequence with engine InnoDB
#
CREATE SEQUENCE s engine=innodb;
ALTER TABLE s sequence=0;
delete from s;
FLUSH TABLES;
CHECK TABLE s;
Table Op Msg_type Msg_text
test.s check Error Fewer than one row in the table
test.s check error Corrupt
DROP SEQUENCE s;
CREATE SEQUENCE s engine=innodb;
CHECK TABLE s;
Table Op Msg_type Msg_text
test.s check status OK
DROP SEQUENCE s;
CREATE SEQUENCE s engine=innodb;
ALTER TABLE s sequence=0;
insert into s values (2,1,9223372036854775806,1,1,1000,0,0);
FLUSH TABLES;
CHECK TABLE s;
Table Op Msg_type Msg_text
test.s check Warning More than one row in the table
test.s check status OK
DROP SEQUENCE s;

View File

@ -137,3 +137,36 @@ create sequence s;
--error ER_ILLEGAL_HA
update s set minimum_value=500, maximum_value=200;
drop sequence s;
--echo #
--echo # MDEV-35866 mariadb-check does not return warning for incorrect sequence with engine InnoDB
--echo #
--source include/have_innodb.inc
# Fewer than one row
let $datadir=`select @@datadir`;
CREATE SEQUENCE s engine=innodb;
copy_file $datadir/test/s.frm $datadir/test/s1.frm;
ALTER TABLE s sequence=0;
delete from s;
FLUSH TABLES;
remove_file $datadir/test/s.frm;
move_file $datadir/test/s1.frm $datadir/test/s.frm;
CHECK TABLE s;
DROP SEQUENCE s;
# Just one row, check ok
CREATE SEQUENCE s engine=innodb;
CHECK TABLE s;
DROP SEQUENCE s;
# More than one row
let $datadir=`select @@datadir`;
CREATE SEQUENCE s engine=innodb;
copy_file $datadir/test/s.frm $datadir/test/s1.frm;
ALTER TABLE s sequence=0;
insert into s values (2,1,9223372036854775806,1,1,1000,0,0);
FLUSH TABLES;
remove_file $datadir/test/s.frm;
move_file $datadir/test/s1.frm $datadir/test/s.frm;
CHECK TABLE s;
DROP SEQUENCE s;