aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-12-07 13:11:30 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2018-12-07 13:11:30 -0500
commitb90e6cef12662ccad8679be24cd650c6b49feb1c (patch)
tree70a724b7dcce7a0537e891f6d7b3a04422c0785d
parent5deadfef282761aeb27b18706dcff295e9430c39 (diff)
downloadpostgresql-b90e6cef12662ccad8679be24cd650c6b49feb1c.tar.gz
postgresql-b90e6cef12662ccad8679be24cd650c6b49feb1c.zip
In PQprint(), write HTML table trailer before closing the output pipe.
This is an astonishingly ancient bit of silliness, dating AFAICS to commit edb519b14 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/15541-c835d8b9a903f7ad@postgresql.org
-rw-r--r--src/interfaces/libpq/fe-print.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index 95de270b933..f022780dc78 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -304,6 +304,8 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
if (po->header && !po->html3)
fprintf(fout, "(%d row%s)\n\n", PQntuples(res),
(PQntuples(res) == 1) ? "" : "s");
+ if (po->html3 && !po->expanded)
+ fputs("</table>\n", fout);
free(fieldMax);
free(fieldNotNum);
free((void *) fieldNames);
@@ -323,8 +325,6 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
#endif /* ENABLE_THREAD_SAFETY */
#endif /* WIN32 */
}
- if (po->html3 && !po->expanded)
- fputs("</table>\n", fout);
}
}