|
91 | 91 | * Portions Copyright (c) 1994, Regents of the University of California |
92 | 92 | * |
93 | 93 | * IDENTIFICATION |
94 | | - * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.58 2006/02/1905:54:06 tgl Exp $ |
| 94 | + * $PostgreSQL: pgsql/src/backend/utils/sort/tuplesort.c,v 1.59 2006/02/1919:59:53 tgl Exp $ |
95 | 95 | * |
96 | 96 | *------------------------------------------------------------------------- |
97 | 97 | */ |
@@ -324,8 +324,7 @@ struct Tuplesortstate |
324 | 324 | #defineUSEMEM(state,amt)((state)->availMem -= (amt)) |
325 | 325 | #defineFREEMEM(state,amt)((state)->availMem += (amt)) |
326 | 326 |
|
327 | | -/*-------------------- |
328 | | - * |
| 327 | +/* |
329 | 328 | * NOTES about on-tape representation of tuples: |
330 | 329 | * |
331 | 330 | * We require the first "unsigned int" of a stored tuple to be the total size |
@@ -357,16 +356,13 @@ struct Tuplesortstate |
357 | 356 | * |
358 | 357 | * We count space allocated for tuples against the workMem limit, plus |
359 | 358 | * the space used by the variable-size arrays memtuples and memtupindex. |
360 | | - * Fixed-size space (primarily the LogicalTapeSet I/O buffers) is not |
361 | | - * counted. |
| 359 | + * Fixed-size space is not counted; it's small enough to not be interesting. |
362 | 360 | * |
363 | 361 | * Note that we count actual space used (as shown by GetMemoryChunkSpace) |
364 | 362 | * rather than the originally-requested size. This is important since |
365 | 363 | * palloc can add substantial overhead. It's not a complete answer since |
366 | 364 | * we won't count any wasted space in palloc allocation blocks, but it's |
367 | 365 | * a lot better than what we were doing before 7.3. |
368 | | - * |
369 | | - *-------------------- |
370 | 366 | */ |
371 | 367 |
|
372 | 368 | /* |
@@ -2407,6 +2403,7 @@ readtup_datum(Tuplesortstate *state, int tapenum, unsigned int len) |
2407 | 2403 | sizeof(tuplen))!=sizeof(tuplen)) |
2408 | 2404 | elog(ERROR,"unexpected end of data"); |
2409 | 2405 |
|
| 2406 | +/* if pass-by-ref data type, must recompute the Datum pointer */ |
2410 | 2407 | if (!tuple->isNull&& !state->datumTypeByVal) |
2411 | 2408 | tuple->val=PointerGetDatum(((char*)tuple)+ |
2412 | 2409 | MAXALIGN(sizeof(DatumTuple))); |
|