Issue Details (XML | Word | Printable)

Key: DERBY-1613
Type: Bug Bug
Status: Closed Closed
Resolution: Duplicate
Priority: Major Major
Assignee: Yip Ng
Reporter: Mamta A. Satoor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Derby

A trigger does not get invalidated when the view used by it is dropped

Created: 31/Jul/06 06:15 AM   Updated: 13/Dec/07 09:05 AM
Return to search
Component/s: SQL
Affects Version/s: None
Fix Version/s: 10.2.1.6

Time Tracking:
Not Specified

Issue Links:
Blocker
 
Reference
 

Resolution Date: 25/Aug/06 08:33 PM


 Description  « Hide
I created a trigger which does a select into another table using the rows from a view. I had expected the trigger to get invalidated when the view is dropped. But that is not happening. Trigger continues to fire with old plan which gets it rows from the view. This happens in all the codelines starting with 10.0. Once the database is shutdown and restarted, and the next time the trigger gets fired, it throws the correct exception for view not found.

Following is the ij script to reproduce the problem

connect 'jdbc:derby:c:/dellater/db100;create=true' user 'mamta1' as mamta1;
create table t11TriggerTest (c111 int not null primary key, c112 int);
insert into t11TriggerTest values(1,1);
insert into t11TriggerTest values(2,2);

-- create a view based on table t11TriggerTest
create view v21ViewTest as select * from mamta1.t11TriggerTest;

-- get ready to create a trigger. Trigger is created on t31TriggerTest and it inserts into t32TriggerTest
create table t31TriggerTest (c311 int);
create table t32TriggerTest (c321 int);
create trigger tr31t31TriggerTest after insert on t31TriggerTest for each statement mode db2sql
   insert into t32TriggerTest values (select c111 from mamta1.v21ViewTest where c112=1);

-- try an insert which will fire the trigger
insert into t31TriggerTest values(1);
select * from t31TriggerTest;
-- we know the trigger got fired if there is one row in t32TriggerTest
select * from t32TriggerTest;

-- drop the view used by the trigger.
drop view v21ViewTest;

-- try an insert which would cause insert trigger to fire. The insert trigger should have failed because view doesn't
-- exist anymore.
insert into t31TriggerTest values(1);
-- no error from the insert trigger fired by insert statement above
select * from t31TriggerTest;
-- insert trigger got fired because there are 2 rows in the following table now
select * from t32TriggerTest;


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Deepa Remesh added a comment - 31/Jul/06 03:19 PM
I think this issue is related to DERBY-1435. I had filed DERBY-1435 for the case where we drop a table referenced by a trigger. And then found similar problem when we drop procedures/functions referenced by trigger. In these cases, trigger firing does not throw any exception if we re-execute a previously executed statement. If database is restarted, we get the correct exception indicating trigger is invalid. I found this is the case with the Mamta's repro for views too. I haven't yet looked to see if these issues can be solved by a single solution. So I am just linking this issue to DERBY-1435. Maybe we need to update the summary for DERBY-1435 to something more general.

Yip Ng added a comment - 23/Aug/06 06:15 PM
This is a duplicate to DERBY-1621.

Yip Ng added a comment - 25/Aug/06 08:33 PM
DERBY-1621 resolves this issue.

Andrew McIntyre added a comment - 13/Dec/07 09:05 AM
This issue has been resolved for over a year with no further movement. Closing.