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
Inconsistent behaviour of the NEW context variable in AFTER UPDATE OR DELETE triggers [CORE6144] #6393
Comments
Commented by: @livius2 Both cases should raise an error but not your definded exception. |
Commented by: @dyemanov Karol, IIRC it's documented that unavailable context in universal triggers is returned as NULL. |
Modified by: @dyemanovassignee: Dmitry Yemanov [ dimitr ] |
Commented by: @mrotteveel @dmitry The documentation says: "In DELETE triggers, references to the NEW variables are invalid and will throw an exception" (see https://www.firebirdsql.org/file/documentation/reference_manuals/fblangref25-en/html/fblangref25-psql-triggers.html#fblangref25-psql-oldnew). I haven't found references for UPDATE OR DELETE triggers. |
Commented by: @dyemanov That is for simple triggers. However, see README.universal_triggers:
|
Commented by: @ilya071294 I have prepared a PR: |
Modified by: @dyemanovassignee: Dmitry Yemanov [ dimitr ] => Ilya Eremin [ ilya071294 ] |
Modified by: @dyemanovstatus: Open [ 1 ] => Resolved [ 5 ] resolution: Fixed [ 1 ] Fix Version: 3.0.5 [ 10885 ] Fix Version: 4.0 Beta 2 [ 10888 ] |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Resolved [ 5 ] QA Status: No test => Done successfully |
Modified by: @pavel-zotovstatus: Resolved [ 5 ] => Closed [ 6 ] |
Commented by: Sean Leyne (seanleyne) Can we have details on the new functionality? |
Submitted by: @ilya071294
Assigned to: @ilya071294
Script to reproduce:
create table test (id integer not null primary key);
commit;
insert into test (id) values (1);
commit;
alter table test add v integer default 1 not null;
commit;
insert into test (id) values (2);
create exception ex 'Failed';
set term ^;
create or alter trigger test_null for test
after update or delete
as
begin
if (new.v is not null) then -- new.v should be NULL if the trigger runs after DELETE statement
exception ex;
end^
set term ;^
commit;
delete from test where id = 2; -- no errors
delete from test where id = 1; -- trigger throws exception
I am working on a PR.
Commits: 0c5b177 0b63117 eb31af0
The text was updated successfully, but these errors were encountered: