Github user sureshsubbiah commented on a diff in the pull request:

    
https://github.com/apache/incubator-trafodion/pull/1051#discussion_r110809205
  
    --- Diff: core/sql/optimizer/RelExpr.cpp ---
    @@ -9121,38 +9090,85 @@ NABoolean Scan::updateableIndex(IndexDesc *idx)
       {
         ItemExpr *updateCol = colUpdated[i].getItemExpr();
         CMPASSERT(updateCol->getOperatorType() == ITM_BASECOLUMN);
    -
         for (CollIndex j = 0; j < indexKey.entries(); j++)
         {
           ItemExpr *keyCol = indexKey[j].getItemExpr();
    -
    -      ItemExpr *baseCol = 
((IndexColumn*)keyCol)->getDefinition().getItemExpr();
    +      ItemExpr *baseCol = 
    +        ((IndexColumn*)keyCol)->getDefinition().getItemExpr();
           CMPASSERT(baseCol->getOperatorType() == ITM_BASECOLUMN);
    -
    -      // QSTUFF
    -      if (getGroupAttr()->isEmbeddedUpdate()){
    -        if (((BaseColumn*)updateCol)->getColNumber() ==
    +      if (((BaseColumn*)updateCol)->getColNumber() ==
               ((BaseColumn*)baseCol)->getColNumber())
    -          return FALSE;
    -      }
    -      // QSTUFF
    +        return FALSE;
    +    }
    +  }
    +  return TRUE;
    +} // Scan::updateableIndex
    +
    +NABoolean Scan::requiresHalloweenForUpdateUsingIndexScan()
    +{
    +
    +  // Returns TRUE if any non clustering index can be used for a scan 
    +  // during an UPDATE and a key column of that index is in the SET
    +  // clause of the update. If this method returns TRUE we will use a 
    +  // sort node to prevent the "Halloween Update Problem".
    --- End diff --
    
    Yes, we can now use a an index to drive an update of an indexed column, 
regardless of the type of WHERE predicate. A blocking SORT will be added for 
anything other than an equality predicate without a constant. As such there is 
no concept of an updateableIndex anymore (not considering embeddedUpdate which 
is still retained in the old method). Every index is updateable, some 
predicate/index combinations require a blocing sort while others do not.  This 
method is to help decide whether a blocking sort is needed for an index driven 
scan of an update.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

Reply via email to