Skip to content

Commit dc37450

Browse files
committed
Fix for psort again.
1 parent 677efc7 commit dc37450

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/backend/utils/sort/psort.c

Lines changed: 11 additions & 4 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.10 1997/08/06 07:39:20 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.11 1997/08/06 17:11:20 momjian Exp $
1111
*
1212
* NOTES
1313
* Sorts the first relation into the second relation.
@@ -281,8 +281,14 @@ initialrun(Sort *node, bool *empty)
281281
inittapes(node);
282282
extrapasses = 0;
283283
}
284-
else
285-
return; /* if rows fit in memory, we never access tape stuff */
284+
else {
285+
/* if empty or rows fit in memory, we never access tape stuff */
286+
if (*empty || ! PS(node)->using_tape_files)
287+
return;
288+
if (! PS(node)->using_tape_files)
289+
inittapes(node);
290+
extrapasses = 1 + (PS(node)->Tuples != NULL); /* (T != N) ? 2 : 1 */
291+
}
286292

287293
for ( ; ; ) {
288294
tp->tp_dummy--;
@@ -362,7 +368,8 @@ createrun(Sort *node, FILE *file, bool *empty)
362368
&PS(node)->treeContext);
363369
if (! PS(node)->using_tape_files) {
364370
inittapes(node);
365-
file = PS(node)->Tape->tp_file; /* was NULL */
371+
if (! file)
372+
file = PS(node)->Tape->tp_file; /* was NULL */
366373
}
367374
PUTTUP(node, tup, file);
368375
TRACEOUT(createrun, tup);

0 commit comments

Comments
 (0)