psql seems to never call clearerr() on its output file. So if it gets an error while printing a result, it'll show
could not print result table: Success after each and every result, even though the output file isn't in error state anymore. It seems that the simplest fix is just to do clearerr() at the start of printTable(), as in the attached. I haven't been able to find a good reproducer. Sometimes doing C-s C-c does it, but I'm not sure it is fully reproducible. -- Álvaro Herrera Valdivia, Chile
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c index e8772a278c..0d0b5ef782 100644 --- a/src/fe_utils/print.c +++ b/src/fe_utils/print.c @@ -3322,6 +3322,9 @@ printTable(const printTableContent *cont, if (cont->opt->format == PRINT_NOTHING) return; + /* Clear any prior error indicator */ + clearerr(fout); + /* print_aligned_*() handle the pager themselves */ if (!is_pager && cont->opt->format != PRINT_ALIGNED &&