diff --git a/src/bin/psql/common.c b/src/bin/psql/common.c index f605c97..fae1e5a 100644 *** a/src/bin/psql/common.c --- b/src/bin/psql/common.c *************** ExecQueryUsingCursor(const char *query, *** 982,987 **** --- 982,988 ---- char fetch_cmd[64]; instr_time before, after; + int flush_error; *elapsed_msec = 0; *************** ExecQueryUsingCursor(const char *query, *** 1098,1106 **** /* * 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; --- 1099,1109 ---- /* * Make sure to flush the output stream, so intermediate results are ! * visible to the client immediately. We check the results because ! * if the pager dies/exits/etc, there's no sense throwing more data ! * at it. */ ! flush_error = fflush(pset.queryFout); /* after the first result set, disallow header decoration */ my_popt.topt.start_table = false; *************** ExecQueryUsingCursor(const char *query, *** 1108,1114 **** PQclear(results); ! if (ntuples < pset.fetch_count || cancel_pressed) break; } --- 1111,1117 ---- PQclear(results); ! if (ntuples < pset.fetch_count || cancel_pressed || flush_error) break; }