psql --no-connect option

From: Gurjeet Singh <gurjeet(at)singh(dot)im>
To: Postgres Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: psql --no-connect option
Date: 2023-08-24 19:55:30
Message-ID: CABwTF4VzohGJQ_D98zLR9o5JDB2iaiKTaaVhY55WA=X-txdswQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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 Content-Type Size
psql_no_connect.diff application/octet-stream 1.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2023-08-24 21:00:27 Re: Checks in RegisterBackgroundWorker.()
Previous Message Tristan Partin 2023-08-24 19:52:59 Re: Make documentation builds reproducible