From cb6a523f47e9cfbed532484c21e7ee5699e24e2d Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Thu, 26 Mar 2020 22:33:56 -0500
Subject: [PATCH v16 5/7] fixes2

---
 doc/src/sgml/ref/cluster.sgml    | 2 +-
 doc/src/sgml/ref/reindex.sgml    | 2 +-
 doc/src/sgml/ref/vacuum.sgml     | 4 ++--
 src/backend/commands/cluster.c   | 3 +++
 src/backend/commands/indexcmds.c | 4 ++--
 5 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/doc/src/sgml/ref/cluster.sgml b/doc/src/sgml/ref/cluster.sgml
index 4847837765..a61a77a014 100644
--- a/doc/src/sgml/ref/cluster.sgml
+++ b/doc/src/sgml/ref/cluster.sgml
@@ -112,7 +112,7 @@ CLUSTER [VERBOSE]
     <term><replaceable class="parameter">new_tablespace</replaceable></term>
     <listitem>
      <para>
-      The name of a specific tablespace to store clustered relations.
+      The tablespace where the clustered relation will be rebuilt.
      </para>
     </listitem>
    </varlistentry>
diff --git a/doc/src/sgml/ref/reindex.sgml b/doc/src/sgml/ref/reindex.sgml
index 635c762f18..1f692aec60 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -166,7 +166,7 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { IN
     <term><literal>TABLESPACE</literal></term>
     <listitem>
      <para>
-      This specifies a tablespace, where all rebuilt indexes will be created.
+      This specifies that indexes will be rebuilt on a new tablespace.
       Cannot be used with "mapped" relations. If <literal>SCHEMA</literal>,
       <literal>DATABASE</literal> or <literal>SYSTEM</literal> is specified, then
       all unsuitable relations will be skipped and a single <literal>WARNING</literal>
diff --git a/doc/src/sgml/ref/vacuum.sgml b/doc/src/sgml/ref/vacuum.sgml
index 0a00125a36..681486bb38 100644
--- a/doc/src/sgml/ref/vacuum.sgml
+++ b/doc/src/sgml/ref/vacuum.sgml
@@ -22,7 +22,7 @@ PostgreSQL documentation
  <refsynopsisdiv>
 <synopsis>
 VACUUM [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
-VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
+VACUUM [ FULL ] [ FREEZE ] [ VERBOSE ] [ ANALYZE ] [ TABLESPACE <replaceable class="parameter">new_tablespace</replaceable> ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
 VACUUM ( FULL [, ...] ) [ TABLESPACE <replaceable class="parameter">new_tablespace</replaceable> ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
 
 <phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>
@@ -305,7 +305,7 @@ VACUUM ( FULL [, ...] ) [ TABLESPACE <replaceable class="parameter">new_tablespa
     <term><replaceable class="parameter">new_tablespace</replaceable></term>
     <listitem>
      <para>
-      The name of a specific tablespace to write a new copy of the table.
+      The tablespace where the table will be rebuilt.
      </para>
     </listitem>
    </varlistentry>
diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c
index 7c52bb470f..ef8b1c9a82 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -281,6 +281,9 @@ cluster(ParseState *pstate, ClusterStmt *stmt, bool isTopLevel)
  * If indexOid is InvalidOid, the table will be rewritten in physical order
  * instead of index order.  This is the new implementation of VACUUM FULL,
  * and error messages should refer to the operation as VACUUM not CLUSTER.
+ *
+ * "tablespaceOid" is the tablespace to use for the rebuilt relation.  If
+ * InvalidOid, use the tablespace in-use instead.
  */
 void
 cluster_rel(Oid tableOid, Oid indexOid, Oid tablespaceOid, int options)
diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c
index 3ff8d4f006..9c09f2cbdc 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -2745,8 +2745,8 @@ ReindexMultipleTables(ReindexStmt *stmt)
 			else if (!OidIsValid(classtuple->relfilenode))
 			{
 				/*
-				 * Skip all mapped relations.
-				 * relfilenode == 0 checks after that, similarly to
+				 * Skip all mapped relations if TABLESPACE is specified.
+				 * OidIsValid(relfilenode) checks that, similar to
 				 * RelationIsMapped().
 				 */
 				if (!tablespace_warning)
-- 
2.17.0

