fix bug for rownum when cstore

This commit is contained in:
yupeng
2021-03-09 11:26:23 +08:00
parent c95258b287
commit 1eefafe1a0
4 changed files with 148 additions and 0 deletions

View File

@ -228,6 +228,22 @@ static ScalarVector* ExecEvalVecNot(
return pVector;
}
static ScalarVector* ExecEvalVecRownum(
RownumState* exprstate, ExprContext* econtext, bool* pSelection, ScalarVector* pVector, ExprDoneCond* isDone)
{
Assert(pSelection != NULL);
ScalarValue* pDest = pVector->m_vals;
int64 ps_rownum = exprstate->ps->ps_rownum;
for (int i = 0; i < econtext->align_rows; i++) {
SET_NOTNULL(pVector->m_flag[i]);
pDest[i] = ++ps_rownum ;
}
pVector->m_rows = econtext->align_rows;
return pVector;
}
// TRUE means we deal with or
// false means we deal with and
template <bool AndOrFLag>
@ -3158,6 +3174,12 @@ ExprState* ExecInitVecExpr(Expr* node, PlanState* parent)
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmodule(MOD_VEC_EXECUTOR),
errmsg("Unsupported array coerce expression in vector engine")));
case T_Rownum: {
RownumState* rnstate = (RownumState*)makeNode(RownumState);
rnstate->ps = parent;
state = (ExprState*)rnstate;
state->vecExprFun = (VectorExprFun)ExecEvalVecRownum;
} break;
default:
ereport(ERROR,
(errcode(ERRCODE_UNRECOGNIZED_NODE_TYPE),

View File

@ -154,6 +154,7 @@ TupleTableSlot* ExecVecToRow(VecToRowState* state) /* return: a tuple or NULL */
state->m_currentRow = 0;
// Convert the batch into row based tuple
DevectorizeOneBatch(state);
outer_plan->ps_rownum += current_batch->m_rows;
}
// retrieve rows from current batch