From 3964348533b73cd68c11074c173b66d37b8b51d1 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Tue, 17 Jan 2017 16:29:32 +0900
Subject: [PATCH 2/2] Rename pg_subtrans to pg_subxact

pg_upgrade is updated to handle the transfer correctly to post-10
clusters.
---
 doc/src/sgml/backup.sgml                     |  2 +-
 doc/src/sgml/func.sgml                       |  2 +-
 doc/src/sgml/protocol.sgml                   |  2 +-
 doc/src/sgml/storage.sgml                    |  2 +-
 doc/src/sgml/wal.sgml                        |  2 +-
 src/backend/access/transam/README            | 18 +++++++++---------
 src/backend/access/transam/subtrans.c        |  8 ++++----
 src/backend/access/transam/transam.c         | 10 +++++-----
 src/backend/access/transam/twophase.c        |  6 +++---
 src/backend/access/transam/varsup.c          |  6 +++---
 src/backend/access/transam/xact.c            |  2 +-
 src/backend/access/transam/xlog.c            |  8 ++++----
 src/backend/replication/basebackup.c         |  2 +-
 src/backend/replication/logical/snapbuild.c  |  2 +-
 src/backend/storage/ipc/procarray.c          | 14 +++++++-------
 src/backend/utils/time/tqual.c               |  2 +-
 src/bin/initdb/initdb.c                      |  2 +-
 src/bin/pg_basebackup/t/010_pg_basebackup.pl |  2 +-
 src/bin/pg_upgrade/exec.c                    |  7 ++++++-
 src/include/access/slru.h                    |  4 ++--
 src/include/storage/proc.h                   |  2 +-
 21 files changed, 55 insertions(+), 50 deletions(-)

diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index 0c56c9d068..a5a9b879e7 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -1093,7 +1093,7 @@ SELECT pg_stop_backup();
     The contents of the directories <filename>pg_dynshmem/</>,
     <filename>pg_notify/</>, <filename>pg_serial/</>,
     <filename>pg_snapshots/</>, <filename>pg_stat_tmp/</>,
-    and <filename>pg_subtrans/</> (but not the directories themselves) can be
+    and <filename>pg_subxact/</> (but not the directories themselves) can be
     omitted from the backup as they will be initialized on postmaster startup.
     If <xref linkend="guc-stats-temp-directory"> is set and is under the data
     directory then the contents of that directory can also be omitted.
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 865f74a260..e433b99f30 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15328,7 +15328,7 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
  pg_wal          | 16
  pg_hba.conf     | 17
  pg_stat_tmp     | 18
- pg_subtrans     | 19
+ pg_subxact      | 19
 (19 rows)
 </programlisting>
   </para>
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 9ba147cae5..d40dd42eaa 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -2098,7 +2098,7 @@ The commands accepted in walsender mode are:
          <filename>pg_dynshmem</>, <filename>pg_notify</>,
          <filename>pg_replslot</>, <filename>pg_serial</>,
          <filename>pg_snapshots</>, <filename>pg_stat_tmp</>, and
-         <filename>pg_subtrans</> are copied as empty directories (even if
+         <filename>pg_subxact</> are copied as empty directories (even if
          they are symbolic links).
         </para>
        </listitem>
diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml
index 91b44d4cc5..2fb858a149 100644
--- a/doc/src/sgml/storage.sgml
+++ b/doc/src/sgml/storage.sgml
@@ -121,7 +121,7 @@ Item
 </row>
 
 <row>
- <entry><filename>pg_subtrans</></entry>
+ <entry><filename>pg_subxact</></entry>
  <entry>Subdirectory containing subtransaction status data</entry>
 </row>
 
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 1f9fac9be9..aa0eccb048 100644
--- a/doc/src/sgml/wal.sgml
+++ b/doc/src/sgml/wal.sgml
@@ -201,7 +201,7 @@
     </listitem>
     <listitem>
      <para>
-      Internal data structures such as <filename>pg_xact</filename>, <filename>pg_subtrans</filename>, <filename>pg_multixact</filename>,
+      Internal data structures such as <filename>pg_xact</filename>, <filename>pg_subxact</filename>, <filename>pg_multixact</filename>,
       <filename>pg_serial</filename>, <filename>pg_notify</filename>, <filename>pg_stat</filename>, <filename>pg_snapshots</filename> are not directly
       checksummed, nor are pages protected by full page writes. However, where
       such data structures are persistent, WAL records are written that allow
diff --git a/src/backend/access/transam/README b/src/backend/access/transam/README
index e7dd19fd7b..94553f1f15 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -198,7 +198,7 @@ parent.  This maintains the invariant that child transactions have XIDs later
 than their parents, which is assumed in a number of places.
 
 The subsidiary actions of obtaining a lock on the XID and entering it into
-pg_subtrans and PG_PROC are done at the time it is assigned.
+pg_subxact and PG_PROC are done at the time it is assigned.
 
 A transaction that has no XID still needs to be identified for various
 purposes, notably holding locks.  For this purpose we assign a "virtual
@@ -331,10 +331,10 @@ of the xid fields is atomic, so assuming it for xmin as well is no extra
 risk.
 
 
-pg_xact and pg_subtrans
+pg_xact and pg_subxact
 -----------------------
 
-pg_xact and pg_subtrans are permanent (on-disk) storage of transaction related
+pg_xact and pg_subxact are permanent (on-disk) storage of transaction related
 information.  There is a limited number of pages of each kept in memory, so
 in many cases there is no need to actually read from disk.  However, if
 there's a long running transaction or a backend sitting idle with an open
@@ -367,24 +367,24 @@ allow unlimited transaction nesting depth, so any particular subtransaction's
 commit state is dependent on the commit status of each and every ancestor
 transaction.
 
-The "subtransaction parent" (pg_subtrans) mechanism records, for each
+The "subtransaction parent" (pg_subxact) mechanism records, for each
 transaction with an XID, the TransactionId of its parent transaction.  This
 information is stored as soon as the subtransaction is assigned an XID.
-Top-level transactions do not have a parent, so they leave their pg_subtrans
+Top-level transactions do not have a parent, so they leave their pg_subxact
 entries set to the default value of zero (InvalidTransactionId).
 
-pg_subtrans is used to check whether the transaction in question is still
+pg_subxact is used to check whether the transaction in question is still
 running --- the main Xid of a transaction is recorded in the PGXACT struct,
 but since we allow arbitrary nesting of subtransactions, we can't fit all Xids
 in shared memory, so we have to store them on disk.  Note, however, that for
 each transaction we keep a "cache" of Xids that are known to be part of the
-transaction tree, so we can skip looking at pg_subtrans unless we know the
+transaction tree, so we can skip looking at pg_subxact unless we know the
 cache has been overflowed.  See storage/ipc/procarray.c for the gory details.
 
-slru.c is the supporting mechanism for both pg_xact and pg_subtrans.  It
+slru.c is the supporting mechanism for both pg_xact and pg_subxact.  It
 implements the LRU policy for in-memory buffer pages.  The high-level routines
 for pg_xact are implemented in transam.c, while the low-level functions are in
-clog.c.  pg_subtrans is contained completely in subtrans.c.
+clog.c.  pg_subxact is contained completely in subtrans.c.
 
 
 Write-Ahead Log Coding
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 70828e5170..3c535b0645 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -3,7 +3,7 @@
  * subtrans.c
  *		PostgreSQL subtransaction-log manager
  *
- * The pg_subtrans manager is a pg_xact-like manager that stores the parent
+ * The pg_subxact manager is a pg_xact-like manager that stores the parent
  * transaction Id for each transaction.  It is a fundamental part of the
  * nested transactions implementation.  A main transaction has a parent
  * of InvalidTransactionId, and each subtransaction has its immediate parent.
@@ -11,7 +11,7 @@
  * opposite direction.
  *
  * are completely different from pg_xact, because we only need to remember
- * pg_subtrans information for currently-open transactions.  Thus, there is
+ * pg_subxact information for currently-open transactions.  Thus, there is
  * no need to preserve data over a crash and restart.
  *
  * There are no XLOG interactions since we do not care about preserving
@@ -179,7 +179,7 @@ SUBTRANSShmemInit(void)
 {
 	SubTransCtl->PagePrecedes = SubTransPagePrecedes;
 	SimpleLruInit(SubTransCtl, "subtrans", NUM_SUBTRANS_BUFFERS, 0,
-				  SubtransControlLock, "pg_subtrans",
+				  SubtransControlLock, "pg_subxact",
 				  LWTRANCHE_SUBTRANS_BUFFERS);
 	/* Override default assumption that writes should be fsync'd */
 	SubTransCtl->do_fsync = false;
@@ -240,7 +240,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
 	int			endPage;
 
 	/*
-	 * Since we don't expect pg_subtrans to be valid across crashes, we
+	 * Since we don't expect pg_subxact to be valid across crashes, we
 	 * initialize the currently-active page(s) to zeroes during startup.
 	 * Whenever we advance into a new page, ExtendSUBTRANS will likewise zero
 	 * the new page without regard to whatever was previously on disk.
diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c
index b91a259e80..066a0a4800 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -137,13 +137,13 @@ TransactionIdDidCommit(TransactionId transactionId)
 	/*
 	 * If it's marked subcommitted, we have to check the parent recursively.
 	 * However, if it's older than TransactionXmin, we can't look at
-	 * pg_subtrans; instead assume that the parent crashed without cleaning up
+	 * pg_subxact; instead assume that the parent crashed without cleaning up
 	 * its children.
 	 *
 	 * Originally we Assert'ed that the result of SubTransGetParent was not
 	 * zero. However with the introduction of prepared transactions, there can
 	 * be a window just after database startup where we do not have complete
-	 * knowledge in pg_subtrans of the transactions after TransactionXmin.
+	 * knowledge in pg_subxact of the transactions after TransactionXmin.
 	 * StartupSUBTRANS() has ensured that any missing information will be
 	 * zeroed.  Since this case should not happen under normal conditions, it
 	 * seems reasonable to emit a WARNING for it.
@@ -157,7 +157,7 @@ TransactionIdDidCommit(TransactionId transactionId)
 		parentXid = SubTransGetParent(transactionId);
 		if (!TransactionIdIsValid(parentXid))
 		{
-			elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
+			elog(WARNING, "no pg_subxact entry for subcommitted XID %u",
 				 transactionId);
 			return false;
 		}
@@ -193,7 +193,7 @@ TransactionIdDidAbort(TransactionId transactionId)
 	/*
 	 * If it's marked subcommitted, we have to check the parent recursively.
 	 * However, if it's older than TransactionXmin, we can't look at
-	 * pg_subtrans; instead assume that the parent crashed without cleaning up
+	 * pg_subxact; instead assume that the parent crashed without cleaning up
 	 * its children.
 	 */
 	if (xidstatus == TRANSACTION_STATUS_SUB_COMMITTED)
@@ -206,7 +206,7 @@ TransactionIdDidAbort(TransactionId transactionId)
 		if (!TransactionIdIsValid(parentXid))
 		{
 			/* see notes in TransactionIdDidCommit */
-			elog(WARNING, "no pg_subtrans entry for subcommitted XID %u",
+			elog(WARNING, "no pg_subxact entry for subcommitted XID %u",
 				 transactionId);
 			return true;
 		}
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 3c1f7b596d..9da228dc1d 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1674,7 +1674,7 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon)
  *
  * Our other responsibility is to determine and return the oldest valid XID
  * among the prepared xacts (if none, return ShmemVariableCache->nextXid).
- * This is needed to synchronize pg_subtrans startup properly.
+ * This is needed to synchronize pg_subxact startup properly.
  *
  * If xids_p and nxids_p are not NULL, pointer to a palloc'd array of all
  * top-level xids is stored in *xids_p. The number of entries in the array
@@ -1819,7 +1819,7 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
  *
  * Currently we simply call SubTransSetParent() for any subxids of prepared
  * transactions. If overwriteOK is true, it's OK if some XIDs have already
- * been marked in pg_subtrans.
+ * been marked in pg_subxact.
  */
 void
 StandbyRecoverPreparedTransactions(bool overwriteOK)
@@ -1976,7 +1976,7 @@ RecoverPreparedTransactions(void)
 
 			/*
 			 * Reconstruct subtrans state for the transaction --- needed
-			 * because pg_subtrans is not preserved over a restart.  Note that
+			 * because pg_subxact is not preserved over a restart.  Note that
 			 * we are linking all the subtransactions directly to the
 			 * top-level XID; there may originally have been a more complex
 			 * hierarchy, but there's no need to restore that exactly.
diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c
index fc084c5bdb..9c987ff91b 100644
--- a/src/backend/access/transam/varsup.c
+++ b/src/backend/access/transam/varsup.c
@@ -166,7 +166,7 @@ GetNewTransactionId(bool isSubXact)
 	 * XID before we zero the page.  Fortunately, a page of the commit log
 	 * holds 32K or more transactions, so we don't have to do this very often.
 	 *
-	 * Extend pg_subtrans and pg_commit_ts too.
+	 * Extend pg_subxact and pg_commit_ts too.
 	 */
 	ExtendCLOG(xid);
 	ExtendCommitTs(xid);
@@ -203,9 +203,9 @@ GetNewTransactionId(bool isSubXact)
 	 *
 	 * If there's no room to fit a subtransaction XID into PGPROC, set the
 	 * cache-overflowed flag instead.  This forces readers to look in
-	 * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There is a
+	 * pg_subxact to map subtransaction XIDs up to top-level XIDs. There is a
 	 * race-condition window, in that the new XID will not appear as running
-	 * until its parent link has been placed into pg_subtrans. However, that
+	 * until its parent link has been placed into pg_subxact. However, that
 	 * will happen before anyone could possibly have a reason to inquire about
 	 * the status of the XID, so it seems OK.  (Snapshots taken during this
 	 * window *will* include the parent XID, so they will deliver the correct
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index fc603a575e..fe0904fc11 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -545,7 +545,7 @@ AssignTransactionId(TransactionState s)
 		log_unknown_top = true;
 
 	/*
-	 * Generate a new Xid and record it in PG_PROC and pg_subtrans.
+	 * Generate a new Xid and record it in PG_PROC and pg_subxact.
 	 *
 	 * NB: we must make the subtrans entry BEFORE the Xid appears anywhere in
 	 * shared storage other than PG_PROC; because if there's no room for it in
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 41b721b1dd..9838a00f7a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8702,9 +8702,9 @@ CreateCheckPoint(int flags)
 		PreallocXlogFiles(recptr);
 
 	/*
-	 * Truncate pg_subtrans if possible.  We can throw away all data before
+	 * Truncate pg_subxact if possible.  We can throw away all data before
 	 * the oldest XMIN of any running transaction.  No future transaction will
-	 * attempt to reference any pg_subtrans entry older than that (see Asserts
+	 * attempt to reference any pg_subxact entry older than that (see Asserts
 	 * in subtrans.c).  During recovery, though, we mustn't do this because
 	 * StartupSUBTRANS hasn't been called yet.
 	 */
@@ -9065,9 +9065,9 @@ CreateRestartPoint(int flags)
 	}
 
 	/*
-	 * Truncate pg_subtrans if possible.  We can throw away all data before
+	 * Truncate pg_subxact if possible.  We can throw away all data before
 	 * the oldest XMIN of any running transaction.  No future transaction will
-	 * attempt to reference any pg_subtrans entry older than that (see Asserts
+	 * attempt to reference any pg_subxact entry older than that (see Asserts
 	 * in subtrans.c).  When hot standby is disabled, though, we mustn't do
 	 * this because StartupSUBTRANS hasn't been called yet.
 	 */
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 09ecc15365..6f1bce13d4 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -134,7 +134,7 @@ static const char *excludeDirContents[] =
 	"pg_snapshots",
 
 	/* Contents zeroed on startup, see StartupSUBTRANS(). */
-	"pg_subtrans",
+	"pg_subxact",
 
 	/* end of list */
 	NULL
diff --git a/src/backend/replication/logical/snapbuild.c b/src/backend/replication/logical/snapbuild.c
index 1e02aa9bd8..7ade4759dd 100644
--- a/src/backend/replication/logical/snapbuild.c
+++ b/src/backend/replication/logical/snapbuild.c
@@ -20,7 +20,7 @@
  * tables since the data we decode is wholly contained in the WAL
  * records. Also, our snapshots need to be different in comparison to normal
  * MVCC ones because in contrast to those we cannot fully rely on the clog and
- * pg_subtrans for information about committed transactions because they might
+ * pg_subxact for information about committed transactions because they might
  * commit in the future from the POV of the WAL entry we're currently
  * decoding. This definition has the advantage that we only need to prevent
  * removal of catalog rows, while normal table's rows can still be
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c
index ce34e8a8de..75736e3de9 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -929,7 +929,7 @@ ProcArrayApplyXidAssignment(TransactionId topxid,
 	RecordKnownAssignedTransactionIds(max_xid);
 
 	/*
-	 * Notice that we update pg_subtrans with the top-level xid, rather than
+	 * Notice that we update pg_subxact with the top-level xid, rather than
 	 * the parent xid. This is a difference between normal processing and
 	 * recovery, yet is still correct in all cases. The reason is that
 	 * subtransaction commit is not marked in clog until commit processing, so
@@ -1146,7 +1146,7 @@ TransactionIdIsInProgress(TransactionId xid)
 		}
 
 		/*
-		 * If the KnownAssignedXids overflowed, we have to check pg_subtrans
+		 * If the KnownAssignedXids overflowed, we have to check pg_subxact
 		 * too.  Fetch all xids from KnownAssignedXids that are lower than
 		 * xid, since if xid is a subtransaction its parent will always have a
 		 * lower value.  Note we will collect both main and subXIDs here, but
@@ -1160,7 +1160,7 @@ TransactionIdIsInProgress(TransactionId xid)
 
 	/*
 	 * If none of the relevant caches overflowed, we know the Xid is not
-	 * running without even looking at pg_subtrans.
+	 * running without even looking at pg_subxact.
 	 */
 	if (nxids == 0)
 	{
@@ -1169,7 +1169,7 @@ TransactionIdIsInProgress(TransactionId xid)
 	}
 
 	/*
-	 * Step 4: have to check pg_subtrans.
+	 * Step 4: have to check pg_subxact.
 	 *
 	 * At this point, we know it's either a subtransaction of one of the Xids
 	 * in xids[], or it's not running.  If it's an already-failed
@@ -1270,7 +1270,7 @@ TransactionIdIsActive(TransactionId xid)
  * ignore concurrently running lazy VACUUMs because (a) they must be working
  * on other tables, and (b) they don't need to do snapshot-based lookups.
  *
- * This is also used to determine where to truncate pg_subtrans.  For that
+ * This is also used to determine where to truncate pg_subxact.  For that
  * backends in all databases have to be considered, so rel = NULL has to be
  * passed in.
  *
@@ -3075,14 +3075,14 @@ DisplayXidCache(void)
  * KnownAssignedXids list.  In backends, this is copied into snapshots in
  * GetSnapshotData(), taking advantage of the fact that XidInMVCCSnapshot()
  * doesn't care about the distinction either.  Subtransaction XIDs are
- * effectively treated as top-level XIDs and in the typical case pg_subtrans
+ * effectively treated as top-level XIDs and in the typical case pg_subxact
  * links are *not* maintained (which does not affect visibility).
  *
  * We have room in KnownAssignedXids and in snapshots to hold maxProcs *
  * (1 + PGPROC_MAX_CACHED_SUBXIDS) XIDs, so every master transaction must
  * report its subtransaction XIDs in a WAL XLOG_XACT_ASSIGNMENT record at
  * least every PGPROC_MAX_CACHED_SUBXIDS.  When we receive one of these
- * records, we mark the subXIDs as children of the top XID in pg_subtrans,
+ * records, we mark the subXIDs as children of the top XID in pg_subxact,
  * and then remove them from KnownAssignedXids.  This prevents overflow of
  * KnownAssignedXids and snapshots, at the cost that status checks for these
  * subXIDs will take a slower path through TransactionIdIsInProgress().
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c
index 2431d8794a..295d3a975c 100644
--- a/src/backend/utils/time/tqual.c
+++ b/src/backend/utils/time/tqual.c
@@ -1490,7 +1490,7 @@ XidInMVCCSnapshot(TransactionId xid, Snapshot snapshot)
 		 * If the snapshot contains full subxact data, the fastest way to
 		 * check things is just to compare the given XID against both subxact
 		 * XIDs and top-level XIDs.  If the snapshot overflowed, we have to
-		 * use pg_subtrans to convert a subxact XID to its parent XID, but
+		 * use pg_subxact to convert a subxact XID to its parent XID, but
 		 * then we need only look at top-level XIDs not subxacts.
 		 */
 		if (!snapshot->suboverflowed)
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 8ad3879e13..621e1be8c3 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -201,7 +201,7 @@ static const char *const subdirs[] = {
 	"pg_notify",
 	"pg_serial",
 	"pg_snapshots",
-	"pg_subtrans",
+	"pg_subxact",
 	"pg_twophase",
 	"pg_multixact",
 	"pg_multixact/members",
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 2c5a3658d5..d560650566 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -74,7 +74,7 @@ is_deeply(
 	'no WAL files copied');
 
 # Contents of these directories should not be copied.
-foreach my $dirname (qw(pg_dynshmem pg_notify pg_replslot pg_serial pg_snapshots pg_stat_tmp pg_subtrans))
+foreach my $dirname (qw(pg_dynshmem pg_notify pg_replslot pg_serial pg_snapshots pg_stat_tmp pg_subxact))
 {
 	is_deeply(
 		[ sort(slurp_dir("$tempdir/backup/$dirname/")) ],
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 6810a6fb58..9012310b31 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -300,7 +300,6 @@ check_data_dir(ClusterInfo *cluster)
 	check_single_dir(pg_data, "base");
 	check_single_dir(pg_data, "global");
 	check_single_dir(pg_data, "pg_multixact");
-	check_single_dir(pg_data, "pg_subtrans");
 	check_single_dir(pg_data, "pg_tblspc");
 	check_single_dir(pg_data, "pg_twophase");
 
@@ -315,6 +314,12 @@ check_data_dir(ClusterInfo *cluster)
 		check_single_dir(pg_data, "pg_clog");
 	else
 		check_single_dir(pg_data, "pg_xact");
+
+	/* pg_clog has been renamed to pg_xact in post-10 cluster */
+	if (GET_MAJOR_VERSION(cluster->major_version) < 1000)
+		check_single_dir(pg_data, "pg_subtrans");
+	else
+		check_single_dir(pg_data, "pg_subxact");
 }
 
 
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 722867d5d2..d28c768dbc 100644
--- a/src/include/access/slru.h
+++ b/src/include/access/slru.h
@@ -76,7 +76,7 @@ typedef struct SlruSharedData
 	/*
 	 * Optional array of WAL flush LSNs associated with entries in the SLRU
 	 * pages.  If not zero/NULL, we must flush WAL before writing pages (true
-	 * for pg_xact, false for multixact, pg_subtrans, pg_notify).  group_lsn[]
+	 * for pg_xact, false for multixact, pg_subxact, pg_notify).  group_lsn[]
 	 * has lsn_groups_per_page entries per buffer slot, each containing the
 	 * highest LSN known for a contiguous group of SLRU entries on that slot's
 	 * page.
@@ -120,7 +120,7 @@ typedef struct SlruCtlData
 
 	/*
 	 * This flag tells whether to fsync writes (true for pg_xact and multixact
-	 * stuff, false for pg_subtrans and pg_notify).
+	 * stuff, false for pg_subxact and pg_notify).
 	 */
 	bool		do_fsync;
 
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 398fa8afde..e139de8c2f 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -30,7 +30,7 @@
  * generated at least one subtransaction that didn't fit in the cache).
  * If none of the caches have overflowed, we can assume that an XID that's not
  * listed anywhere in the PGPROC array is not a running transaction.  Else we
- * have to look at pg_subtrans.
+ * have to look at pg_subxact.
  */
 #define PGPROC_MAX_CACHED_SUBXIDS 64	/* XXX guessed-at value */
 
-- 
2.11.0

