summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2020-10-19 19:03:47 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2020-10-19 19:03:47 -0400
commit5a9f99bed8cbd4a2aafaedbf464eedf9ae9e73a8 (patch)
treeb7fdd54054d7a14595705c63ed0b54c71aa8cfb2 /doc
parent1e17fb93571926ec225587abbb7eb11e4523c175 (diff)
Fix connection string handling in src/bin/scripts/ programs.
When told to process all databases, clusterdb, reindexdb, and vacuumdb would reconnect by replacing their --maintenance-db parameter with the name of the target database. If that parameter is a connstring (which has been allowed for a long time, though we failed to document that before this patch), we'd lose any other options it might specify, for example SSL or GSS parameters, possibly resulting in failure to connect. Thus, this is the same bug as commit a45bc8a4f fixed in pg_dump and pg_restore. We can fix it in the same way, by using libpq's rules for handling multiple "dbname" parameters to add the target database name separately. I chose to apply the same refactoring approach as in that patch, with a struct to handle the command line parameters that need to be passed through to connectDatabase. (Maybe someday we can unify the very similar functions here and in pg_dump/pg_restore.) Per Peter Eisentraut's comments on bug #16604. Back-patch to all supported branches. Discussion: https://postgr.es/m/16604-933f4b8791227b15@postgresql.org
Diffstat (limited to 'doc')
-rw-r--r--doc/src/sgml/ref/clusterdb.sgml20
-rw-r--r--doc/src/sgml/ref/createdb.sgml3
-rw-r--r--doc/src/sgml/ref/dropdb.sgml3
-rw-r--r--doc/src/sgml/ref/reindexdb.sgml20
-rw-r--r--doc/src/sgml/ref/vacuumdb.sgml20
5 files changed, 45 insertions, 21 deletions
diff --git a/doc/src/sgml/ref/clusterdb.sgml b/doc/src/sgml/ref/clusterdb.sgml
index 95b9e2cf4a5..6164bcd53ac 100644
--- a/doc/src/sgml/ref/clusterdb.sgml
+++ b/doc/src/sgml/ref/clusterdb.sgml
@@ -90,9 +90,9 @@ PostgreSQL documentation
<term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to be clustered.
- If this is not specified and <option>-a</option> (or
- <option>--all</option>) is not used, the database name is read
+ Specifies the name of the database to be clustered,
+ when <option>-a</option>/<option>--all</option> is not used.
+ If this is not specified, the database name is read
from the environment variable <envar>PGDATABASE</envar>. If
that is not set, the user name specified for the connection is
used. The <replaceable>dbname</replaceable> can be a <link
@@ -249,10 +249,16 @@ PostgreSQL documentation
<term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to connect to discover what other
- databases should be clustered. If not specified, the
- <literal>postgres</literal> database will be used,
- and if that does not exist, <literal>template1</literal> will be used.
+ Specifies the name of the database to connect to to discover which
+ databases should be clustered,
+ when <option>-a</option>/<option>--all</option> is used.
+ If not specified, the <literal>postgres</literal> database will be used,
+ or if that does not exist, <literal>template1</literal> will be used.
+ This can be a <link linkend="libpq-connstring">connection
+ string</link>. If so, connection string parameters will override any
+ conflicting command line options. Also, connection string parameters
+ other than the database name itself will be re-used when connecting
+ to other databases.
</para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/createdb.sgml b/doc/src/sgml/ref/createdb.sgml
index 2658efeb1a1..7f978fadeca 100644
--- a/doc/src/sgml/ref/createdb.sgml
+++ b/doc/src/sgml/ref/createdb.sgml
@@ -286,6 +286,9 @@ PostgreSQL documentation
database will be used; if that does not exist (or if it is the name
of the new database being created), <literal>template1</literal> will
be used.
+ This can be a <link linkend="libpq-connstring">connection
+ string</link>. If so, connection string parameters will override any
+ conflicting command line options.
</para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/dropdb.sgml b/doc/src/sgml/ref/dropdb.sgml
index 38f38f01ce6..3323a1f754e 100644
--- a/doc/src/sgml/ref/dropdb.sgml
+++ b/doc/src/sgml/ref/dropdb.sgml
@@ -205,6 +205,9 @@ PostgreSQL documentation
target database. If not specified, the <literal>postgres</literal>
database will be used; if that does not exist (or is the database
being dropped), <literal>template1</literal> will be used.
+ This can be a <link linkend="libpq-connstring">connection
+ string</link>. If so, connection string parameters will override any
+ conflicting command line options.
</para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/reindexdb.sgml b/doc/src/sgml/ref/reindexdb.sgml
index b3313d04a43..e8faaa826a4 100644
--- a/doc/src/sgml/ref/reindexdb.sgml
+++ b/doc/src/sgml/ref/reindexdb.sgml
@@ -123,9 +123,9 @@ PostgreSQL documentation
<term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to be reindexed.
- If this is not specified and <option>-a</option> (or
- <option>--all</option>) is not used, the database name is read
+ Specifies the name of the database to be reindexed,
+ when <option>-a</option>/<option>--all</option> is not used.
+ If this is not specified, the database name is read
from the environment variable <envar>PGDATABASE</envar>. If
that is not set, the user name specified for the connection is
used. The <replaceable>dbname</replaceable> can be a <link
@@ -317,10 +317,16 @@ PostgreSQL documentation
<term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to connect to discover what other
- databases should be reindexed. If not specified, the
- <literal>postgres</literal> database will be used,
- and if that does not exist, <literal>template1</literal> will be used.
+ Specifies the name of the database to connect to to discover which
+ databases should be reindexed,
+ when <option>-a</option>/<option>--all</option> is used.
+ If not specified, the <literal>postgres</literal> database will be used,
+ or if that does not exist, <literal>template1</literal> will be used.
+ This can be a <link linkend="libpq-connstring">connection
+ string</link>. If so, connection string parameters will override any
+ conflicting command line options. Also, connection string parameters
+ other than the database name itself will be re-used when connecting
+ to other databases.
</para>
</listitem>
</varlistentry>
diff --git a/doc/src/sgml/ref/vacuumdb.sgml b/doc/src/sgml/ref/vacuumdb.sgml
index 366873ba308..92f08b82b75 100644
--- a/doc/src/sgml/ref/vacuumdb.sgml
+++ b/doc/src/sgml/ref/vacuumdb.sgml
@@ -92,9 +92,9 @@ PostgreSQL documentation
<term><option><optional>--dbname=</optional><replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to be cleaned or analyzed.
- If this is not specified and <option>-a</option> (or
- <option>--all</option>) is not used, the database name is read
+ Specifies the name of the database to be cleaned or analyzed,
+ when <option>-a</option>/<option>--all</option> is not used.
+ If this is not specified, the database name is read
from the environment variable <envar>PGDATABASE</envar>. If
that is not set, the user name specified for the connection is
used. The <replaceable>dbname</replaceable> can be a <link
@@ -342,10 +342,16 @@ PostgreSQL documentation
<term><option>--maintenance-db=<replaceable class="parameter">dbname</replaceable></option></term>
<listitem>
<para>
- Specifies the name of the database to connect to discover what other
- databases should be vacuumed. If not specified, the
- <literal>postgres</literal> database will be used,
- and if that does not exist, <literal>template1</literal> will be used.
+ Specifies the name of the database to connect to to discover which
+ databases should be vacuumed,
+ when <option>-a</option>/<option>--all</option> is used.
+ If not specified, the <literal>postgres</literal> database will be used,
+ or if that does not exist, <literal>template1</literal> will be used.
+ This can be a <link linkend="libpq-connstring">connection
+ string</link>. If so, connection string parameters will override any
+ conflicting command line options. Also, connection string parameters
+ other than the database name itself will be re-used when connecting
+ to other databases.
</para>
</listitem>
</varlistentry>