Details
-
Type:
Bug
-
Status: Open (View Workflow)
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 5.5, 10.1, 10.2, 10.3, 10.4
-
Component/s: Data Manipulation - Delete, Data Manipulation - Update, Stored routines
-
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; |