Fix oversight in recent patch to support multiple read positions in
tuplestore: in READFILE state tuplestore_select_read_pointer must save the current file seek position in the read pointer being deactivated.
This commit is contained in:
parent
742fd06d98
commit
34f89cb4af
|
@ -46,7 +46,7 @@
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.41 2008/10/04 21:56:54 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/utils/sort/tuplestore.c,v 1.42 2008/10/07 00:05:55 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
@ -434,7 +434,8 @@ tuplestore_end(Tuplestorestate *state)
|
||||||
void
|
void
|
||||||
tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
|
tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
|
||||||
{
|
{
|
||||||
TSReadPointer *readptr = &state->readptrs[ptr];
|
TSReadPointer *readptr;
|
||||||
|
TSReadPointer *oldptr;
|
||||||
|
|
||||||
Assert(ptr >= 0 && ptr < state->readptrcount);
|
Assert(ptr >= 0 && ptr < state->readptrcount);
|
||||||
|
|
||||||
|
@ -442,6 +443,9 @@ tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
|
||||||
if (ptr == state->activeptr)
|
if (ptr == state->activeptr)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
readptr = &state->readptrs[ptr];
|
||||||
|
oldptr = &state->readptrs[state->activeptr];
|
||||||
|
|
||||||
switch (state->status)
|
switch (state->status)
|
||||||
{
|
{
|
||||||
case TSS_INMEM:
|
case TSS_INMEM:
|
||||||
|
@ -449,10 +453,19 @@ tuplestore_select_read_pointer(Tuplestorestate *state, int ptr)
|
||||||
/* no work */
|
/* no work */
|
||||||
break;
|
break;
|
||||||
case TSS_READFILE:
|
case TSS_READFILE:
|
||||||
|
/*
|
||||||
|
* First, save the current read position in the pointer about
|
||||||
|
* to become inactive.
|
||||||
|
*/
|
||||||
|
if (!oldptr->eof_reached)
|
||||||
|
BufFileTell(state->myfile,
|
||||||
|
&oldptr->file,
|
||||||
|
&oldptr->offset);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We have to make the temp file's seek position equal to the
|
* We have to make the temp file's seek position equal to the
|
||||||
* logical position of the read pointer. In eof_reached state,
|
* logical position of the new read pointer. In eof_reached
|
||||||
* that's the EOF, which we have available from the saved
|
* state, that's the EOF, which we have available from the saved
|
||||||
* write position.
|
* write position.
|
||||||
*/
|
*/
|
||||||
if (readptr->eof_reached)
|
if (readptr->eof_reached)
|
||||||
|
|
Loading…
Reference in New Issue