psqlrc overrides command line flags in PG 9.6

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: psqlrc overrides command line flags in PG 9.6
Date: 2017-03-29 14:28:06
Message-ID: CA+mi_8a0UeuKLnCvKN2h87dwSgJJTCSxGMr-RzohqfDhPGuf7A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

In PG 9.6 -c doesn't imply -X anymore, that's fine (well, not really,
but let's say it is).

However it seems it is no more possible to *override* what's in the
psqlrc unless the config file is disabled altogether. E.g. alignment
has a default and a different alternative can be set on command line:

$ rm ~/.psqlrc

$ psql -c "select E'1\n2' as foo"
foo
-----
1 +
2
(1 row)

$ psql -A -c "select E'1\n2' as foo"
foo
1
2
(1 row)

$ psql --pset format=unaligned -c "select E'1\n2' as foo"
foo
1
2
(1 row)

If something is specified in the psqlrc, it overrides the command line too:

$ echo '\pset format wrapped' > ~/.psqlrc

$ psql -A -c "select E'1\n2' as foo"
Output format is wrapped.
foo
-----
1 +
2
(1 row)

$ psql --pset format=unaligned -c "select E'1\n2' as foo"
Output format is wrapped.
foo
-----
1 +
2
(1 row)

The only way to have the command line working is to disable psqlrc

$ psql -AX -c "select E'1\n2' as foo"
foo
1
2
(1 row)

The command line is more specific than the configuration file: I think
it should override what defined there.

-- Daniele

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2017-03-29 14:35:42 Re: psqlrc overrides command line flags in PG 9.6
Previous Message cevatcekli 2017-03-29 14:27:10 BUG #14602: Fedora 20 + PG 9.3 Cannot retrive metalink