psql feature request: --list-conninfo (dump the config info psql would use to connect)

From: David Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: psql feature request: --list-conninfo (dump the config info psql would use to connect)
Date: 2014-12-23 02:55:56
Message-ID: CAKFQuwbG0CWv9Sq-aHShjWUHqy4P0vmH1mLa_7Xk4eBXz8bMSA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

When psql (libpq) connects it uses a combination of defaults, environment
variables, command line arguments, and possibly a pg_service file to figure
out where it is going to connect, and how.

Specifying the option "--list-conninfo" as an option would cause psql to
simply output all of the valid "conninfo" parameters and their current
value. It could also indicate whether a matching .pgpass entry was found.
By default it would not return the open connection - only dump the data.
However, when the "list-conninfo-prompt" option is provided psql would
finish the display with a prompt -:"do you wish to connect to this
database?". Ideally an option of the form
list-conninfo-fields='dbname,username,host,port' could be used to limit the
displayed fields - especially useful with the prompt option so that the
user does not get a screen full of data to skim. A default config could be
designed and made available while in prompt mode (non-prompt mode would
list everything) and the -fields option would simply provide an override.

I see a use for this in semi-automatic scripts where you wish to add a
measure of safety by allowing the user to at least review the connection
setup once in the script before using the same connection string on
subsequent attempts without prompting. It would also make a useful
debugging tool.

The interaction of this and various authentication mechanisms would be
worth exploring in detail - even if it takes an actual connection attempt
to work the details out.

While outside the scope of PostgreSQL itself the interaction with tools
like pgPool and pgBouncer would be worthwhile - i.e., the ability to
pass-through what your intermediary is going to be using to connect.

My goal in posting this is to get a reaction and hopefully, if favorable,
get this added to the Wiki ToDo area. Its not something I have the ability
to code or desire to directly fund but it does seem like a feature that
would contribute to new user friendliness and ease-of-use.

Thanks!

David J.

Browse pgsql-general by date

  From Date Subject
Next Message Cory Zue 2014-12-23 03:17:28 help troubleshooting invalid page header error
Previous Message Lacey Powers 2014-12-22 19:22:20 Re: 9.3.5 failing to compile with dtrace on FreeBSD 10.1