[TRAFODION-2901] add explanation
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/b9334761 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/b9334761 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/b9334761 Branch: refs/heads/master Commit: b933476147dbc2eb699c9eb7be56950c4697459a Parents: c5ef360 Author: Guhaiyan <[email protected]> Authored: Wed Jun 20 02:32:11 2018 +0000 Committer: Guhaiyan <[email protected]> Committed: Wed Jun 20 02:32:11 2018 +0000 ---------------------------------------------------------------------- core/sql/optimizer/RelExpr.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/b9334761/core/sql/optimizer/RelExpr.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/RelExpr.cpp b/core/sql/optimizer/RelExpr.cpp index 14b841c..d203ec1 100644 --- a/core/sql/optimizer/RelExpr.cpp +++ b/core/sql/optimizer/RelExpr.cpp @@ -13342,12 +13342,17 @@ void GenericUpdate::pushdownCoveredExpr(const ValueIdSet &outputExpr, predicatesOnParent, &localExprs); +/*to fix jira 18-20180111-2901 + *For query " insert into to t1 select seqnum(seq1, next) from t1;", there is no SORT as left child of TSJ, and it + *is a self-referencing updates Halloween problem. In NestedJoin::genWriteOpLeftChildSortReq(), child(0) + *producing no outputs for this query, which means that there is no column to sort on. So we solve this by + *having the source for Halloween insert produce at least one output column always. + * */ if (avoidHalloween() && child(0) && child(0)->getOperatorType() == REL_SCAN && child(0)->getGroupAttr()) { - ValueIdSet cur_output = child(0)->getGroupAttr()->getCharacteristicOutputs(); - if (cur_output.isEmpty()) + if (child(0)->getGroupAttr()->getCharacteristicOutputs().isEmpty()) { ValueId exprId; ValueId atLeastOne; @@ -13364,8 +13369,7 @@ void GenericUpdate::pushdownCoveredExpr(const ValueIdSet &outputExpr, break; } } - cur_output = child(0)->getGroupAttr()->getCharacteristicOutputs(); - if (cur_output.isEmpty()) + if (child(0)->getGroupAttr()->getCharacteristicOutputs().isEmpty()) { child(0)->getGroupAttr()->addCharacteristicOutputs(atLeastOne); }
