[
https://issues.apache.org/jira/browse/TRAFODION-1610?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16189936#comment-16189936
]
ASF GitHub Bot commented on TRAFODION-1610:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1253#discussion_r142454172
--- Diff: core/sql/generator/GenRelUpdate.cpp ---
@@ -292,8 +292,85 @@ static short genUpdExpr(
return 0;
}
-static short genUpdConstraintExpr(Generator *generator)
+// Used to generate update or insert constraint expressions for update
operators
+static short genUpdConstraintExpr(Generator * generator,
+ ItemExpr * constrTree,
+ const ValueIdSet & constraintColumns,
+ ValueIdArray & targetRecExprArray,
+ ex_expr ** targetExpr /* out */)
{
+ ExpGenerator * expGen = generator->getExpGenerator();
+
+ // The Attributes for the table columns refer to the old values of the
column.
+ // The constraints must operate on the new values, though. So we must do
a
+ // switcheroo on the Attributes for the update expression. The target
value IDs
+ // come from targetRecExprArray.
+
+ ValueIdList savedSourceVIDlist;
+ NAList<Attributes*> savedSourceAttrsList(generator->wHeap());
+
+ for (ValueId sourceValId = constraintColumns.init();
+ constraintColumns.next(sourceValId);
+ constraintColumns.advance(sourceValId))
+ {
+ NAColumn * sourceCol =
((IndexColumn*)sourceValId.getItemExpr())->getNAColumn();
+ ValueId targetValId;
+ NAColumn *targetCol = NULL;
--- End diff --
Just noticed something that could be improved. It would be better to set
targetCol to NULL just inside the "for" loop, so that the "if" at line 329
would not be taken. It's not an observable bug, though, because even if on the
second time around, targetCol were pointing to an NAColumn from the first time
around, the other comparisons at line 330 onward would come out false.
Nevertheless, making the change would make it cleaner.
> Generate constraint expression for update/merge commands
> --------------------------------------------------------
>
> Key: TRAFODION-1610
> URL: https://issues.apache.org/jira/browse/TRAFODION-1610
> Project: Apache Trafodion
> Issue Type: Sub-task
> Components: sql-cmp
> Reporter: Selvaganesan Govindarajan
> Assignee: David Wayne Birdsall
>
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)