MDEV-35849: index records in a wrong order

page_cur_dtuple_cmp(): Take DESC index fields into account also when
comparing a NULL value in a ROW_FORMAT≠REDUNDANT record.

Thanks to Elena Stepanova for finding this bug.
This commit is contained in:
Marko Mäkelä 2025-01-15 07:31:33 +02:00
parent 3761a7fec8
commit 18dbeae1b8
3 changed files with 22 additions and 1 deletions

View file

@ -1996,4 +1996,14 @@ a
c c
DROP TABLE t1; DROP TABLE t1;
# End of 10.8 tests # End of 10.8 tests
#
# MDEV-35849: index records in a wrong order
#
CREATE TABLE t (pk INT PRIMARY KEY, a VARCHAR(1), KEY (a DESC)) ENGINE=InnoDB;
INSERT INTO t VALUES (1,NULL),(2,'x');
CHECK TABLE t;
Table Op Msg_type Msg_text
test.t check status OK
DROP TABLE t;
# End of 11.8 tests
ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci; ALTER DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_uca1400_ai_ci;

View file

@ -1229,6 +1229,17 @@ DROP TABLE t1;
--echo # End of 10.8 tests --echo # End of 10.8 tests
--echo #
--echo # MDEV-35849: index records in a wrong order
--echo #
CREATE TABLE t (pk INT PRIMARY KEY, a VARCHAR(1), KEY (a DESC)) ENGINE=InnoDB;
INSERT INTO t VALUES (1,NULL),(2,'x');
CHECK TABLE t;
DROP TABLE t;
--echo # End of 11.8 tests
--disable_query_log --disable_query_log
call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd."); call mtr.add_suppression("InnoDB: Tablespace .* was not found at .*t[12].ibd.");

View file

@ -606,7 +606,7 @@ static int page_cur_dtuple_cmp(const dtuple_t &dtuple, const rec_t *rec,
{ {
if (i < cur_field || dtuple.fields[i].len == UNIV_SQL_NULL) if (i < cur_field || dtuple.fields[i].len == UNIV_SQL_NULL)
continue; continue;
ret= 1; ret= field->descending ? -1 : 1;
break; break;
} }
} }