Skip to content

Commit b90e6ce

Browse files
committed
In PQprint(), write HTML table trailer before closing the output pipe.
This is an astonishingly ancient bit of silliness, dating AFAICS to commit edb519b of 27-Jul-1996 which added the pipe close stanza in the wrong place. It happens to be harmless given that the code above this won't enable the pager if html3 output mode is selected. Still, somebody might try to relax that restriction someday, and in any case it could confuse readers and static analysis tools, so let's fix it in HEAD. Per bug #15541 from Pan Bian. Discussion: https://postgr.es/m/[email protected]
1 parent 5deadfe commit b90e6ce

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/interfaces/libpq/fe-print.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
304304
if (po->header && !po->html3)
305305
fprintf(fout, "(%d row%s)\n\n", PQntuples(res),
306306
(PQntuples(res) == 1) ? "" : "s");
307+
if (po->html3 && !po->expanded)
308+
fputs("</table>\n", fout);
307309
free(fieldMax);
308310
free(fieldNotNum);
309311
free((void *) fieldNames);
@@ -323,8 +325,6 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
323325
#endif /* ENABLE_THREAD_SAFETY */
324326
#endif /* WIN32 */
325327
}
326-
if (po->html3 && !po->expanded)
327-
fputs("</table>\n", fout);
328328
}
329329
}
330330

0 commit comments

Comments
 (0)