* Tom Lane (t...@sss.pgh.pa.us) wrote: > If you're combining this with the FETCH_COUNT logic then it seems like > it'd be sufficient to check ferror(fout) once per fetch chunk, and just > fall out of that loop then. I don't want psql issuing query cancels > on its own authority, either.
Attached is a patch that just checks the result from the existing fflush() inside the FETCH_COUNT loop and drops out of that loop if we get an error from it. Thanks! Stephen
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; }
signature.asc
Description: Digital signature