[MDEV-30099] DELETE .. RETURNING does not always return metadata Created: 2022-11-25  Updated: 2023-11-28

Status: Open
Project: MariaDB Server
Component/s: Data Manipulation - Delete
Affects Version/s: 10.3, 10.4, 10.5, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11
Fix Version/s: 10.4, 10.5, 10.6

Type: Bug Priority: Major
Reporter: Elena Stepanova Assignee: Rucha Deodhar
Resolution: Unresolved Votes: 0
Labels: None


 Description   

In some cases DELETE ... RETURNING which does not delete any rows does not return metadata. In other cases it does. Apparently it is not the expected behavior/

create table t (a int);
--enable_metadata
delete from t returning *;
delete from t where 0 returning *;
delete from t where not exists (select * from mysql.user) returning *;
select * from t where 0;
 
# Cleanup
--disable_metadata
drop table t;

10.3 162c1505

delete from t returning *;
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def	test	t	t	a	a	3	11	0	Y	32768	0	63
a
delete from t where 0 returning *;
delete from t where not exists (select * from mysql.user) returning *;
select * from t where 0;
Catalog	Database	Table	Table_alias	Column	Column_alias	Type	Length	Max length	Is_null	Flags	Decimals	Charsetnr
def	test	t	t	a	a	3	11	0	Y	32768	0	63
a

So, DELETE without a WHERE clause returns metadata, even though the table is empty. But DELETE with an impossible condition does not.
SELECT however returns metadata with the same impossible conditions.


Generated at Thu Feb 08 10:13:39 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.