Reworks as suggested by Hans
Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/97f137c5 Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/97f137c5 Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/97f137c5 Branch: refs/heads/master Commit: 97f137c5cdd4d9a7568a063f03a369a914eac839 Parents: ebf7283 Author: Dave Birdsall <[email protected]> Authored: Thu Jan 25 19:35:07 2018 +0000 Committer: Dave Birdsall <[email protected]> Committed: Thu Jan 25 19:35:07 2018 +0000 ---------------------------------------------------------------------- core/sql/optimizer/OptPhysRelExpr.cpp | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/trafodion/blob/97f137c5/core/sql/optimizer/OptPhysRelExpr.cpp ---------------------------------------------------------------------- diff --git a/core/sql/optimizer/OptPhysRelExpr.cpp b/core/sql/optimizer/OptPhysRelExpr.cpp index eff9944..1f7a4dc 100644 --- a/core/sql/optimizer/OptPhysRelExpr.cpp +++ b/core/sql/optimizer/OptPhysRelExpr.cpp @@ -15527,37 +15527,16 @@ Context * FirstN::createContextForAChild(Context* myContext, if (reqdOrder().entries() > 0) { - // replace our sort requirement with that implied by our ORDER BY clause - - rg.removeSortKey(); - - ValueIdList sortKey; - sortKey.insert(reqdOrder()); + // add our sort requirement as implied by our ORDER BY clause // Shouldn't/Can't add a sort order type requirement // if we are in DP2 if (rppForMe->executeInDP2()) - rg.addSortKey(sortKey,NO_SOT); + rg.addSortKey(reqdOrder(),NO_SOT); else - rg.addSortKey(sortKey,ESP_SOT); + rg.addSortKey(reqdOrder(),ESP_SOT); } - if (NOT pws->isEmpty()) - { - const Context* childContext = pws->getLatestChildContext(); - - // ------------------------------------------------------------------ - // Cost limit exceeded or got no solution? Give up since we only - // try one plan. - // ------------------------------------------------------------------ - if(NOT (childContext AND childContext->hasOptimalSolution())) - return NULL; - - if (NOT pws->isLatestContextWithinCostLimit()) - return NULL; - - } - if (NOT rg.checkFeasibility()) return NULL;
