Another thing that I noticed today was, in this loop that is a part of 
getTriggerActionString

     for (ColumnReference ref : refs)
{
TableName tableName = ref.getQualifiedTableName();
                              int tableBeginOffset = tableName.getBeginOffset() 
- actionOffset;

I suppose this loop should work for Status and ID when it is called by the 
action node and only for status when it is called by the when node. But when I 
print out the value of columnReference, I notice that for action node, I only 
get ID in my output
though I was expecting both ID and Status. And I get Status for when node, 
which I is what I expect.

Yes, this code is quite complex to understand.

The "refs" collection comes from the parse tree node, which is called
"actionStmt" in this subroutine, but which is really an arbitrary
node in the parse tree which is constructed by the parser.

        SortedSet<ColumnReference> refs = getTransitionVariables(
                actionStmt, oldReferencingName, newReferencingName);

So the first time we call this, actionStmt is indeed the action
statement for our trigger, which is:

        UPDATE table SET result='completed' WHERE id=newrow.id

In this parse tree, the only reference to a column in "newrow" is
"newrow.id", which is why ID is the only column that comes back
in the "refs" collection.

The second time we call this, actionStmt is pointing to the parse
tree for the WHEN clause, which is:

        WHEN (newrow.status='d')

In this parse tree, the only reference to a column in "newrow" is
"newrow.status", which is why STATUS is the only column that comes
back in the "refs" collection the second time.

The argument

        int[] referencedCols,

that is passed to DataDictionaryImpl.getTriggerActionString() also contains
the STATUS column; this is because elsewhere we have analyzed:

        ... AFTER UPDATE OF status ON ...

and determined that STATUS is the column that "fires" the trigger.

bryan

Reply via email to