!1031 fix two bugs about ROWNUM
Merge pull request !1031 from 周雄佳/davidzhou
This commit is contained in:
@ -51,8 +51,8 @@ void preprocess_rownum(PlannerInfo *root, Query *parse)
|
||||
if (quals == NULL) {
|
||||
return;
|
||||
}
|
||||
/* If it includes {order by} or {group by}, can not be rewrited */
|
||||
if ((parse->sortClause != NULL) || (parse->groupClause != NULL)) {
|
||||
/* If it includes aggregation function or {order by} or {group by}, can not be rewrited */
|
||||
if (parse->hasAggs || (parse->sortClause != NULL) || (parse->groupClause != NULL)) {
|
||||
return;
|
||||
}
|
||||
if (parse->limitCount != NULL) {
|
||||
|
||||
@ -270,7 +270,9 @@ void ExecReScan(PlanState* node)
|
||||
}
|
||||
|
||||
/* reset the rownum */
|
||||
node->ps_rownum = 0;
|
||||
if (!node->do_not_reset_rownum) {
|
||||
node->ps_rownum = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* If we have changed parameters, propagate that info.
|
||||
|
||||
@ -98,6 +98,7 @@ TupleTableSlot* ExecPartIterator(PartIteratorState* node)
|
||||
TupleTableSlot* slot = NULL;
|
||||
PartIterator* pi_node = (PartIterator*)node->ps.plan;
|
||||
EState* state = node->ps.lefttree->state;
|
||||
node->ps.lefttree->do_not_reset_rownum = true;
|
||||
bool orig_early_free = state->es_skip_early_free;
|
||||
|
||||
PlanState* noden = (PlanState*)node->ps.lefttree;
|
||||
|
||||
@ -1238,7 +1238,7 @@ typedef struct PlanState {
|
||||
List* plan_issues;
|
||||
bool recursive_reset; /* node already reset? */
|
||||
bool qual_is_inited;
|
||||
|
||||
bool do_not_reset_rownum;
|
||||
int64 ps_rownum; /* store current rownum */
|
||||
} PlanState;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user