Repository: trafodion
Updated Branches:
  refs/heads/master 3e26f8621 -> a52f46229


[TRAFODION-3000] Fix binder issue with index maintenance on MERGE DELETE


Project: http://git-wip-us.apache.org/repos/asf/trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafodion/commit/b4c60e15
Tree: http://git-wip-us.apache.org/repos/asf/trafodion/tree/b4c60e15
Diff: http://git-wip-us.apache.org/repos/asf/trafodion/diff/b4c60e15

Branch: refs/heads/master
Commit: b4c60e151b3103d43ded0e62d9da7d9e69821e29
Parents: 21735bc
Author: Dave Birdsall <[email protected]>
Authored: Mon Mar 19 23:14:57 2018 +0000
Committer: Dave Birdsall <[email protected]>
Committed: Mon Mar 19 23:14:57 2018 +0000

----------------------------------------------------------------------
 core/sql/optimizer/Inlining.cpp | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafodion/blob/b4c60e15/core/sql/optimizer/Inlining.cpp
----------------------------------------------------------------------
diff --git a/core/sql/optimizer/Inlining.cpp b/core/sql/optimizer/Inlining.cpp
index f8d7b66..e93e33b 100644
--- a/core/sql/optimizer/Inlining.cpp
+++ b/core/sql/optimizer/Inlining.cpp
@@ -1888,7 +1888,7 @@ static RelExpr *createIMNode(BindWA *bindWA,
                             NABoolean isIMInsert,
                             NABoolean useInternalSyskey,
                              NABoolean isForUpdateOrMergeUpdate,
-                             NABoolean isForMerge, // mergeDelete OR 
mergeUpdate
+                             NABoolean mergeDeleteWithInsertOrMergeUpdate,
                             NABoolean isEffUpsert)
 {
    
@@ -1906,7 +1906,8 @@ static RelExpr *createIMNode(BindWA *bindWA,
   // that correspond to the base table. Hence we introduce 
   // robustDelete below. This flag could also be called 
   // isIMOnAUniqueIndexForMerge
-  NABoolean robustDelete = (isForMerge && index->isUniqueIndex()) || 
(isEffUpsert && index->isUniqueIndex());
+  NABoolean robustDelete = (mergeDeleteWithInsertOrMergeUpdate && 
index->isUniqueIndex()) || 
+                           (isEffUpsert && index->isUniqueIndex());
 
   tableCorrName.setCorrName(isIMInsert ?  NEWCorr : OLDCorr);
   
@@ -2127,8 +2128,15 @@ RelExpr *GenericUpdate::createIMNodes(BindWA *bindWA,
   if (getOperatorType() == REL_UNARY_DELETE ||
       getOperatorType() == REL_UNARY_UPDATE ||
       isEffUpsert)
-    
-    indexDelete = indexOp = createIMNode(bindWA,
+    {
+      NABoolean mergeDeleteWithInsertOrMergeUpdate = isMerge();
+      if (mergeDeleteWithInsertOrMergeUpdate && 
+          (getOperatorType() == REL_UNARY_DELETE) && 
+          (!insertValues()))
+        // merge delete without an insert
+        mergeDeleteWithInsertOrMergeUpdate = FALSE;
+      
+      indexDelete = indexOp = createIMNode(bindWA,
                                         tableCorrName,
                                          indexCorrName,
                                         index,
@@ -2136,8 +2144,9 @@ RelExpr *GenericUpdate::createIMNodes(BindWA *bindWA,
                                         FALSE,
                                         useInternalSyskey,
                                          isForUpdateOrMergeUpdate,
-                                         isMerge(),
+                                         mergeDeleteWithInsertOrMergeUpdate,
                                         isEffUpsert);
+    }
 
   if ((getOperatorType() == REL_UNARY_UPDATE) || isEffUpsert){
     indexOp = new (bindWA->wHeap()) Union(indexDelete, indexInsert, 

Reply via email to