From e5628c99835b93846519240e5577330b0752f95b Mon Sep 17 00:00:00 2001
From: Justin Pryzby <pryzbyj@telsasoft.com>
Date: Thu, 26 Mar 2020 22:33:56 -0500
Subject: [PATCH v15 3/6] 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 1adf12c3b9..897fea9692 100644
--- a/doc/src/sgml/ref/cluster.sgml
+++ b/doc/src/sgml/ref/cluster.sgml
@@ -103,7 +103,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 b97bd673a5..e989729327 100644
--- a/doc/src/sgml/ref/reindex.sgml
+++ b/doc/src/sgml/ref/reindex.sgml
@@ -191,7 +191,7 @@ REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { IN
     <term><replaceable class="parameter">new_tablespace</replaceable></term>
     <listitem>
      <para>
-      The name of a specific tablespace to store rebuilt indexes.
+      The tablespace where indexes will be rebuilt.
      </para>
     </listitem>
    </varlistentry>
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 894b1fb98f..abc84f8ff1 100644
--- a/src/backend/commands/cluster.c
+++ b/src/backend/commands/cluster.c
@@ -278,6 +278,9 @@ cluster(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 056e390698..d19d53f551 100644
--- a/src/backend/commands/indexcmds.c
+++ b/src/backend/commands/indexcmds.c
@@ -2742,8 +2742,8 @@ ReindexMultipleTables(const char *objectName, ReindexObjectType objectKind, char
 			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

