PostgreSQL version: 9.4.4 and previous 9.4
Ubuntu version: 14.04 LTS
psql -A parameter unalines continued data wrongly. The continued data jump=
s 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 | =3Dc/postgres =
+
| | | | | postgres=3DCTc/postgre=
s
template1 | postgres | LATIN1 | en_US | en_US | postgres=3DCTc/postgres=
+
| | | | | =3Dc/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 | =3Dc/postgres =
+
| | | | | postgres=3DCTc/postgre=
s
template1 | postgres | LATIN1 | en_US | en_US | postgres=3DCTc/postgres=
+
| | | | | =3Dc/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|=3Dc/postgres
postgres=3DCTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=3DCTc/postgres
=3Dc/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|=3Dc/postgres
postgres=3DCTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=3DCTc/postgres
=3Dc/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|=3Dc/postgres
|||||postgres=3DCTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=3DCTc/postgres
|||||=3Dc/postgres
It would even be better not to use the line splitting (with the + continuat=
ion 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|=3Dc/postgres postgres=3DCTc/postgres
template1|postgres|LATIN1|en_US|en_US|postgres=3DCTc/postgres =3Dc/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=3DCTc/postgres <=3D shouldn't appear
template1
=3Dc/postgres <=3D 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