From: Paul Förster <paul.foerster@gmail.com>
To: pgsql-general list <pgsql-general@lists.postgresql.org>
Subject: PostgreSQL URI
Date: Thu, 25 Feb 2021 15:45:46 +0100
Message-ID: <6E752D6B-487C-463E-B6E2-C32E7FB007EA@gmail.com> (raw)
Hi,
in https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING it says that the syntax for a PostgreSQL URI is:
postgresql://[user[:password]@][host][:port][,...][/dbname][?param1=value1&...]
What I don't understand is the [,...] part, i.e. optionally repeating argument.
I know that this is a valid URI:
postgresql://user1:pass1@host1:port1,host2:port2/dbname?target_session_attrs=read-write
But is the following valid?
postgresql://user1:pass1@host1:port1,user2:pass2@host2:port2/dbname?target_session_attrs=read-write
i.e. can (or should) the user[:pass] part be repeated, and possibly can even be different, if I provide more than one host:port information? Or is the user[:pass] part definitely a one-time only argument and must not appear a second time? I don't know how to read this repetition [,...] syntax. A repeat syntax usually means providing more parameters like the one immediately before that, which in this case, is the port.
I think, it should be more correct this way (note the angle bracket):
postgresql://[user[:password]@][host[:port]][,...][/dbname][?param1=value1&...]
I tried this with psql but failed miserably, though both user1:pass1 and user2:pass2 exist on both databases.
The documentation also claims that any of the parts is optional except the postgresql:// part. This means, specifying a port without a host would be perfectly fine, which IMHO makes no sense.
Can someone enlighten me? Is this just a misleading line to me in the documentation?
Cheers,
Paul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: paul.foerster@gmail.com
Subject: Re: PostgreSQL URI
In-Reply-To: <6E752D6B-487C-463E-B6E2-C32E7FB007EA@gmail.com>
References: <6E752D6B-487C-463E-B6E2-C32E7FB007EA@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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