Currently, psql exits if a database connection is not established when
psql is launched.

Sometimes it may be useful to launch psql without connecting to the
database. For example, a user may choose to start psql and then pipe
commands via stdin, one of which may eventually perform the \connect
command. Or the user may be interested in performing operations that
psql can perform, like setting variables etc., before optionally
initiating a connection.

The attached patch introduces the --no-connect option, which allows
psql to continue operation in absence of connection options.

This patch is nowhere close to finished, but I'm posting it here to
gauge interest in the feature. For example, this patch results in an
undesirable output (0.0 server version), as seen below.

$ psql --no-connect
psql (17devel, server 0.0.0)
WARNING: psql major version 17, server major version 0.0.
         Some psql features might not work.
Type "help" for help.

!?>

The patch needs many improvements, like not expecting to inherit
connection options from a previous connection, etc., but mostly in
identifying the conflicting options; an example of this is included in
the patch where psql throws an error if --no-connect and --list are
specified together.

$ psql --no-connect --list
psql: error: --no-connect cannot be specified with --list

Best regards,
Gurjeet
http://Gurje.et

Attachment: psql_no_connect.diff
Description: Binary data

Reply via email to