psql -A parameter unalines continued data wrongly

From: Kurt De Cauwsemaecker <Kurt(dot)DeCauwsemaecker(at)digipolis(dot)be>
To: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: psql -A parameter unalines continued data wrongly
Date: 2015-06-22 15:56:01
Message-ID: 99CF48BFA38EF54F9157F22281521FC1A0BB7174@RMS402.rte.antwerpen.local
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

PostgreSQL version: 9.4.4 and previous 9.4
Ubuntu version: 14.04 LTS

psql -A parameter unalines continued data wrongly. The continued data jumps to the first column while it should be in the correct column or shoudn't be spitted.

Example:

Full formatted output:
$ psql -p 50005 -d postgres -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+---------+-------+-----------------------
postgres | postgres | LATIN1 | en_US | en_US |
template0 | postgres | LATIN1 | en_US | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | LATIN1 | en_US | en_US | postgres=CTc/postgres+
| | | | | =c/postgres
(3 rows)

The same but tuples-only:
$ psql -p 50005 -d postgres -l -t
postgres | postgres | LATIN1 | en_US | en_US |
template0 | postgres | LATIN1 | en_US | en_US | =c/postgres +
| | | | | postgres=CTc/postgres
template1 | postgres | LATIN1 | en_US | en_US | postgres=CTc/postgres+
| | | | | =c/postgres

Using the -A to unaline output:
$ psql -p 50005 -d postgres -l -t -A
postgres|postgres|LATIN1|en_US|en_US|
template0|postgres|LATIN1|en_US|en_US|=c/postgres
postgres=CTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=CTc/postgres
=c/postgres

The issue also appears with output from the -c parameter:
$ psql -p 50005 -d postgres -c "\list" -t -A
postgres|postgres|LATIN1|en_US|en_US|
template0|postgres|LATIN1|en_US|en_US|=c/postgres
postgres=CTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=CTc/postgres
=c/postgres

Output should be:
$ psql -p 50005 -d postgres -l -t -A
postgres|postgres|LATIN1|en_US|en_US|
template0|postgres|LATIN1|en_US|en_US|=c/postgres
|||||postgres=CTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=CTc/postgres
|||||=c/postgres

It would even be better not to use the line splitting (with the + continuation sign) when asking for unalined output:
$ psql -p 50005 -d postgres -l -t -A
postgres|postgres|LATIN1|en_US|en_US|
template0|postgres|LATIN1|en_US|en_US|=c/postgres postgres=CTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=CTc/postgres =c/postgres

Derived problem (in trying to get a simple list of database names):
$ psql -p 50005 -d postgres -l -t -A | cut -d"|" -f1
postgres
template0
postgres=CTc/postgres <= shouldn't appear
template1
=c/postgres <= shouldn't appear

Workaround for the derived problem:
$ psql -p 50005 -d postgres -l -t | cut -d"|" -f1 | sed -e "s/ //g" | grep -v "^$"
postgres
template0
template1

Regards,
Kurt de Cauwsemaecker

Browse pgsql-bugs by date

  From Date Subject
Next Message David G. Johnston 2015-06-22 16:07:54 Re: Incomplete Explain for delete
Previous Message Ghislain ROUVIGNAC 2015-06-22 15:47:10 Incomplete Explain for delete