diff --git a/src/bin/psql/print.c b/src/bin/psql/print.c index cab9e6e..5e2ff09 100644 --- a/src/bin/psql/print.c +++ b/src/bin/psql/print.c @@ -2725,6 +2725,12 @@ print_troff_ms_vertical(const printTableContent *cont, FILE *fout) /* Public functions */ /********************************/ +#ifdef USE_ASSERT_CHECKING +#define MAX_PAGEOUTPUT_LINES 1000 +#define MAX_PAGEOUTPUT_BUF (1000 * 80 * 2) +static char *PageOutputBuf; +static int expected_lines; +#endif /* * PageOutput @@ -2770,6 +2776,21 @@ PageOutput(int lines, const printTableOpt *topt) #endif } +#ifdef USE_ASSERT_CHECKING + if (lines < MAX_PAGEOUTPUT_LINES) + { + fflush(stdout); + expected_lines = lines; + if (!PageOutputBuf) + { + PageOutputBuf = pg_malloc0(MAX_PAGEOUTPUT_BUF); + setvbuf(stdout, PageOutputBuf, _IOFBF, MAX_PAGEOUTPUT_BUF); + } else { + memset(PageOutputBuf, MAX_PAGEOUTPUT_BUF, 0); + } + } +#endif + return stdout; } @@ -2799,6 +2820,33 @@ ClosePager(FILE *pagerpipe) pqsignal(SIGPIPE, SIG_DFL); #endif } + +#ifdef USE_ASSERT_CHECKING + if (PageOutputBuf && expected_lines) + { + int n_newlines = 0; + int i; + for (i=0;i