db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-6383) Update trigger defined on one column fires on update of other columns
Date Fri, 08 Nov 2013 19:10:17 GMT

    [ https://issues.apache.org/jira/browse/DERBY-6383?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13817585#comment-13817585
] 

Mamta A. Satoor commented on DERBY-6383:
----------------------------------------

Investigating more about drop column and its impact on statement level trigger defined at
the table level might be DERBY-4988(ALTER TABLE DROP COLUMN should make use of information
in SYSTRIGGERS to detect column used through REFERENCING clause to find trigger dependencies).
A simple test case below which works correctly in trunk through 10.7 but not in 10.6(and probably
earlier codelines)
java org.apache.derby.tools.ij
connect 'jdbc:derby:db1;create=true';
CREATE TABLE DERBY_6368_TAB1 (X INTEGER, Y INTEGER);
CREATE TABLE DERBY_6368_TAB2 (X INTEGER, Y INTEGER);
INSERT INTO  DERBY_6368_TAB1 VALUES(1, 2);

-- statement trigger defined at table level
CREATE TRIGGER t3 AFTER UPDATE ON DERBY_6368_TAB1 REFERENCING old table AS old INSERT INTO
DERBY_6368_TAB2 SELECT * FROM old;

--1 row
UPDATE DERBY_6368_TAB1 SET x = x + 1;
select count(*) from DERBY_6368_TAB2;
delete from DERBY_6368_TAB2;

-- following should drop the statement trigger defined above but it does not do that in 10.6
and earlier codelines
ALTER TABLE DERBY_6368_TAB1 DROP COLUMN Y;
ALTER TABLE DERBY_6368_TAB2 DROP COLUMN Y;
select * from sys.systriggers;

UPDATE DERBY_6368_TAB1 SET x = x + 1;
--count should be 0 but in 10.6 and earlier, the update fires the trigger since the trigger
didn't get dropped
select count(*) from DERBY_6368_TAB2;

> Update trigger defined on one column fires on update of other columns
> ---------------------------------------------------------------------
>
>                 Key: DERBY-6383
>                 URL: https://issues.apache.org/jira/browse/DERBY-6383
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions: 10.7.1.4, 10.8.1.2, 10.9.1.0, 10.10.1.1
>            Reporter: Knut Anders Hatlen
>            Assignee: Mamta A. Satoor
>             Fix For: 10.9.2.2, 10.10.1.3, 10.11.0.0
>
>         Attachments: DERBY6383_patch1_diff.txt, DERBY6383_patch2_diff.txt, DERBY6383_patch3_diff.txt,
d6383.sql, derby_for_Embedded_40Changes10_7testTriggers.log, derby_for_Embedded_40Changes10_9testDisposableStatisticsExplicit.log,
error-stacktrace_for_Embedded_40Changes10_7testTriggers.out, error-stacktrace_for_Embedded_40Changes10_9testDisposableStatisticsExplicit.out,
releaseNote.html, releaseNote.html, runall.out
>
>
> I see this problem on 10.8 and higher. To reproduce, create a database with a trigger
like this:
> connect 'jdbc:derby:trigdb;create=true';
> create table t1(x int, y int);
> create table t2(x int, y int);
> create trigger tr after update of x on t1 referencing old table as old insert into t2
select * from old;
> Then run dblook on the database, and you'll see the following output:
> -- ----------------------------------------------
> -- DDL Statements for triggers
> -- ----------------------------------------------
> CREATE TRIGGER "APP"."TR" AFTER UPDATE OF "X", "Y" ON "APP"."T1" REFERENCING OLD_TABLE
AS OLD FOR EACH STATEMENT insert into t2 select * from old;
> Notice that the DDL creates an update trigger for columns X and Y, whereas the original
trigger was defined on column X only.
> I see the expected DDL on 10.7.1.1.



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Mime
View raw message