pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedMaintaining blank lines in psql output?
6+ messages / 3 participants
[nested] [flat]
* Maintaining blank lines in psql output?
@ 2023-01-17 20:48 Ron <ronljohnsonjr@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Ron @ 2023-01-17 20:48 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
White space can of course make things easy to read, but psql seems to ignore
those blank lines. Is there any way to retain them in psql output?
$ cat spaces.sql
insert into foo values(1);
insert into foo values(2);
insert into foo values(3);
insert into foo values(4);
insert into bar values(1);
insert into bar values(2);
insert into bar values(3);
insert into bar values(4);
insert into snaggle values(1);
insert into snaggle values(2);
insert into snaggle values(3);
insert into snaggle values(4);
insert into frob values(1);
insert into frob values(2);
insert into frob values(3);
insert into frob values(4);
postgres@haggis:~$ psql12 test -af spaces.sql
insert into foo values(1);
INSERT 0 1
insert into foo values(2);
INSERT 0 1
insert into foo values(3);
INSERT 0 1
insert into foo values(4);
INSERT 0 1
insert into bar values(1);
INSERT 0 1
insert into bar values(2);
INSERT 0 1
insert into bar values(3);
INSERT 0 1
insert into bar values(4);
INSERT 0 1
insert into snaggle values(1);
INSERT 0 1
insert into snaggle values(2);
INSERT 0 1
insert into snaggle values(3);
INSERT 0 1
insert into snaggle values(4);
INSERT 0 1
insert into frob values(1);
INSERT 0 1
insert into frob values(2);
INSERT 0 1
insert into frob values(3);
INSERT 0 1
insert into frob values(4);
INSERT 0 1
--
Born in Arizona, moved to Babylonia.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Maintaining blank lines in psql output?
@ 2023-01-17 21:22 David G. Johnston <david.g.johnston@gmail.com>
parent: Ron <ronljohnsonjr@gmail.com>
0 siblings, 2 replies; 6+ messages in thread
From: David G. Johnston @ 2023-01-17 21:22 UTC (permalink / raw)
To: Ron <ronljohnsonjr@gmail.com>; +Cc: pgsql-general@lists.postgresql.org
On Tue, Jan 17, 2023 at 1:48 PM Ron <ronljohnsonjr@gmail.com> wrote:
>
> White space can of course make things easy to read, but psql seems to
> ignore
> those blank lines. Is there any way to retain them in psql output?
>
>
Nope, there is no setting for psql to print all blank lines it encounters
to stdout. If you want to format your output with stuff other than query
results it provides \echo
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Maintaining blank lines in psql output?
@ 2023-01-17 23:06 raf <raf@raf.org>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: raf @ 2023-01-17 23:06 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Tue, Jan 17, 2023 at 02:22:22PM -0700, "David G. Johnston" <david.g.johnston@gmail.com> wrote:
> On Tue, Jan 17, 2023 at 1:48 PM Ron <ronljohnsonjr@gmail.com> wrote:
>
> >
> > White space can of course make things easy to read, but psql seems to
> > ignore
> > those blank lines. Is there any way to retain them in psql output?
> >
> >
> Nope, there is no setting for psql to print all blank lines it encounters
> to stdout. If you want to format your output with stuff other than query
> results it provides \echo
>
> David J.
Perhaps the best you can do is something like adding:
select '';
or
raise notice '';
It won't result in just a blank line, but it will separate things.
cheers,
raf
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Maintaining blank lines in psql output?
@ 2023-01-17 23:10 David G. Johnston <david.g.johnston@gmail.com>
parent: raf <raf@raf.org>
0 siblings, 1 reply; 6+ messages in thread
From: David G. Johnston @ 2023-01-17 23:10 UTC (permalink / raw)
To: raf <raf@raf.org>; +Cc: pgsql-general@lists.postgresql.org
On Tue, Jan 17, 2023 at 4:07 PM raf <raf@raf.org> wrote:
> On Tue, Jan 17, 2023 at 02:22:22PM -0700, "David G. Johnston" <
> david.g.johnston@gmail.com> wrote:
>
> > On Tue, Jan 17, 2023 at 1:48 PM Ron <ronljohnsonjr@gmail.com> wrote:
> >
> > >
> > > White space can of course make things easy to read, but psql seems to
> > > ignore
> > > those blank lines. Is there any way to retain them in psql output?
> > >
> > >
> > Nope, there is no setting for psql to print all blank lines it encounters
> > to stdout. If you want to format your output with stuff other than query
> > results it provides \echo
> >
> > David J.
>
> Perhaps the best you can do is something like adding:
>
> select '';
>
> or
>
> raise notice '';
>
> It won't result in just a blank line, but it will separate things.
>
>
Those both seem much more complicated than \echo for the same (or worse)
effect. You'd have to wrap the raise notice inside a do block which itself
would then be executed by the server...
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Maintaining blank lines in psql output?
@ 2023-01-17 23:21 raf <raf@raf.org>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: raf @ 2023-01-17 23:21 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On Tue, Jan 17, 2023 at 04:10:50PM -0700, "David G. Johnston" <david.g.johnston@gmail.com> wrote:
> On Tue, Jan 17, 2023 at 4:07 PM raf <raf@raf.org> wrote:
>
> > On Tue, Jan 17, 2023 at 02:22:22PM -0700, "David G. Johnston" <
> > david.g.johnston@gmail.com> wrote:
> >
> > > On Tue, Jan 17, 2023 at 1:48 PM Ron <ronljohnsonjr@gmail.com> wrote:
> > >
> > > >
> > > > White space can of course make things easy to read, but psql seems to
> > > > ignore
> > > > those blank lines. Is there any way to retain them in psql output?
> > > >
> > > >
> > > Nope, there is no setting for psql to print all blank lines it encounters
> > > to stdout. If you want to format your output with stuff other than query
> > > results it provides \echo
> > >
> > > David J.
> >
> > Perhaps the best you can do is something like adding:
> >
> > select '';
> >
> > or
> >
> > raise notice '';
> >
> > It won't result in just a blank line, but it will separate things.
> >
> >
> Those both seem much more complicated than \echo for the same (or worse)
> effect. You'd have to wrap the raise notice inside a do block which itself
> would then be executed by the server...
>
> David J.
Good point. I didn't read it right. select/raise make more sense
out of the context of psql (i.e. in sql/plpgsql). \echo makes more
sense in psql.
cheers,
raf
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Maintaining blank lines in psql output?
@ 2023-01-18 00:22 Ron <ronljohnsonjr@gmail.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Ron @ 2023-01-18 00:22 UTC (permalink / raw)
To: pgsql-general@lists.postgresql.org
On 1/17/23 15:22, David G. Johnston wrote:
> On Tue, Jan 17, 2023 at 1:48 PM Ron <ronljohnsonjr@gmail.com> wrote:
>
>
> White space can of course make things easy to read, but psql seems to
> ignore
> those blank lines. Is there any way to retain them in psql output?
>
>
> Nope, there is no setting for psql to print all blank lines it encounters
> to stdout. If you want to format your output with stuff other than query
> results it provides \echo
\echo is exactly what I want, not only because of it's simplicity but since
it doesn't generate numbers when \timing is enabled.
(The primary use is for sql scripts generated by bash scripts and run from
cron, where stdout and stderr are redirected to a log file.)
--
Born in Arizona, moved to Babylonia.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2023-01-18 00:22 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-01-17 20:48 Maintaining blank lines in psql output? Ron <ronljohnsonjr@gmail.com>
2023-01-17 21:22 ` David G. Johnston <david.g.johnston@gmail.com>
2023-01-17 23:06 ` raf <raf@raf.org>
2023-01-17 23:10 ` David G. Johnston <david.g.johnston@gmail.com>
2023-01-17 23:21 ` raf <raf@raf.org>
2023-01-18 00:22 ` Ron <ronljohnsonjr@gmail.com>
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