Fix postgresql_fdw to reuse contents of tuplestore through whole of
authorShigeru Hanada <[email protected]>
Mon, 8 Nov 2010 01:58:55 +0000 (10:58 +0900)
committerShigeru Hanada <[email protected]>
Mon, 8 Nov 2010 01:58:55 +0000 (10:58 +0900)
the query to avoid unnecessary re-execution of remote query.

contrib/postgresql_fdw/postgresql_fdw.c

index abeb2711260c0ec144276ba642da379b2d1207dd..288830430b4df16305e97cc2fcca38202dbb5f01 100644 (file)
@@ -649,13 +649,9 @@ pgReOpen(ForeignScanState *scanstate)
 {
    pgFdwReply     *reply = (pgFdwReply *) scanstate->reply;
 
-   /* Free Tuplestore to execute query again */
-   /* TODO: reuse tupstore through the scan to avoid overhead */
+   /* Rewind tuplestore to retrieve all tuples again */
    if (reply->tupstore)
-   {
-       tuplestore_end(reply->tupstore);
-       reply->tupstore = NULL;
-   }
+       tuplestore_rescan(reply->tupstore);
 }
 
 /*