1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-30 21:42:05 +03:00

ExecReScan for Unique & Sort nodes.

This commit is contained in:
Vadim B. Mikheev
1998-02-23 06:28:16 +00:00
parent e4fd534645
commit f0e7e2faa4
7 changed files with 83 additions and 11 deletions

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.17 1998/02/13 03:26:36 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.18 1998/02/23 06:26:53 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -43,6 +43,7 @@
#include "executor/nodeHash.h"
#include "executor/nodeAgg.h"
#include "executor/nodeResult.h"
#include "executor/nodeUnique.h"
#include "executor/nodeSubplan.h"
#include "executor/execdebug.h"
#include "optimizer/internal.h" /* for _TEMP_RELATION_ID_ */
@ -354,6 +355,14 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
ExecReScanResult((Result*) node, exprCtxt, parent);
break;
case T_Unique:
ExecReScanUnique((Unique*) node, exprCtxt, parent);
break;
case T_Sort:
ExecReScanSort((Sort*) node, exprCtxt, parent);
break;
/*
* Tee is never used
case T_Tee:

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.12 1998/01/07 21:02:56 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.13 1998/02/23 06:26:56 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -183,8 +183,6 @@ ExecSort(Sort *node)
else
{
slot = (TupleTableSlot *) sortstate->csstate.cstate.cs_ResultTupleSlot;
/* *** get_cs_ResultTupleSlot((CommonState) sortstate); */
/* slot = sortstate->csstate.css_ScanTupleSlot; orig */
}
SO1_printf("ExecSort: %s\n",
@ -390,3 +388,28 @@ ExecSortRestrPos(Sort *node)
*/
psort_restorepos(node);
}
void
ExecReScanSort(Sort *node, ExprContext *exprCtxt, Plan *parent)
{
SortState *sortstate = node->sortstate;
/*
* If we haven't sorted yet, just return. If outerplan'
* chgParam is not NULL then it will be re-scanned by
* ExecProcNode, else - no reason to re-scan it at all.
*/
if (sortstate->sort_Flag == false)
return;
ExecClearTuple(sortstate->csstate.cstate.cs_ResultTupleSlot);
psort_rescan (node);
/*
* If subnode is to be rescanned then we aren't sorted
*/
if (((Plan*) node)->lefttree->chgParam != NULL)
sortstate->sort_Flag = false;
}

View File

@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.15 1998/02/18 12:40:44 vadim Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.16 1998/02/23 06:26:58 vadim Exp $
*
*-------------------------------------------------------------------------
*/
@ -355,3 +355,19 @@ ExecEndUnique(Unique *node)
ExecEndNode(outerPlan((Plan *) node), (Plan *) node);
ExecClearTuple(uniquestate->cs_ResultTupleSlot);
}
void
ExecReScanUnique(Unique *node, ExprContext *exprCtxt, Plan *parent)
{
UniqueState *uniquestate = node->uniquestate;
ExecClearTuple(uniquestate->cs_ResultTupleSlot);
/*
* if chgParam of subnode is not null then plan
* will be re-scanned by first ExecProcNode.
*/
if (((Plan*) node)->lefttree->chgParam == NULL)
ExecReScan (((Plan*) node)->lefttree, exprCtxt, (Plan *) node);
}