psql \x bug

Started by Greg Sabino Mullanealmost 21 years ago2 messagespatches
Jump to latest
#1Greg Sabino Mullane
greg@turnstep.com

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Fix two instances of using raw "puts" inside of specifying fout.
The second one caused a bug that can be seen by using the pager
in expanded output mode:

$ psql pgtest

pgtest> \x
Expanded display is on.
pgtest> SELECT * FROM pg_class LIMIT 2;

(messy output)

--
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200509161020
https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

Index: print.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.72
diff -c -r1.72 print.c
*** print.c     18 Jul 2005 20:57:53 -0000      1.72
--- print.c     16 Sep 2005 14:18:04 -0000
***************
*** 570,576 ****

if (cells[0] == NULL)
{
! puts(_("(No rows)\n"));
return;
}

--- 570,576 ----

if (cells[0] == NULL)
{
! fprintf(fout, _("(No rows)\n"));
return;
}

***************
*** 704,710 ****
                        if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
                            format_numeric_locale(my_cell);
                        if (opt_border < 2)
!                               puts(my_cell);
                        else
                                fprintf(fout, "%-s%*s |\n", my_cell, dwidth - cell_w[i], "");
                        free(my_cell);
--- 704,710 ----
                        if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
                            format_numeric_locale(my_cell);
                        if (opt_border < 2)
!                               fprintf(fout, "%s\n", my_cell);
                        else
                                fprintf(fout, "%-s%*s |\n", my_cell, dwidth - cell_w[i], "");
                        free(my_cell);
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkMq1REACgkQvJuQZxSWSsjIGgCeIE1CONuRu31KZuJLAcNZT1VI
sysAoK6Pi5NXYPBC/0oNhmQKqZqca5jw
=W9GE
-----END PGP SIGNATURE-----

#2Bruce Momjian
bruce@momjian.us
In reply to: Greg Sabino Mullane (#1)
Re: psql \x bug

Patch applied. Thanks.

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

Greg Sabino Mullane wrote:
[ There is text before PGP section. ]

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message

Fix two instances of using raw "puts" inside of specifying fout.
The second one caused a bug that can be seen by using the pager
in expanded output mode:

$ psql pgtest

pgtest> \x
Expanded display is on.
pgtest> SELECT * FROM pg_class LIMIT 2;

(messy output)

--
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200509161020
https://www.biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

Index: print.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/print.c,v
retrieving revision 1.72
diff -c -r1.72 print.c
*** print.c     18 Jul 2005 20:57:53 -0000      1.72
--- print.c     16 Sep 2005 14:18:04 -0000
***************
*** 570,576 ****

if (cells[0] == NULL)
{
! puts(_("(No rows)\n"));
return;
}

--- 570,576 ----

if (cells[0] == NULL)
{
! fprintf(fout, _("(No rows)\n"));
return;
}

***************
*** 704,710 ****
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
format_numeric_locale(my_cell);
if (opt_border < 2)
!                               puts(my_cell);
else
fprintf(fout, "%-s%*s |\n", my_cell, dwidth - cell_w[i], "");
free(my_cell);
--- 704,710 ----
if (opt_align[i % col_count] == 'r' && opt_numeric_locale)
format_numeric_locale(my_cell);
if (opt_border < 2)
!                               fprintf(fout, "%s\n", my_cell);
else
fprintf(fout, "%-s%*s |\n", my_cell, dwidth - cell_w[i], "");
free(my_cell);
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkMq1REACgkQvJuQZxSWSsjIGgCeIE1CONuRu31KZuJLAcNZT1VI
sysAoK6Pi5NXYPBC/0oNhmQKqZqca5jw
=W9GE
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 2: Don't 'kill -9' the postmaster

-- 
  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