In psql, when running a SELECT query using a cursor, flush the query
authorNeil Conway <[email protected]>
Fri, 22 Jun 2007 03:19:57 +0000 (03:19 +0000)
committerNeil Conway <[email protected]>
Fri, 22 Jun 2007 03:19:57 +0000 (03:19 +0000)
output after each FETCH. This ensures that incremental results are
available to clients that are executing long-running SELECT queries
via the FETCH_COUNT feature.

src/bin/psql/common.c

index ae406f62d66cd5aa369a6b65096ccb7a4889a3cf..6ff402b764402c489aa222d84e09a5fb4cce3b1e 100644 (file)
@@ -1100,6 +1100,12 @@ ExecQueryUsingCursor(const char *query, double *elapsed_msec)
 
                printQuery(results, &my_popt, pset.queryFout, pset.logfile);
 
+               /*
+                * Make sure to flush the output stream, so intermediate
+                * results are visible to the client immediately.
+                */
+               fflush(pset.queryFout);
+
                /* after the first result set, disallow header decoration */
                my_popt.topt.start_table = false;
                my_popt.topt.prior_records += ntuples;