Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting multiple rows from a view with triggers may cause triggers to fire just once #6838

Closed
dyemanov opened this issue Jun 2, 2021 · 0 comments

Comments

@dyemanov
Copy link
Member

dyemanov commented Jun 2, 2021

If a view has BEFORE/AFTER DELETE triggers and returns multiple rows, and DELETE statement is run against this view with expectation to affect multiple rows, view triggers may be executed just one time instead of per-record.

Test case:

create table t (id int);
create view v as select id from t;
create table log (txt varchar(10));

set term ^;
create trigger trg for v before delete as begin insert into log values ('deleted'); end^
set term ;^

insert into t values (1);
insert into t values (2);
commit;

select count(*) from t;

                COUNT 
===================== 
                    2 

select count(*) from v;

                COUNT 
===================== 
                    2 

delete from v;
select * from log;

TXT        
========== 
deleted    

-- Should be two records!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants