postgresql/src/bin/psql
Tom Lane 4f670c64ef 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:10:23 +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 Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
common.c Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:14 -08:00
common.h Move psql's print.c and mbprint.c into src/fe_utils. 2016-03-24 18:27:28 -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 for 2016 2016-01-02 13:33:40 -05:00
create_help.pl Clean up some misplaced #includes. 2016-03-18 13:43:17 -04:00
crosstabview.c Fix incorrect error reporting for duplicate data in \crosstabview. 2016-12-25 16:04:47 -05:00
crosstabview.h Improve coding of column-name parsing in psql's new crosstabview.c. 2016-04-12 12:52:42 -04:00
describe.c Clean up SQL emitted by psql/describe.c. 2017-07-26 19:36:19 -04:00
describe.h Fix loose ends for SQL ACCESS METHOD objects 2016-06-07 17:59:34 -04:00
help.c Code review for psql's helpSQL() function. 2021-01-26 13:04:52 -05:00
help.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
input.c Guard against empty buffer in gets_fromFile()'s check for a newline. 2016-07-28 18:57:24 -04:00
input.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
large_obj.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
large_obj.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
mainloop.c Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
mainloop.h Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -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 19:44:29 +02:00
prompt.c pgindent run for 9.6 2016-06-09 18:02:36 -04:00
prompt.h Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscanslash.h Avoid code duplication in \crosstabview. 2016-04-17 11:37:58 -04:00
psqlscanslash.l Use mode "r" for popen() in psql's evaluate_backtick(). 2020-10-28 14:35:53 -04:00
settings.h Rethink \crosstabview's argument parsing logic. 2016-04-14 22:54:31 -04:00
startup.c Avoid platform-specific null pointer dereference in psql. 2019-08-25 15:04:04 -04:00
stringutils.c Update copyright for 2016 2016-01-02 13:33:40 -05:00
stringutils.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
tab-complete.c Fix tab completion for ALTER LANGUAGE in psql 2019-08-05 14:30:34 +09:00
tab-complete.h Update copyright for 2016 2016-01-02 13:33:40 -05:00
variables.c Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:14 -08:00
variables.h Ignore attempts to \gset into specially treated variables. 2020-11-09 07:32:14 -08:00