pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #12721: psql -a does not preserve empty lines between SELECTs
5+ messages / 3 participants
[nested] [flat]

* BUG #12721: psql -a does not preserve empty lines between SELECTs
@ 2015-01-31 17:37  hans@matfyz.cz
  0 siblings, 1 reply; 5+ messages in thread

From: hans@matfyz.cz @ 2015-01-31 17:37 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      12721
Logged by:          Hans Ginzel
Email address:      hans@matfyz.cz
PostgreSQL version: 9.4.0
Operating system:   GNU/Linux Centos 6.5
Description:        

Hello!

There is, in the [doc] that psql with option -a echoes all input lines.

Try a file containing
SELECT count(*) AS N FROM information_schema.Tables;

SELECT count(*) AS N FROM information_schema.Columns;

There is an empty line between SELECTs and they are each on one line. The
output of 
    cat input.sql |psql -naAF"`echo -e '\t'`" -Pfooter=off
is in my case is

SELECT count(*) AS N FROM information_schema.Tables;
n
205
SELECT count(*) AS N FROM information_schema.Columns;
n
1855

The empty line has disappeared. If there had been a comment line, it would
have been preserved. Preserve also empty lines, please.

[doc]: http://www.postgresql.org/docs/9.4/static/app-psql.html

Best regards
HG

PS: Please, is there a better way how to specify tab as delimiter?


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12721: psql -a does not preserve empty lines between SELECTs
@ 2015-01-31 18:35  Tom Lane <tgl@sss.pgh.pa.us>
  parent: hans@matfyz.cz
  0 siblings, 2 replies; 5+ messages in thread

From: Tom Lane @ 2015-01-31 18:35 UTC (permalink / raw)
  To: hans@matfyz.cz; +Cc: pgsql-bugs

hans@matfyz.cz writes:
> There is, in the [doc] that psql with option -a echoes all input lines.

Hm.  That's poorly phrased: what it actually echoes is commands, not
lines.  This must be so because some of the other possible settings of
ECHO require decisions at the per-command level.  I will see about
improving the wording here.

> The empty line has disappeared. If there had been a comment line, it would
> have been preserved. Preserve also empty lines, please.

Sorry, that's not going to happen.  psql has always stripped whitespace
appearing before a command, and changing that would create a lot of
unhappiness in a lot of other behaviors.

> PS: Please, is there a better way how to specify tab as delimiter?

Maybe put \pset fieldsep '\t' in the input .sql file, instead of setting
it up on the command line.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12721: psql -a does not preserve empty lines between SELECTs
@ 2015-01-31 22:50  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 1 reply; 5+ messages in thread

From: Tom Lane @ 2015-01-31 22:50 UTC (permalink / raw)
  To: hans@matfyz.cz; +Cc: pgsql-bugs

I wrote:
> hans@matfyz.cz writes:
>> There is, in the [doc] that psql with option -a echoes all input lines.

> Hm.  That's poorly phrased: what it actually echoes is commands, not
> lines.  This must be so because some of the other possible settings of
> ECHO require decisions at the per-command level.

Huh --- I take that back; the "queries" and "errors" cases are implemented
totally independently of "all" mode.  The "all" mode does work on a line
by line basis, and there's no good reason why it doesn't print blank
lines, except that somebody wasn't thinking very hard about where they
added the test.  Will fix.

The documentation is wrong too, but not in the way I thought; it should
say that interactive input is never echoed by this feature, rather than
that it's "less useful" to turn it on for that.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12721: psql -a does not preserve empty lines between SELECTs
@ 2015-01-31 23:00  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 5+ messages in thread

From: Tom Lane @ 2015-01-31 23:00 UTC (permalink / raw)
  To: hans@matfyz.cz; +Cc: pgsql-bugs

I wrote:
> Huh --- I take that back; the "queries" and "errors" cases are implemented
> totally independently of "all" mode.  The "all" mode does work on a line
> by line basis, and there's no good reason why it doesn't print blank
> lines, except that somebody wasn't thinking very hard about where they
> added the test.  Will fix.

Or maybe not.  It's a simple enough change, but it breaks all our
regression tests, which use -a and are not expecting blank lines to
get echoed.  So I think I was right the first time: the existing behavior
is probably embedded in enough places that changing it would not be worth
the pain.  Sorry.

> The documentation is wrong too, but not in the way I thought; it should
> say that interactive input is never echoed by this feature, rather than
> that it's "less useful" to turn it on for that.

This still needs fixed though ...

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: BUG #12721: psql -a does not preserve empty lines between SELECTs
@ 2015-02-02 07:57  Hans Ginzel <hans@matfyz.cz>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 5+ messages in thread

From: Hans Ginzel @ 2015-02-02 07:57 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

Thank you, Tom.

On Sat, Jan 31, 2015 at 01:35:00PM -0500, Tom Lane wrote:
>> PS: Please, is there a better way how to specify tab as delimiter?
>Maybe put \pset fieldsep '\t' in the input .sql file, instead of setting
>it up on the command line.

I have SELECTs on stdin and everything others should be set on command line.
I have reported a specific bug about that. See #12725.

Regards,
Hans


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2015-02-02 07:57 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2015-01-31 17:37 BUG #12721: psql -a does not preserve empty lines between SELECTs hans@matfyz.cz
2015-01-31 18:35 ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-31 22:50   ` Tom Lane <tgl@sss.pgh.pa.us>
2015-01-31 23:00     ` Tom Lane <tgl@sss.pgh.pa.us>
2015-02-02 07:57   ` Hans Ginzel <hans@matfyz.cz>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox