Github user DaveBirdsall commented on a diff in the pull request: https://github.com/apache/incubator-trafodion/pull/1253#discussion_r142539058 --- 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(); --- End diff -- Thanks. Will add.
---