aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/ref/psql-ref.sgml5
-rw-r--r--src/fe_utils/print.c6
-rw-r--r--src/interfaces/libpq/fe-print.c3
3 files changed, 11 insertions, 3 deletions
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index 168a295013f..0c846e14522 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -3798,8 +3798,9 @@ $endif
If the query results do not fit on the screen, they are piped
through this command. Typical values are
<literal>more</literal> or <literal>less</literal>. The default
- is platform-dependent. The use of the pager can be disabled by
- using the <command>\pset</command> command.
+ is platform-dependent. Use of the pager can be disabled by setting
+ <envar>PAGER</envar> to empty, or by using pager-related options of
+ the <command>\pset</command> command.
</para>
</listitem>
</varlistentry>
diff --git a/src/fe_utils/print.c b/src/fe_utils/print.c
index 1ec74f17907..5c5d285be5f 100644
--- a/src/fe_utils/print.c
+++ b/src/fe_utils/print.c
@@ -2874,6 +2874,12 @@ PageOutput(int lines, const printTableOpt *topt)
pagerprog = getenv("PAGER");
if (!pagerprog)
pagerprog = DEFAULT_PAGER;
+ else
+ {
+ /* if PAGER is empty or all-white-space, don't use pager */
+ if (strspn(pagerprog, " \t\r\n") == strlen(pagerprog))
+ return stdout;
+ }
disable_sigpipe_trap();
pagerpipe = popen(pagerprog, "w");
if (pagerpipe)
diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c
index c33dc42a839..e596a514087 100644
--- a/src/interfaces/libpq/fe-print.c
+++ b/src/interfaces/libpq/fe-print.c
@@ -166,8 +166,9 @@ PQprint(FILE *fout, const PGresult *res, const PQprintOpt *po)
screen_size.ws_col = 80;
#endif
pagerenv = getenv("PAGER");
+ /* if PAGER is unset, empty or all-white-space, don't use pager */
if (pagerenv != NULL &&
- pagerenv[0] != '\0' &&
+ strspn(pagerenv, " \t\r\n") != strlen(pagerenv) &&
!po->html3 &&
((po->expanded &&
nTups * (nFields + 1) >= screen_size.ws_row) ||