Thread: Properly page footers in psql

Properly page footers in psql

From
greg@turnstep.com
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Small (inline) patch to fix the annoying behavior of psql when the
footers are long (e.g. when there are a lot of foreign keys) and
the page scrolls past, without invoking the pager utility.

Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200208141153


Index: print.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/print.c,v
retrieving revision 1.28
diff -r1.28 print.c
1078,1079c1078,1080
<         if (!opt->tuples_only)
<             lines += 5;
---
>         if (footers && !opt->tuples_only)
>             for (ptr = footers; *ptr; ptr++)
>               lines++;
1106d1106
<
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iEYEARECAAYFAj1aiFAACgkQvJuQZxSWSshYMQCcDcMHLVwA3h7xgH4YlxznRiy7
wsYAn1xpAWQloL3C2cUQY/zDUc2YxChm
=9jN8
-----END PGP SIGNATURE-----


Re: Properly page footers in psql

From
"Greg Sabino Mullane"
Date:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Any word on this? Is there a disadvantage to not guessing
the number of lines and just sending everything to the pager
no matter what?

Index: print.c
===================================================================
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/print.c,v
retrieving revision 1.28
diff -r1.28 print.c
1078,1079c1078,1080
< if (!opt->tuples_only)
< lines += 5;
---
> if (footers && !opt->tuples_only)
> for (ptr = footers; *ptr; ptr++)
> lines++;
1106d1106

Greg Sabino Mullane  greg@turnstep.com
PGP Key: 0x14964AC8 200208311637

-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html

iD8DBQE9cSpvvJuQZxSWSsgRAiunAKCN4+YpR5QmMyGIPmlTMAhj2ewSBACg7tvr
n0yEFMfJnXgyVdZkP/DZUH4=
=9zcO
-----END PGP SIGNATURE-----





Re: Properly page footers in psql

From
Bruce Momjian
Date:
Nice improvement.  Applied.

We do check the length because most pagers require you to quit them, and
if it is only a few lines, it is a pain to exit.  Some pagers will only
as for a quite if the contents overflow the page, but not all of them,
and we have no way of knowing if the pager they are using does this.

---------------------------------------------------------------------------

Greg Sabino Mullane wrote:
[ There is text before PGP section. ]
>
[ PGP not available, raw data follows ]
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
>
>
> Any word on this? Is there a disadvantage to not guessing
> the number of lines and just sending everything to the pager
> no matter what?
>
> Index: print.c
> ===================================================================
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/print.c,v
> retrieving revision 1.28
> diff -r1.28 print.c
> 1078,1079c1078,1080
> < if (!opt->tuples_only)
> < lines += 5;
> ---
> > if (footers && !opt->tuples_only)
> > for (ptr = footers; *ptr; ptr++)
> > lines++;
> 1106d1106
>
> Greg Sabino Mullane  greg@turnstep.com
> PGP Key: 0x14964AC8 200208311637
>
> -----BEGIN PGP SIGNATURE-----
> Comment: http://www.turnstep.com/pgp.html
>
> iD8DBQE9cSpvvJuQZxSWSsgRAiunAKCN4+YpR5QmMyGIPmlTMAhj2ewSBACg7tvr
> n0yEFMfJnXgyVdZkP/DZUH4=
> =9zcO
> -----END PGP SIGNATURE-----
>
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>
[ Decrypting message... End of raw data. ]

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 359-1001
  +  If your life is a hard drive,     |  13 Roberts Road
  +  Christ can be your backup.        |  Newtown Square, Pennsylvania 19073
Index: src/bin/psql/print.c
===================================================================
RCS file: /cvsroot/pgsql-server/src/bin/psql/print.c,v
retrieving revision 1.30
diff -c -c -r1.30 print.c
*** src/bin/psql/print.c    28 Aug 2002 20:46:24 -0000    1.30
--- src/bin/psql/print.c    1 Sep 2002 23:29:09 -0000
***************
*** 1017,1024 ****
              lines = (col_count + 1) * row_count;
          else
              lines = row_count + 1;
!         if (!opt->tuples_only)
!             lines += 5;

          result = ioctl(fileno(stdout), TIOCGWINSZ, &screen_size);
          if (result == -1 || lines > screen_size.ws_row)
--- 1017,1025 ----
              lines = (col_count + 1) * row_count;
          else
              lines = row_count + 1;
!         if (footers && !opt->tuples_only)
!             for (ptr = footers; *ptr; ptr++)
!                 lines++;

          result = ioctl(fileno(stdout), TIOCGWINSZ, &screen_size);
          if (result == -1 || lines > screen_size.ws_row)