Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf0e7e2f

Browse files
committed
ExecReScan for Unique & Sort nodes.
1 parente4fd534 commitf0e7e2f

File tree

7 files changed

+83
-11
lines changed

7 files changed

+83
-11
lines changed

‎src/backend/executor/execAmi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.17 1998/02/13 03:26:36 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.18 1998/02/23 06:26:53 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -43,6 +43,7 @@
4343
#include"executor/nodeHash.h"
4444
#include"executor/nodeAgg.h"
4545
#include"executor/nodeResult.h"
46+
#include"executor/nodeUnique.h"
4647
#include"executor/nodeSubplan.h"
4748
#include"executor/execdebug.h"
4849
#include"optimizer/internal.h"/* for _TEMP_RELATION_ID_ */
@@ -354,6 +355,14 @@ ExecReScan(Plan *node, ExprContext *exprCtxt, Plan *parent)
354355
ExecReScanResult((Result*)node,exprCtxt,parent);
355356
break;
356357

358+
caseT_Unique:
359+
ExecReScanUnique((Unique*)node,exprCtxt,parent);
360+
break;
361+
362+
caseT_Sort:
363+
ExecReScanSort((Sort*)node,exprCtxt,parent);
364+
break;
365+
357366
/*
358367
* Tee is never used
359368
case T_Tee:

‎src/backend/executor/nodeSort.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.12 1998/01/07 21:02:56momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.13 1998/02/23 06:26:56vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -183,8 +183,6 @@ ExecSort(Sort *node)
183183
else
184184
{
185185
slot= (TupleTableSlot*)sortstate->csstate.cstate.cs_ResultTupleSlot;
186-
/* *** get_cs_ResultTupleSlot((CommonState) sortstate); */
187-
/*slot =sortstate->csstate.css_ScanTupleSlot; orig */
188186
}
189187

190188
SO1_printf("ExecSort: %s\n",
@@ -390,3 +388,28 @@ ExecSortRestrPos(Sort *node)
390388
*/
391389
psort_restorepos(node);
392390
}
391+
392+
void
393+
ExecReScanSort(Sort*node,ExprContext*exprCtxt,Plan*parent)
394+
{
395+
SortState*sortstate=node->sortstate;
396+
397+
/*
398+
* If we haven't sorted yet, just return. If outerplan'
399+
* chgParam is not NULL then it will be re-scanned by
400+
* ExecProcNode, else - no reason to re-scan it at all.
401+
*/
402+
if (sortstate->sort_Flag== false)
403+
return;
404+
405+
ExecClearTuple(sortstate->csstate.cstate.cs_ResultTupleSlot);
406+
407+
psort_rescan (node);
408+
409+
/*
410+
* If subnode is to be rescanned then we aren't sorted
411+
*/
412+
if (((Plan*)node)->lefttree->chgParam!=NULL)
413+
sortstate->sort_Flag= false;
414+
415+
}

‎src/backend/executor/nodeUnique.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.15 1998/02/18 12:40:44 vadim Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.16 1998/02/23 06:26:58 vadim Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -355,3 +355,19 @@ ExecEndUnique(Unique *node)
355355
ExecEndNode(outerPlan((Plan*)node), (Plan*)node);
356356
ExecClearTuple(uniquestate->cs_ResultTupleSlot);
357357
}
358+
359+
360+
void
361+
ExecReScanUnique(Unique*node,ExprContext*exprCtxt,Plan*parent)
362+
{
363+
UniqueState*uniquestate=node->uniquestate;
364+
365+
ExecClearTuple(uniquestate->cs_ResultTupleSlot);
366+
/*
367+
* if chgParam of subnode is not null then plan
368+
* will be re-scanned by first ExecProcNode.
369+
*/
370+
if (((Plan*)node)->lefttree->chgParam==NULL)
371+
ExecReScan (((Plan*)node)->lefttree,exprCtxt, (Plan*)node);
372+
373+
}

‎src/backend/utils/sort/psort.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.37 1998/02/11 19:13:47 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.38 1998/02/23 06:27:39 vadim Exp $
1111
*
1212
* NOTES
1313
*Sorts the first relation into the second relation.
@@ -924,8 +924,6 @@ psort_end(Sort * node)
924924

925925
if (!node->cleaned)
926926
{
927-
Assert(node!= (Sort*)NULL);
928-
929927
/*
930928
* I'm changing this because if we are sorting a relation with no
931929
* tuples, psortstate is NULL.
@@ -944,12 +942,35 @@ psort_end(Sort * node)
944942
(int)ceil((double)PS(node)->BytesWritten /BLCKSZ);
945943

946944
pfree((void*)node->psortstate);
945+
node->psortstate=NULL;
947946

948947
node->cleaned= TRUE;
949948
}
950949
}
951950
}
952951

952+
void
953+
psort_rescan (Sort*node)
954+
{
955+
/*
956+
* If subnode is to be rescanned then free our previous results
957+
*/
958+
if (((Plan*)node)->lefttree->chgParam!=NULL)
959+
{
960+
psort_end (node);
961+
node->cleaned= false;
962+
}
963+
elseif (PS(node)!= (Psortstate*)NULL)
964+
{
965+
PS(node)->all_fetched= false;
966+
PS(node)->psort_current=0;
967+
PS(node)->psort_saved=0;
968+
if (PS(node)->using_tape_files== true)
969+
rewind (PS(node)->psort_grab_file);
970+
}
971+
972+
}
973+
953974
/*
954975
*gettape- handles access temporary files in polyphase merging
955976
*

‎src/include/executor/nodeSort.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nodeSort.h,v 1.5 1997/11/26 01:13:04 momjian Exp $
9+
* $Id: nodeSort.h,v 1.6 1998/02/23 06:27:55 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -23,5 +23,6 @@ extern intExecCountSlotsSort(Sort *node);
2323
externvoidExecEndSort(Sort*node);
2424
externvoidExecSortMarkPos(Sort*node);
2525
externvoidExecSortRestrPos(Sort*node);
26+
externvoidExecReScanSort(Sort*node,ExprContext*exprCtxt,Plan*parent);
2627

2728
#endif/* NODESORT_H */

‎src/include/executor/nodeUnique.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: nodeUnique.h,v 1.5 1997/11/26 01:13:06 momjian Exp $
9+
* $Id: nodeUnique.h,v 1.6 1998/02/23 06:27:56 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -21,5 +21,6 @@ extern TupleTableSlot *ExecUnique(Unique *node);
2121
externboolExecInitUnique(Unique*node,EState*estate,Plan*parent);
2222
externintExecCountSlotsUnique(Unique*node);
2323
externvoidExecEndUnique(Unique*node);
24+
externvoidExecReScanUnique(Unique*node,ExprContext*exprCtxt,Plan*parent);
2425

2526
#endif/* NODEUNIQUE_H */

‎src/include/utils/psort.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: psort.h,v 1.14 1997/10/15 06:36:36 vadim Exp $
9+
* $Id: psort.h,v 1.15 1998/02/23 06:28:16 vadim Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -104,5 +104,6 @@ extern HeapTuple psort_grabtuple(Sort *node, bool *should_free);
104104
externvoidpsort_markpos(Sort*node);
105105
externvoidpsort_restorepos(Sort*node);
106106
externvoidpsort_end(Sort*node);
107+
externvoidpsort_rescan(Sort*node);
107108

108109
#endif/* PSORT_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp