aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/sort/psort.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c
index 2c9b3213632..9bb7de5b68b 100644
--- a/src/backend/utils/sort/psort.c
+++ b/src/backend/utils/sort/psort.c
@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.37 1998/02/11 19:13:47 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.38 1998/02/23 06:27:39 vadim Exp $
*
* NOTES
* Sorts the first relation into the second relation.
@@ -924,8 +924,6 @@ psort_end(Sort * node)
if (!node->cleaned)
{
- Assert(node != (Sort *) NULL);
-
/*
* I'm changing this because if we are sorting a relation with no
* tuples, psortstate is NULL.
@@ -944,12 +942,35 @@ psort_end(Sort * node)
(int) ceil((double) PS(node)->BytesWritten / BLCKSZ);
pfree((void *) node->psortstate);
+ node->psortstate = NULL;
node->cleaned = TRUE;
}
}
}
+void
+psort_rescan (Sort *node)
+{
+ /*
+ * If subnode is to be rescanned then free our previous results
+ */
+ if (((Plan*) node)->lefttree->chgParam != NULL)
+ {
+ psort_end (node);
+ node->cleaned = false;
+ }
+ else if (PS(node) != (Psortstate *) NULL)
+ {
+ PS(node)->all_fetched = false;
+ PS(node)->psort_current = 0;
+ PS(node)->psort_saved = 0;
+ if (PS(node)->using_tape_files == true)
+ rewind (PS(node)->psort_grab_file);
+ }
+
+}
+
/*
* gettape - handles access temporary files in polyphase merging
*