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

    https://github.com/apache/incubator-hawq/pull/1350#discussion_r178480561
  
    --- Diff: contrib/vexecutor/execVQual.c ---
    @@ -0,0 +1,125 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one
    + * or more contributor license agreements.  See the NOTICE file
    + * distributed with this work for additional information
    + * regarding copyright ownership.  The ASF licenses this file
    + * to you under the Apache License, Version 2.0 (the
    + * "License"); you may not use this file except in compliance
    + * with the License.  You may obtain a copy of the License at
    + *
    + *   http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing,
    + * software distributed under the License is distributed on an
    + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    + * KIND, either express or implied.  See the License for the
    + * specific language governing permissions and limitations
    + * under the License.
    + */
    +#include "execVQual.h"
    +
    +/*
    + * ExecVariableList
    + *         Evaluates a simple-Variable-list projection.
    + *
    + * Results are stored into the passed values and isnull arrays.
    + */
    +static void
    +ExecVecVariableList(ProjectionInfo *projInfo,
    +                 Datum *values)
    +{
    +    ExprContext *econtext = projInfo->pi_exprContext;
    +    int               *varSlotOffsets = projInfo->pi_varSlotOffsets;
    +    int               *varNumbers = projInfo->pi_varNumbers;
    +    TupleBatch  tb = (TupleBatch) values;
    +    int                    i;
    +    tb->ncols = list_length(projInfo->pi_targetlist);
    +
    +    /*
    +     * Assign to result by direct extraction of fields from source slots 
... a
    +     * mite ugly, but fast ...
    +     */
    +    for (i = list_length(projInfo->pi_targetlist) - 1; i >= 0; i--)
    +    {
    +        char          *slotptr = ((char *) econtext) + varSlotOffsets[i];
    +        TupleTableSlot *varSlot = *((TupleTableSlot **) slotptr);
    +        int                        varNumber = varNumbers[i] - 1;
    +        tb->datagroup[i] = 
((TupleBatch)varSlot->PRIVATE_tb)->datagroup[varNumber];
    +    }
    +}
    +
    +TupleTableSlot *
    +ExecVProject(ProjectionInfo *projInfo, ExprDoneCond *isDone)
    +{
    +    TupleTableSlot *slot;
    +    Assert(projInfo != NULL);
    +
    +    /*
    +     * get the projection info we want
    +     */
    +    slot = projInfo->pi_slot;
    +
    +    /*
    +     * Clear any former contents of the result slot.  This makes it safe 
for
    +     * us to use the slot's Datum/isnull arrays as workspace. (Also, we can
    +     * return the slot as-is if we decide no rows can be projected.)
    +     */
    +    ExecClearTuple(slot);
    +
    +    /*
    +     * form a new result tuple (if possible); if successful, mark the 
result
    +     * slot as containing a valid virtual tuple
    +     */
    +    if (projInfo->pi_isVarList)
    +    {
    +        /* simple Var list: this always succeeds with one result row */
    +        if (isDone)
    +            *isDone = ExprSingleResult;
    +
    +        ExecVecVariableList(projInfo,slot->PRIVATE_tb);
    +        ExecStoreVirtualTuple(slot);
    +    }
    +    else
    +    {
    +        elog(FATAL,"does not support expression in projection stmt");
    --- End diff --
    
    The expression op will be supported soon in next 


---

Reply via email to