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

    https://github.com/apache/incubator-trafodion/pull/132#discussion_r42519204
  
    --- Diff: core/sql/optimizer/ValueDesc.cpp ---
    @@ -6397,3 +6400,111 @@ Lng32 ValueIdList::findPrefixLength(const 
ValueIdSet& x) const
       return ct;
     }
     
    +// -----------------------------------------------------------------------
    +// replace any ColReference (of the given column name) in of this value
    +// expression with the given expression.
    +// used in ValueId::computeEncodedKey() to assign key values into the
    +// salt/DivisionByto expression.
    +// ----------------------------------------------------------------------
    +void ValueId::replaceColReferenceWithExpr(const NAString& colName,
    +                                          const ValueId & vid)
    +{
    +  ItemExpr* thisItemExpr = getItemExpr();
    +  for( Lng32 i = 0; i < thisItemExpr->getArity(); i++ )
    +  {
    +    ValueId childValueId = thisItemExpr->child(i).getValueId();
    +    ItemExpr* childItemExpr = childValueId.getItemExpr();
    +
    +    if( childItemExpr->getOperatorType() == ITM_REFERENCE)
    +    {
    +      if( ((ColReference*)childItemExpr)->getColRefNameObj().getColName() 
== colName )
    +        thisItemExpr->setChild( i, vid.getItemExpr() );
    +    }
    +    childValueId.replaceColReferenceWithExpr( colName, vid );
    +  }
    +}
    +
    +
    +char*
    +ValueIdList::computeEncodedKey(const TableDesc* tDesc, NABoolean isMaxKey, 
    +                               char*& encodedKeyBuffer, Int32& keyBufLen) 
const
    +{
    +   const NATable*  naTable = tDesc->getNATable();
    +
    +
    +   CollIndex count = entries();
    +   NAString** inputStrings = new (STMTHEAP) NAStringPtr[count];
    +
    +   for (Int32 j=0; j<count; j++ ) 
    +       inputStrings[j] = NULL;
    +
    +   for (Int32 j=0; j<count; j++ ) {
    +
    +      ValueId vid = (*this)[j];
    +      ItemExpr* ie = vid.getItemExpr();
    +
    +      if ( ie->getOperatorType() != ITM_CONSTANT ) {
    +          ConstValue* value = ie->compute(STMTHEAP);
    --- End diff --
    
    Shouldn't we call ItemExpr::doesExprEvaluateToConstant(TRUE, TRUE) here 
before calling compute()? What happens when a non-constant like a VEGRef or a 
parameter is passed to compute()?


---
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