postgresql/src/bin/psql
Tom Lane d5a905ed5e Fix psql's \connect command some more.
Jasen Betts reported yet another unintended side effect of commit
85c54287a: reconnecting with "\c service=whatever" did not have the
expected results.  The reason is that starting from the output of
PQconndefaults() effectively allows environment variables (such
as PGPORT) to override entries in the service file, whereas the
normal priority is the other way around.

Not using PQconndefaults at all would require yet a third main code
path in do_connect's parameter setup, so I don't really want to fix
it that way.  But we can have the logic effectively ignore all the
default values for just a couple more lines of code.

This patch doesn't change the behavior for "\c -reuse-previous=on
service=whatever".  That remains significantly different from before
85c54287a, because many more parameters will be re-used, and thus
not be possible for service entries to replace.  But I think this
is (mostly?) intentional.  In any case, since libpq does not report
where it got parameter values from, it's hard to do differently.

Per bug #16936 from Jasen Betts.  As with the previous patches,
back-patch to all supported branches.  (9.5 is unfortunately now
out of support, so this won't get fixed there.)

Discussion: https://postgr.es/m/16936-3f524322a53a29f0@postgresql.org
2021-03-23 14:27:50 -04:00
..
po Translation updates 2021-02-08 18:07:32 +01:00
.gitignore Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
command.c Fix psql's \connect command some more. 2021-03-23 14:27:50 -04:00
command.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
common.c Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:13 -08:00
common.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
conditional.c Support \if ... \elif ... \else ... \endif in psql scripting. 2017-03-30 12:59:24 -04:00
conditional.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
copy.c Fix psql's "\g target" meta-command to work with COPY TO STDOUT. 2019-01-26 14:15:42 -05:00
copy.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
create_help.pl Clean up Perl code according to perlcritic 2017-03-27 08:18:22 -04:00
crosstabview.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
crosstabview.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
describe.c Fix infelicities in describeOneTableDetails' partitioned-table handling. 2019-07-24 18:14:27 -04:00
describe.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
help.c Code review for psql's helpSQL() function. 2021-01-26 13:04:52 -05:00
help.h Update copyright via script for 2017 2017-01-03 13:48:53 -05:00
input.c Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
input.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
large_obj.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
large_obj.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
mainloop.c Phase 3 of pgindent updates. 2017-06-21 15:35:54 -04:00
mainloop.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
Makefile Prevent accidental linking of system-supplied copies of libpq.so etc. 2018-07-09 17:23:31 -04:00
nls.mk Translation updates 2018-08-06 20:03:55 +02:00
prompt.c Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
prompt.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscanslash.h Support \if ... \elif ... \else ... \endif in psql scripting. 2017-03-30 12:59:24 -04:00
psqlscanslash.l Use mode "r" for popen() in psql's evaluate_backtick(). 2020-10-28 14:35:53 -04:00
settings.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
startup.c Avoid platform-specific null pointer dereference in psql. 2019-08-25 15:04:04 -04:00
stringutils.c Initial pgindent run with pg_bsd_indent version 2.0. 2017-06-21 14:39:04 -04:00
stringutils.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
tab-complete.c psql: do file completion for \gx 2020-03-31 23:01:33 -04:00
tab-complete.h Phase 2 of pgindent updates. 2017-06-21 15:19:25 -04:00
variables.c Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:13 -08:00
variables.h Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:13 -08:00