Pass EXEC_FLAG_REWIND when initializing a tuplestore scan.
authorRobert Haas
Wed, 10 May 2017 03:13:21 +0000 (23:13 -0400)
committerRobert Haas
Wed, 10 May 2017 03:13:21 +0000 (23:13 -0400)
Since a rescan is possible, we must be able to rewind.

Thomas Munro, per a report from Prabhat Sabu

Discussion: http://postgr.es/m/CAEepm=2=Uv5fm=exqL+ygBxaO+-tgmC=o+63H4zYAXi9HtXf1w@mail.gmail.com

src/backend/executor/nodeNamedtuplestorescan.c

index 917b05197a48582003a7a87cc78402017fcfe876..44e09426691583378962b82189172eedf196cbe6 100644 (file)
@@ -107,7 +107,7 @@ ExecInitNamedTuplestoreScan(NamedTuplestoreScan *node, EState *estate, int eflag
    scanstate->relation = (Tuplestorestate *) enr->reldata;
    scanstate->tupdesc = ENRMetadataGetTupDesc(&(enr->md));
    scanstate->readptr =
-       tuplestore_alloc_read_pointer(scanstate->relation, 0);
+       tuplestore_alloc_read_pointer(scanstate->relation, EXEC_FLAG_REWIND);
 
    /*
     * The new read pointer copies its position from read pointer 0, which