pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
6+ messages / 4 participants
[nested] [flat]
* BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2017-11-16 17:17 mhwood@ameritech.net
0 siblings, 1 reply; 6+ messages in thread
From: mhwood@ameritech.net @ 2017-11-16 17:17 UTC (permalink / raw)
To: pgsql-bugs; +Cc: mhwood@ameritech.net
The following bug has been logged on the website:
Bug reference: 14912
Logged by: Mark Wood
Email address: mhwood@ameritech.net
PostgreSQL version: 9.6.6
Operating system: Gentoo Linux, kernel 4.12, glibc 2.25-r9
Description:
The 'psql' man page explains that the default database name is your OS
username, and that $PGDATABASE can be used to supply a different default.
That is true *unless* using -l / --list. The code shows that this option
defaults to 'postgresql' instead, overriding the libpq defaulting. I spent
quite some time reading and experimenting to determine why I was not seeing
the documented behavior.
The actual behavior may be reasonable, but if so it should be documented as
an exception for the --list function.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2017-11-16 21:27 David G. Johnston <david.g.johnston@gmail.com>
parent: mhwood@ameritech.net
0 siblings, 2 replies; 6+ messages in thread
From: David G. Johnston @ 2017-11-16 21:27 UTC (permalink / raw)
To: mhwood@ameritech.net; +Cc: pgsql-bugs
On Thu, Nov 16, 2017 at 10:17 AM, <mhwood@ameritech.net> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 14912
> Logged by: Mark Wood
> [...]
>
> That is true *unless* using -l / --list. The code shows that this option
> defaults to 'postgresql' instead, overriding the libpq defaulting.
>
It actually defaults to "postgres"
[...]
> The actual behavior may be reasonable, but if so it should be documented as
> an exception for the --list function.
>
I can see an argument for either default, but given that this invocation
has never defaulted to the user's database I cannot see changing it.
I agree this should be considered a doc bug and back-patched. Possible
verbiage for master below and attached.
Changing the "Usage" section to point out this exception to the rule seems
undesirable.
David J.
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index e520cdf3ba..ad2a505b1e 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -283,7 +283,9 @@ EOF
<listitem>
<para>
List all available databases, then exit. Other non-connection
- options are ignored. This is similar to the meta-command
+ options are ignored. If an explicit database name is not
+ found the <literal>postgres</literal> database, not the user's,
+ will be targeted for connection. This is similar to the meta-command
<command>\list</command>.
</para>
</listitem>
Attachments:
psql-list-command-dbname-fix.patch (application/octet-stream, 654B) download
diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
index e520cdf3ba..ad2a505b1e 100644
--- a/doc/src/sgml/ref/psql-ref.sgml
+++ b/doc/src/sgml/ref/psql-ref.sgml
@@ -283,7 +283,9 @@ EOF
<listitem>
<para>
List all available databases, then exit. Other non-connection
- options are ignored. This is similar to the meta-command
+ options are ignored. If an explicit database name is not
+ found the <literal>postgres</literal> database, not the user's,
+ will be targeted for connection. This is similar to the meta-command
<command>\list</command>.
</para>
</listitem>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2018-01-23 23:23 Bruce Momjian <bruce@momjian.us>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 0 replies; 6+ messages in thread
From: Bruce Momjian @ 2018-01-23 23:23 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: pgsql-bugs
Patch applied and backpatched through PG 10. Thanks.
---------------------------------------------------------------------------
On Thu, Nov 16, 2017 at 02:27:06PM -0700, David G. Johnston wrote:
> On Thu, Nov 16, 2017 at 10:17 AM, <mhwood@ameritech.net> wrote:
>
> The following bug has been logged on the website:
>
> Bug reference: 14912
> Logged by: Mark Wood
> [...]
>
> That is true *unless* using -l / --list. The code shows that this option
> defaults to 'postgresql' instead, overriding the libpq defaulting.
>
>
> It actually defaults to "postgres"
>
> [...]
>
>
> The actual behavior may be reasonable, but if so it should be documented as
> an exception for the --list function.
>
>
> I can see an argument for either default, but given that this invocation has
> never defaulted to the user's database I cannot see changing it.
>
> I agree this should be considered a doc bug and back-patched. Possible
> verbiage for master below and attached.
>
> Changing the "Usage" section to point out this exception to the rule seems
> undesirable.
>
> David J.
>
> diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
> index e520cdf3ba..ad2a505b1e 100644
> --- a/doc/src/sgml/ref/psql-ref.sgml
> +++ b/doc/src/sgml/ref/psql-ref.sgml
> @@ -283,7 +283,9 @@ EOF
> <listitem>
> <para>
> List all available databases, then exit. Other non-connection
> - options are ignored. This is similar to the meta-command
> + options are ignored. If an explicit database name is not
> + found the <literal>postgres</literal> database, not the user's,
> + will be targeted for connection. This is similar to the meta-command
> <command>\list</command>.
> </para>
> </listitem>
>
>
> diff --git a/doc/src/sgml/ref/psql-ref.sgml b/doc/src/sgml/ref/psql-ref.sgml
> index e520cdf3ba..ad2a505b1e 100644
> --- a/doc/src/sgml/ref/psql-ref.sgml
> +++ b/doc/src/sgml/ref/psql-ref.sgml
> @@ -283,7 +283,9 @@ EOF
> <listitem>
> <para>
> List all available databases, then exit. Other non-connection
> - options are ignored. This is similar to the meta-command
> + options are ignored. If an explicit database name is not
> + found the <literal>postgres</literal> database, not the user's,
> + will be targeted for connection. This is similar to the meta-command
> <command>\list</command>.
> </para>
> </listitem>
--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ As you are, so once was I. As I am, so you will be. +
+ Ancient Roman grave inscription +
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2018-02-02 21:49 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Peter Eisentraut @ 2018-02-02 21:49 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; mhwood@ameritech.net; +Cc: pgsql-bugs
On 11/16/17 16:27, David G. Johnston wrote:
> List all available databases, then exit. Other non-connection
> - options are ignored. This is similar to the meta-command
> + options are ignored. If an explicit database name is not
> + found the <literal>postgres</literal> database, not the user's,
> + will be targeted for connection. This is similar to the meta-command
> <command>\list</command>.
What does "an explicit database name is not found" mean? How does one
find an explicit database name?
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2018-02-02 22:05 David G. Johnston <david.g.johnston@gmail.com>
parent: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
0 siblings, 1 reply; 6+ messages in thread
From: David G. Johnston @ 2018-02-02 22:05 UTC (permalink / raw)
To: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>; +Cc: Mark Wood <mhwood@ameritech.net>; pgsql-bugs
On Fri, Feb 2, 2018 at 2:49 PM, Peter Eisentraut <
peter.eisentraut@2ndquadrant.com> wrote:
> On 11/16/17 16:27, David G. Johnston wrote:
> > List all available databases, then exit. Other non-connection
> > - options are ignored. This is similar to the meta-command
> > + options are ignored. If an explicit database name is not
> > + found the <literal>postgres</literal> database, not the user's,
> > + will be targeted for connection. This is similar to the
> meta-command
> > <command>\list</command>.
>
> What does "an explicit database name is not found" mean?
A name was not supplied to the psql command either as the first non-option
argument, via the --dbname command line option, in the connection URI
(possibly indirectly via a pg_service.conf entry), or via the PGDATABASE
environment variable.
How does one
> find an explicit database name?
>
Given the answer above does this question still apply?
David J.
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER
@ 2018-02-03 16:05 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: David G. Johnston <david.g.johnston@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2018-02-03 16:05 UTC (permalink / raw)
To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: Mark Wood <mhwood@ameritech.net>; pgsql-bugs
On 2/2/18 17:05, David G. Johnston wrote:
> What does "an explicit database name is not found" mean?
>
> A name was not supplied to the psql command either as the first
> non-option argument, via the --dbname command line option, in the
> connection URI (possibly indirectly via a pg_service.conf entry), or via
> the PGDATABASE environment variable.
OK, clarified that a bit further. Actually, an environment variable
does not take any effect for this.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2018-02-03 16:05 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-11-16 17:17 BUG #14912: Undocumented: 'psql -l' assumes database 'postgresql' not $USER mhwood@ameritech.net
2017-11-16 21:27 ` David G. Johnston <david.g.johnston@gmail.com>
2018-01-23 23:23 ` Bruce Momjian <bruce@momjian.us>
2018-02-02 21:49 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2018-02-02 22:05 ` David G. Johnston <david.g.johnston@gmail.com>
2018-02-03 16:05 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox