Skip to content

Commit 060c0e3

Browse files
MDEV-23699 Assertion failed in ha_tina::delete_row
When REPAIRing a CSV table, the CSV engine marks the table as having no rows in the case that there are rows only in memory but not yet written to disk. In this case, there's actually nothing to repair, since nothing exists on disk; make REPAIR idempotent for CSV tables.
1 parent 3c38c37 commit 060c0e3

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

mysql-test/main/repair.result

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,14 @@ test.t1 repair status OK
251251
set myisam_repair_threads = default;
252252
drop table t1;
253253
# End of 10.2 tests
254+
#
255+
# Start of 10.11 tests
256+
#
257+
USE test;
258+
CREATE TEMPORARY TABLE t(c INT NOT NULL) ENGINE=CSV;
259+
INSERT INTO t VALUES(1);
260+
REPAIR TABLE t;
261+
Table Op Msg_type Msg_text
262+
test.t repair status OK
263+
DELETE FROM t;
264+
# End of 10.11 tests

mysql-test/main/repair.test

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,14 @@ set myisam_repair_threads = default;
269269
drop table t1;
270270

271271
--echo # End of 10.2 tests
272+
273+
--echo #
274+
--echo # Start of 10.11 tests
275+
--echo #
276+
USE test;
277+
CREATE TEMPORARY TABLE t(c INT NOT NULL) ENGINE=CSV;
278+
INSERT INTO t VALUES(1);
279+
REPAIR TABLE t;
280+
DELETE FROM t;
281+
282+
--echo # End of 10.11 tests

storage/csv/ha_tina.cc

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,10 +1515,10 @@ int ha_tina::rnd_end()
15151515
check_opt The options for repair. We do not use it currently.
15161516
15171517
DESCRIPTION
1518-
If the file is empty, change # of rows in the file and complete recovery.
1519-
Otherwise, scan the table looking for bad rows. If none were found,
1518+
Scan the table looking for bad rows. If none were found,
15201519
we mark file as a good one and return. If a bad row was encountered,
15211520
we truncate the datafile up to the last good row.
1521+
If the file is empty, then do nothing and complete recovery.
15221522
15231523
TODO: Make repair more clever - it should try to recover subsequent
15241524
rows (after the first bad one) as well.
@@ -1536,10 +1536,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt)
15361536

15371537
/* empty file */
15381538
if (!share->saved_data_file_length)
1539-
{
1540-
share->rows_recorded= 0;
15411539
goto end;
1542-
}
15431540

15441541
/* Don't assert in field::val() functions */
15451542
table->use_all_columns();

0 commit comments

Comments
 (0)