In psql, when running a SELECT query using a cursor, flush the query
authorNeil Conway <neilc@samurai.com>
Fri, 22 Jun 2007 03:19:57 +0000 (03:19 +0000)
committerNeil Conway <neilc@samurai.com>
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 ebd6aee017887756a6e8d59844a6740717c90b39..25273ccc997061acb1faa06aaac9e33ff2220e1a 100644 (file)
@@ -1076,6 +1076,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;