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

    https://github.com/apache/incubator-hawq/pull/1351#discussion_r180627154
  
    --- Diff: contrib/vexecutor/execVQual.c ---
    @@ -123,3 +123,431 @@ VirtualNodeProc(ScanState* state,TupleTableSlot 
*slot){
         ExecStoreVirtualTuple(slot);
         return true;
     }
    +
    +/*
    + * get values from vectorized tuple slot
    + * copy from src/backend/executor/execQual.c
    + */
    +static Datum
    +VExecEvalScalarVar(ExprState *exprstate, ExprContext *econtext,
    +                   bool *isNull, ExprDoneCond *isDone)
    +{
    +   Var                *variable = (Var *) exprstate->expr;
    +   TupleTableSlot *slot;
    +   AttrNumber      attnum;
    +   TupleBatch tb;
    +
    +   if (isDone)
    +           *isDone = ExprSingleResult;
    +
    +   Assert(econtext->ecxt_scantuple != NULL || econtext->ecxt_innertuple != 
NULL || econtext->ecxt_outertuple != NULL);
    +   /*
    +    * Get the input slot and attribute number we want
    +    *
    +    * The asserts check that references to system attributes only appear at
    +    * the level of a relation scan; at higher levels, system attributes 
must
    +    * be treated as ordinary variables (since we no longer have access to 
the
    +    * original tuple).
    +    */
    +   attnum = variable->varattno;
    +
    +   switch (variable->varno)
    +   {
    +           case INNER:                             /* get the tuple from 
the inner node */
    +                   slot = econtext->ecxt_innertuple;
    +                   Assert(attnum > 0);
    +                   break;
    +
    +           case OUTER:                             /* get the tuple from 
the outer node */
    +                   slot = econtext->ecxt_outertuple;
    +                   Assert(attnum > 0);
    +                   break;
    +
    +           default:                                /* get the tuple from 
the relation being
    +                                                            * scanned */
    +                   slot = econtext->ecxt_scantuple;
    +                   break;
    +   }
    +
    +   /* isNull is a single value, it can not be used when data is vectorized 
*/
    +   *isNull = false;
    +
    --- End diff --
    
    It's better to check or assert to make sure slot is not null here.


---

Reply via email to