Skip to content

[YSQL] Deleted row count reported is incorrect when using DELETE with USING clause #25305

@kmuthukk

Description

@kmuthukk

Jira Link: DB-14503

Description

Test Case:

create extension if not exists pgcrypto;
drop table if exists funds;

-- creating a table with duplicate values for k.
create table funds(k integer, u uuid default gen_random_uuid(), v integer);

insert into funds(k, v) values (1, 1);
insert into funds(k, v) values (1, 1);
insert into funds(k, v) values (1, 1);

-- deduplicate rows with same k. Keep only the one with largest value of u.
delete from funds f1
      using funds f2
   where f1.u < f2.u and f1.k = f2.k;

select * from funds;

We would expect the DELETE to delete two rows, but it seems to be reporting an incorrect number of rows (3).

delete from funds f1
      using funds f2
   where f1.u < f2.u and f1.k = f2.k;
DELETE 3

It seems to be just a reporting mistake. Because table does seem to have 1 remaining row left and only 2 rows seem to have gotten deleted.

select * from funds;
 k |                  u                   | v
---+--------------------------------------+---
 1 | bb7e5ed3-2cf8-45be-8c3e-e568c7e8b4ba | 1

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions