|
7 | 7 | *
|
8 | 8 | *
|
9 | 9 | * IDENTIFICATION
|
10 |
| - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.8 1997/08/0605:38:38 momjian Exp $ |
| 10 | + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.9 1997/08/0607:02:48 momjian Exp $ |
11 | 11 | *
|
12 | 12 | * NOTES
|
13 | 13 | * Sorts the first relation into the second relation.
|
@@ -123,7 +123,7 @@ psort_begin(Sort *node, int nkeys, ScanKey key)
|
123 | 123 | PS(node)->BytesRead=0;
|
124 | 124 | PS(node)->BytesWritten=0;
|
125 | 125 | PS(node)->treeContext.tupDesc=
|
126 |
| -ExecGetTupType(outerPlan((Plan*)node)); |
| 126 | +ExecGetTupType(outerPlan((Plan*)node)); |
127 | 127 | PS(node)->treeContext.nKeys=nkeys;
|
128 | 128 | PS(node)->treeContext.scanKeys=key;
|
129 | 129 | PS(node)->treeContext.sortMem=SortMem*1024;
|
@@ -276,7 +276,7 @@ initialrun(Sort *node, bool *empty)
|
276 | 276 |
|
277 | 277 | tp=PS(node)->Tape;
|
278 | 278 |
|
279 |
| -if ((bool)createrun(node,tp->tp_file,empty)!= false) { |
| 279 | +if ((bool)createrun(node,NULL,empty)!= false) { |
280 | 280 | if (!PS(node)->using_tape_files)
|
281 | 281 | inittapes(node);
|
282 | 282 | extrapasses=0;
|
@@ -307,7 +307,7 @@ initialrun(Sort *node, bool *empty)
|
307 | 307 | }/* D3 */
|
308 | 308 | if (extrapasses)
|
309 | 309 | if (--extrapasses) {
|
310 |
| -dumptuples(node); |
| 310 | +dumptuples(tp->tp_file,node); |
311 | 311 | ENDRUN(tp->tp_file);
|
312 | 312 | continue;
|
313 | 313 | }else
|
@@ -360,9 +360,11 @@ createrun(Sort *node, FILE *file, bool *empty)
|
360 | 360 | }
|
361 | 361 | lasttuple=tup=gettuple(&PS(node)->Tuples,&junk,
|
362 | 362 | &PS(node)->treeContext);
|
363 |
| -if (!PS(node)->using_tape_files) |
| 363 | +if (!PS(node)->using_tape_files) { |
364 | 364 | inittapes(node);
|
365 |
| -PUTTUP(node,tup,PS(node)->Tape->tp_file); |
| 365 | +file=PS(node)->Tape->tp_file;/* was NULL */ |
| 366 | + } |
| 367 | +PUTTUP(node,tup,file); |
366 | 368 | TRACEOUT(createrun,tup);
|
367 | 369 | }
|
368 | 370 | if (LACKMEM(node))
|
@@ -400,7 +402,7 @@ createrun(Sort *node, FILE *file, bool *empty)
|
400 | 402 | FREE(lasttuple);
|
401 | 403 | TRACEMEM(createrun);
|
402 | 404 | }
|
403 |
| -dumptuples(node); |
| 405 | +dumptuples(file,node); |
404 | 406 | if (PS(node)->using_tape_files)
|
405 | 407 | ENDRUN(file);
|
406 | 408 | /* delimit the end of the run */
|
@@ -561,7 +563,7 @@ merge(Sort *node, struct tape *dest)
|
561 | 563 | * dumptuples- stores all the tuples in tree into file
|
562 | 564 | */
|
563 | 565 | void
|
564 |
| -dumptuples(Sort*node) |
| 566 | +dumptuples(FILE*file,Sort*node) |
565 | 567 | {
|
566 | 568 | registerstructleftist*tp;
|
567 | 569 | registerstructleftist*newp;
|
|