[MDEV-21340] stored function can see half-updated table Created: 2019-12-17  Updated: 2023-04-27

Status: Open
Project: MariaDB Server
Component/s: Data Manipulation - Delete, Data Manipulation - Update, Stored routines
Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4
Fix Version/s: 10.4

Type: Bug Priority: Major
Reporter: Sergei Golubchik Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Normally if the table is being updated/deleted and selected from, execution stores rowids
in a temp table first (used_key_is_modified, multi-update, query_plan.using_io_buffer, whatever).

But accessing the table-to-be-updated (or deleted) from a stored function bypasses this check:

create table t1 (i int);
insert t1 values (1), (1);
create function summ () returns int return (select sum(i) from t1);
update t1 set i=summ();
--echo # both rows should be 2
select * from t1;
update t1 set i=1;
delete from t1 where i+1=summ();
--echo # should be empty
select * from t1;
drop table t1;
drop function summ;


Generated at Thu Feb 08 09:06:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.