|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.10 1997/08/0607:39:20 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.11 1997/08/0617:11:20 momjian Exp $ |
11 | 11 | *
|
12 | 12 | * NOTES
|
13 | 13 | * Sorts the first relation into the second relation.
|
@@ -281,8 +281,14 @@ initialrun(Sort *node, bool *empty)
|
281 | 281 | inittapes(node);
|
282 | 282 | extrapasses=0;
|
283 | 283 | }
|
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 | + } |
286 | 292 |
|
287 | 293 | for ( ; ; ) {
|
288 | 294 | tp->tp_dummy--;
|
@@ -362,7 +368,8 @@ createrun(Sort *node, FILE *file, bool *empty)
|
362 | 368 | &PS(node)->treeContext);
|
363 | 369 | if (!PS(node)->using_tape_files) {
|
364 | 370 | inittapes(node);
|
365 |
| -file=PS(node)->Tape->tp_file;/* was NULL */ |
| 371 | +if (!file) |
| 372 | +file=PS(node)->Tape->tp_file;/* was NULL */ |
366 | 373 | }
|
367 | 374 | PUTTUP(node,tup,file);
|
368 | 375 | TRACEOUT(createrun,tup);
|
|