Skip to content

Commit a74edc4

Browse files
committed
MDEV-38068 Query doesn't delete all data it should after update to 11.8.4
a fix for MDEV-15990 has unintentionally added HA_EXTRA_REMEMBER_POS/HA_EXTRA_RESTORE_POS on the code path for normal, not versioned, deletes. Let's restore the old logic. followup for 8001679
1 parent c3398a0 commit a74edc4

File tree

3 files changed

+37
-6
lines changed

3 files changed

+37
-6
lines changed

mysql-test/main/delete.result

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,22 @@ id
779779
Warnings:
780780
Warning 4207 Index hints are ignored because they are incompatible with RETURNING clause
781781
drop table t2;
782-
#
783782
# End of 11.4 test
784783
#
784+
# MDEV-38068 Query doesn't delete all data it should after update to 11.8.4
785+
#
786+
create table t1 (id varchar(32), d1 char, key (id), key (d1)) engine=myisam;
787+
insert into t1 values ('1','A'), ('1','B'), ('1','C'), ('2','D'), ('2','E');
788+
select count(*) from t1;
789+
count(*)
790+
5
791+
need "range" below
792+
explain delete from t1 where id = '1';
793+
id select_type table type possible_keys key key_len ref rows Extra
794+
1 SIMPLE t1 range id id 131 NULL 3 Using where
795+
delete from t1 where id = '1';
796+
select count(*) from t1;
797+
count(*)
798+
2
799+
drop table t1;
800+
# End of 11.8 test

mysql-test/main/delete.test

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,18 @@ DELETE FROM t2 ignore index(primary) ORDER BY (id) LIMIT 2 RETURNING id;
825825

826826
drop table t2;
827827

828-
--echo #
829828
--echo # End of 11.4 test
829+
830830
--echo #
831+
--echo # MDEV-38068 Query doesn't delete all data it should after update to 11.8.4
832+
--echo #
833+
create table t1 (id varchar(32), d1 char, key (id), key (d1)) engine=myisam;
834+
insert into t1 values ('1','A'), ('1','B'), ('1','C'), ('2','D'), ('2','E');
835+
select count(*) from t1;
836+
--echo need "range" below
837+
explain delete from t1 where id = '1';
838+
delete from t1 where id = '1';
839+
select count(*) from t1;
840+
drop table t1;
841+
842+
--echo # End of 11.8 test

sql/sql_delete.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,18 +312,20 @@ template <bool replace>
312312
int TABLE::delete_row(bool treat_versioned)
313313
{
314314
int err= 0;
315+
bool remembered_pos= false;
315316
uchar *del_buf= record[replace ? 1 : 0];
316317
bool delete_row= !treat_versioned
317318
|| in_use->lex->vers_conditions.delete_history
318319
|| versioned(VERS_TRX_ID)
319320
|| !vers_end_field()->is_max(
320321
vers_end_field()->ptr_in_record(del_buf));
321322

322-
if ((err= file->extra(HA_EXTRA_REMEMBER_POS)))
323-
return err;
324-
325323
if (!delete_row)
326324
{
325+
if ((err= file->extra(HA_EXTRA_REMEMBER_POS)))
326+
return err;
327+
remembered_pos= true;
328+
327329
if (replace)
328330
{
329331
store_record(this, record[2]);
@@ -370,7 +372,8 @@ int TABLE::delete_row(bool treat_versioned)
370372
if (delete_row)
371373
err= file->ha_delete_row(del_buf);
372374

373-
(void) file->extra(HA_EXTRA_RESTORE_POS);
375+
if (remembered_pos)
376+
(void) file->extra(HA_EXTRA_RESTORE_POS);
374377

375378
return err;
376379
}

0 commit comments

Comments
 (0)