From 2ccc2ff5506cdb32e451c59c1adc65d9edda47b4 Mon Sep 17 00:00:00 2001 From: Neil Conway Date: Fri, 22 Jun 2007 03:19:57 +0000 Subject: [PATCH] In psql, when running a SELECT query using a cursor, flush the query 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 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index ebd6aee017..25273ccc99 100644 --- a/src/bin/psql/common.c +++ b/src/bin/psql/common.c @@ -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; -- 2.39.5