db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-4984) ALTER TABLE DROP COLUMN may leave triggers invalid even if they are not using the column getting dropped.
Date Mon, 19 Mar 2012 16:18:40 GMT

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

Mamta A. Satoor commented on DERBY-4984:

If we do not have a customer request for backporting DERBY-4984, then I would rather us not
backport this jira. The primary reason is we did work on several trigger related jiras around
the same time and some of those jiras depended on changes to system tables. Those different
jiras worked on quite a few common classes and around the same code and hence I am worried
that we might backport something which depends on codes which should not be backported. 

> ALTER TABLE DROP COLUMN may leave triggers invalid even if they are not using the column
getting dropped.
> ---------------------------------------------------------------------------------------------------------
>                 Key: DERBY-4984
>                 URL: https://issues.apache.org/jira/browse/DERBY-4984
>             Project: Derby
>          Issue Type: Bug
>          Components: SQL
>    Affects Versions:,,,,,,,,,,
>            Reporter: Mamta A. Satoor
>            Assignee: Mamta A. Satoor
>              Labels: derby_backport_reject_10_5, derby_backport_reject_10_6, derby_backport_reject_10_7,
>             Fix For:,
> While doing testing for DERBY-4887, I found a case where ALTER TABLE DROP COLUMN will
leave triggers in invalid state even if those triggers are not using the column getting dropped.
>        element_id INTEGER NOT NULL, 
>        altered_id VARCHAR(30) NOT NULL
> ); 
> insert into tab values(1,'aa');
> -- Create a trigger against the table 
>  AFTER UPDATE OF altered_id ON tab 
>   SELECT newt.altered_id from tab;
> --Drop the first column in the table. This will cause the column positions to be recalculated
within the table
> alter table tab drop column element_id; 
> --mytrig is still looking for column altered_id at position 2 but drop column has changed
it's position within the table to 1
> update tab set altered_id='bb';
> As shown in the example above, table "TAB" only has 2 columns. The trigger "MYTRIG" uses
the 2nd column in it's trigger action through the REFERENCING clause. During trigger action
sql parsing, every column referenced through REFERENCING clause gets transformed into a reference
to the column through it's column position in the trigger table(this change to look for columns
based on their column positions rather than the name went in as revision 397959 with following
commit comments DERBY-1258 Change the generated code for a new/old column in a row trigger
to access columns by position and not name to avoid the case-insensitive name lookup specified
by JDBC.) When in the script above, we drop the column in position 1, the trigger "MYTRIG"
ends up becoming invalid because column being used in the trigger action is no more in column
position 2.
> One possible solution is to regenerate the SPSDescriptor associated with the trigger
action for all the triggers defined on the table whose column is getting dropped. We could
be little smarter and only regenerate the SPSDescriptor for the triggers who use the REFERENCING
clause. But we need to do more testing to make sure that triggers without REFERENCING clause
do not get impacted by a drop of column which is not the last column of the table. This optimization
of recognizing the right triggers may not be worth it since performance may not be that big
a criteria for an ALTER TABLE DROP COLUMN which should be a rare operation in a production
> An interim solution to this problem is obviously to drop and recreate the triggers

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message