postgresql/src/bin/psql
Tom Lane 523adcc129 Make psql's \password default to CURRENT_USER, not PQuser(conn).
The documentation says plainly that \password acts on "the current user"
by default.  What it actually acted on, or tried to, was the username
used to log into the current session.  This is not the same thing if
one has since done SET ROLE or SET SESSION AUTHENTICATION.  Aside from
the possible surprise factor, it's quite likely that the current role
doesn't have permissions to set the password of the original role.

To fix, use "SELECT CURRENT_USER" to get the role name to act on.
(This syntax works with servers at least back to 7.0.)  Also, in
hopes of reducing confusion, include the role name that will be
acted on in the password prompt.

The discrepancy from the documentation makes this a bug, so
back-patch to all supported branches.

Patch by me; thanks to Nathan Bossart for review.

Discussion: https://postgr.es/m/747443.1635536754@sss.pgh.pa.us
2021-11-12 14:55:32 -05:00
..
po Translation updates 2021-11-08 10:09:13 +01:00
.gitignore Move psql's psqlscan.l into src/fe_utils. 2016-03-24 20:28:47 -04:00
command.c Make psql's \password default to CURRENT_USER, not PQuser(conn). 2021-11-12 14:55:32 -05:00
command.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
common.c Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
common.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
copy.c Initial pgindent run for v12. 2019-05-22 12:55:34 -04:00
copy.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
create_help.pl psql: Add documentation URL to \help output 2019-03-11 09:11:37 +01:00
crosstabview.c Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
crosstabview.h Fix assorted header files that failed to compile standalone. 2019-05-31 11:45:33 -04:00
describe.c psql \dP: reference regclass with "pg_catalog." prefix 2021-08-28 11:45:47 -04:00
describe.h psql \dP: list partitioned tables and indexes 2019-04-07 15:07:21 -04:00
help.c Fix inconsistencies in psql --help=commands 2021-06-09 16:25:57 +09:00
help.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
input.c Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
input.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
large_obj.c Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
large_obj.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
mainloop.c Move logging.h and logging.c from src/fe_utils/ to src/common/. 2019-05-14 14:20:10 -04:00
mainloop.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
Makefile Update copyright for 2019 2019-01-02 12:44:25 -05:00
nls.mk Translation updates 2020-02-10 13:15:42 +01:00
prompt.c More unconstify use 2019-02-13 11:50:16 +01:00
prompt.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
psqlrc.sample Improve FILES section of psql reference page. 2014-01-14 19:27:57 -05:00
psqlscanslash.h Update copyright for 2019 2019-01-02 12:44:25 -05:00
psqlscanslash.l Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
settings.h tableam: introduce table AM infrastructure. 2019-03-06 09:54:38 -08:00
startup.c Fix redundant error messages in client tools 2020-11-07 22:42:17 +01:00
stringutils.c Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
stringutils.h Phase 2 pgindent run for v12. 2019-05-22 13:04:48 -04:00
tab-complete.c Fix incautious handling of possibly-miscoded strings in client code. 2021-06-07 14:15:25 -04:00
tab-complete.h Update copyright for 2019 2019-01-02 12:44:25 -05: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