Issue Details (XML | Word | Printable)

Key: DERBY-1204
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Yip Ng
Reporter: Daniel John Debrunner
Votes: 1
Watchers: 0
Operations

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

CREATE TRIGGER with an INSERT action statement with multiple rows and a referenced column throws a StringIndexOutOfBoundsException

Created: 12/Apr/06 07:56 AM   Updated: 10/Aug/09 08:46 PM
Return to search
Component/s: SQL
Affects Version/s: 10.1.2.1, 10.2.1.6
Fix Version/s: 10.2.2.0, 10.3.1.4

Time Tracking:
Not Specified

File Attachments:
  Size
Text File Licensed for inclusion in ASF works derby1204-10.2-diff01.txt 2006-12-04 11:42 PM Yip Ng 9 kB
Text File Licensed for inclusion in ASF works derby1204-10.2-stat01.txt 2006-12-04 11:42 PM Yip Ng 0.3 kB
Text File Licensed for inclusion in ASF works derby1204-trunk-diff01.txt 2006-11-13 06:12 PM Yip Ng 7 kB
Text File Licensed for inclusion in ASF works derby1204-trunk-diff02.txt 2006-12-04 02:54 AM Yip Ng 9 kB
Text File Licensed for inclusion in ASF works derby1204-trunk-stat01.txt 2006-11-13 06:12 PM Yip Ng 0.3 kB
Text File Licensed for inclusion in ASF works derby1204-trunk-stat02.txt 2006-12-04 02:54 AM Yip Ng 0.3 kB
XML File Licensed for inclusion in ASF works XMLFile1.angosso1.xml 2009-08-10 08:46 PM Mbiama Assogo Roger 21 kB
XML File Licensed for inclusion in ASF works XMLFile1.angosso1.xml 2009-08-10 08:46 PM Mbiama Assogo Roger 21 kB

Resolution Date: 05/Dec/06 04:41 AM


 Description  « Hide
These triggers succeed

create trigger tgood after insert on x
for each statement mode db2sql insert into x values (666), (999), (333);

create trigger tgood after insert on x
referencing new as n
for each row mode db2sql insert into x values (n.x);

create trigger tgood after insert on x
referencing new as n
for each row mode db2sql insert into x values (333), (999), (333)

This one fails

create trigger tgood after insert on x
referencing new as n
for each row mode db2sql insert into x values (n.x), (999), (333);

Test cases will be added to triggerGeneral under this bug number.

java.lang.StringIndexOutOfBoundsException: String index out of range: -3
at java.lang.String.substring(String.java:1444)
at org.apache.derby.impl.sql.compile.CreateTriggerNode.bindReferencesClause(CreateTriggerNode.java:421)
at org.apache.derby.impl.sql.compile.CreateTriggerNode.bind(CreateTriggerNode.java:258)
at org.apache.derby.impl.sql.GenericStatement.prepMinion(GenericStatement.java:344)
at org.apache.derby.impl.sql.GenericStatement.prepare(GenericStatement.java:118)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.prepareInternalStatement(GenericLanguageConnectionContext.java:713)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:560)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(EmbedStatement.java:507)
at org.apache.derby.impl.tools.ij.ij.executeImmediate(ij.java:313)
at org.apache.derby.impl.tools.ij.utilMain.doCatch(utilMain.java:433)
at org.apache.derby.impl.tools.ij.utilMain.go(utilMain.java:310)
at org.apache.derby.impl.tools.ij.Main.go(Main.java:203)
at org.apache.derby.impl.tools.ij.Main.mainCore(Main.java:169)
at org.apache.derby.impl.tools.ij.Main14.main(Main14.java:55)
at org.apache.derby.tools.ij.main(ij.java:60)


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #393337 Wed Apr 12 00:11:49 UTC 2006 djd DERBY-1204 (test only) Add additional test cases that shows what work and what doesn't
with trigger actions and INSERT clauses with multiple rows. Test case that shows the 1204
bug is commented out.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out

Repository Revision Date User Message
ASF #482358 Mon Dec 04 21:07:25 UTC 2006 bpendleton DERBY-1204: TRIGGER with multi-row INSERT action throws OutOfBounds exception

This patch was contributed by Yip Ng (yipng168@gmail.com)

The statement fails because the bindReferencesClause() method in
CreateTriggerNode did not filter those column references that are not
relevent to the conversion processing for OLD/NEW transition variables.
The above trigger action will have the following parse tree: (roughly)

              InsertNode
                 |
              UnionNode
               / \
        UnionNode RowRSNode
         / \ |
RowRSNode RowRSNode NumericConstantNode
      | | |
 ColRef NumericConstantNode 333
      | |
     n.i 999

Note that the CollectNodesVisitor collects *ALL* the ColumnReferences in
the trigger action. In the above case, it returned 3 column references
nodes. One in the top level Union node, one in top level Union Node's
left child which it is also an UnionNode and the last one is found in
the RowResultSetNode.

The UnionNodes will have a copy of the CRs from its left child and
those CRs will not have its beginOffset set which indicates they are
not relevant for the conversion processing here, so the corrective
action here is to skip these entries.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out

Repository Revision Date User Message
ASF #482484 Tue Dec 05 04:39:58 UTC 2006 bpendleton DERBY-1204: TRIGGER with multi-row INSERT action throws OutOfBounds exception

This patch was contributed by Yip Ng (yipng168@gmail.com)

This change contains DERBY1204-10.2-diff01.txt, which merges the changes
for DERBY-1204 from the trunk to the 10.2 branch.
Files Changed
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
MODIFY /db/derby/code/branches/10.2/java/testing/org/apache/derbyTesting/functionTests/tests/lang/triggerGeneral.sql
MODIFY /db/derby/code/branches/10.2/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java

Repository Revision Date User Message
ASF #483521 Thu Dec 07 16:22:54 UTC 2006 rhillegas DERBY-2129: Add a couple more bug fixes to the release notes. These were ported to the 10.2 branch in the last week: DERBY-1231, DERBY-2131, DERBY-1204.
Files Changed
MODIFY /db/derby/code/branches/10.2/RELEASE-NOTES.html