You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Knut Anders Hatlen (JIRA)" <ji...@apache.org> on 2013/10/23 14:17:42 UTC
[jira] [Updated] (DERBY-6383) dblook gives wrong column list for
update trigger that references transition table
[ https://issues.apache.org/jira/browse/DERBY-6383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Knut Anders Hatlen updated DERBY-6383:
--------------------------------------
Attachment: d6383.sql
This is actually more serious than dblook showing incorrect information. The trigger that was defined on update of column X does in fact fire on update of column Y as well. The attached script d6383.sql reproduces the bug:
{noformat}
ij> connect 'jdbc:derby:memory:db;create=true';
ij> create table t1(x int, y int);
0 rows inserted/updated/deleted
ij> create table t2(x int, y int);
0 rows inserted/updated/deleted
ij> insert into t1 values (1,2);
1 row inserted/updated/deleted
ij> -- create a trigger on update of T1(X)
create trigger t1 after update of x on t1 referencing old table as old insert into t2 select * from old;
0 rows inserted/updated/deleted
ij> -- update T1(Y), should not fire the trigger
update t1 set y = y + 1;
1 row inserted/updated/deleted
ij> -- trigger should not fire, so T2 should be empty
select * from t2;
X |Y
-----------------------
1 |2
1 row selected
{noformat}
With 10.7.1.1 and earlier the final SELECT query returns no rows, which means the trigger had not fired. This is the correct behaviour, I believe.
With 10.7.1.4 and higher, the SELECT query returns one row (as seen above), which means the trigger had fired.
> dblook gives wrong column list for update trigger that references transition table
> ----------------------------------------------------------------------------------
>
> 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
> Attachments: d6383.sql
>
>
> 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)