pgcli: SQL errors are discarded when using the pspg pager
Description
I use the following settings in my pgclirc file:
pager = pspg --csv --rr=2 --quit-if-one-screen --ignore-case --csv-header on -s 4 -X
table_format = csv
and I’m quite happy, except for one notable defect: when I execute a query containing an error, pgcli does not properly handle the case and still emit the output coming from PG thru the pager, that simply discards it not being a CSV stream.
For example, not using the pager I get:
$ pgcli -h localhost -u user -d test
Server: PostgreSQL 11.8 (Debian 11.8-1.pgdg90+1)
Version: 3.0.0
Chat: https://gitter.im/dbcli/pgcli
Home: http://pgcli.com
user@localhost:test> select foo;
column "foo" does not exist
LINE 1: select foo
^
Time: 0.001s
while going thru pspg this is what I get:
$ pgcli -h localhost -u user -d test --pgclirc my.pgclirc
Server: PostgreSQL 11.8 (Debian 11.8-1.pgdg90+1)
Version: 3.0.0
Chat: https://gitter.im/dbcli/pgcli
Home: http://pgcli.com
user@localhost:test> select foo;
Time: 0.002s
Maybe the _evaluate_command() function should return that success flag to the caller and the latter emit the output without the pager?
Environment
$ pip freeze
cli-helpers==2.1.0
click==7.1.2
configobj==5.0.6
pendulum==2.1.2
-e git+https://github.com/dbcli/pgcli.git@8f7e31450835bca5d9a8bb4de252efba6f4b7b10#egg=pgcli
pgspecial==1.11.10
prompt-toolkit==3.0.5
psycopg2==2.8.4
pudb==2019.2
Pygments==2.6.1
python-dateutil==2.8.1
pytzdata==2020.1
setproctitle==1.1.10
six==1.15.0
sqlparse==0.3.1
tabulate==0.8.7
terminaltables==3.1.0
urwid==2.1.1
wcwidth==0.2.5
$ pspg --version
pspg-2.6.6
with readline (version: 0x0603)
with integrated menu
ncurses version: 6.1, patch: 20190112
ncurses with wide char support
ncurses widechar num: 1
wchar_t width: 4, max: 2147483647
with postgres client integration
The same happens with latest released version of pspg, 3.1.2.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 20 (14 by maintainers)
Commits related to this issue
- Quick and dirty fix to issue #1200 — committed to lelit/pgcli by lelit 4 years ago
- Quick and dirty fix to issue #1200 — committed to lelit/pgcli by lelit 4 years ago
so 12. 6. 2021 v 11:56 odesílatel Lele Gaifax @.***> napsal:
I modified pspg readme
Thank you for check
Pavel