On Sun, Oct 23, 2016 at 5:18 PM, Vik Fearing <v...@2ndquadrant.fr> wrote:
> On 10/22/2016 06:00 PM, David Steele wrote:
>> On 10/22/16 6:58 PM, Bruce Momjian wrote:
>>> On Sat, Oct 22, 2016 at 07:33:56AM +0900, Michael Paquier wrote:
>>>> On Sat, Oct 22, 2016 at 4:29 AM, Alvaro Herrera
>>>>
>>>>> Also +1 to renaming pg_subtrans to pg_subxact.
>>>>
>>>> Nice suggestion, good naming for consistency with the rest.
>>>
>>> Agreed.
>>
>> +1
>
> +1 from me, too.

OK, glad to see that we are reaching a conclusion to this thread.
Attached are two patches. 0001 renames pg_clog to pg_xact. I found a
comment in xact.c that was not yet updated. And 0002 renames
pg_subtrans to pg_subxact.
-- 
Michael
From 1711e73fe59b37c0626c1382c6f044b28c01f3d9 Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@paquier.xyz>
Date: Sun, 23 Oct 2016 20:52:22 +0900
Subject: [PATCH 1/2] Rename pg_clog to pg_xact

pg_upgrade is updated to handle the transfer correctly to post-10
clusters.
---
 doc/src/sgml/backup.sgml               |  4 ++--
 doc/src/sgml/catalogs.sgml             |  4 ++--
 doc/src/sgml/config.sgml               |  2 +-
 doc/src/sgml/func.sgml                 |  2 +-
 doc/src/sgml/maintenance.sgml          |  8 ++++----
 doc/src/sgml/ref/pg_resetxlog.sgml     |  4 ++--
 doc/src/sgml/ref/pg_rewind.sgml        |  2 +-
 doc/src/sgml/storage.sgml              | 10 +++++-----
 doc/src/sgml/wal.sgml                  |  2 +-
 src/backend/access/heap/heapam.c       |  4 ++--
 src/backend/access/transam/README      | 10 +++++-----
 src/backend/access/transam/clog.c      |  2 +-
 src/backend/access/transam/commit_ts.c |  2 +-
 src/backend/access/transam/multixact.c |  2 +-
 src/backend/access/transam/subtrans.c  |  5 ++---
 src/backend/access/transam/transam.c   |  2 +-
 src/backend/access/transam/twophase.c  |  4 ++--
 src/backend/access/transam/xact.c      | 18 +++++++++---------
 src/backend/access/transam/xlog.c      |  2 +-
 src/backend/commands/vacuum.c          | 10 +++++-----
 src/backend/postmaster/autovacuum.c    |  2 +-
 src/backend/storage/buffer/README      |  2 +-
 src/backend/storage/ipc/procarray.c    |  4 ++--
 src/backend/utils/time/tqual.c         |  6 +++---
 src/bin/initdb/initdb.c                |  2 +-
 src/bin/pg_upgrade/exec.c              |  6 ++++++
 src/bin/pg_upgrade/pg_upgrade.c        | 30 ++++++++++++++++++------------
 src/include/access/slru.h              |  4 ++--
 28 files changed, 83 insertions(+), 72 deletions(-)

diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index 6eaed1e..d22af0d 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -382,10 +382,10 @@ tar -cf backup.tar /usr/local/pgsql/data
       directories. This will <emphasis>not</> work because the
       information contained in these files is not usable without
       the commit log files,
-      <filename>pg_clog/*</filename>, which contain the commit status of
+      <filename>pg_xact/*</filename>, which contain the commit status of
       all transactions. A table file is only usable with this
       information. Of course it is also impossible to restore only a
-      table and the associated <filename>pg_clog</filename> data
+      table and the associated <filename>pg_xact</filename> data
       because that would render all other tables in the database
       cluster useless.  So file system backups only work for complete
       backup and restoration of an entire database cluster.
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 29738b0..839b52a 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -1847,7 +1847,7 @@
        All transaction IDs before this one have been replaced with a permanent
        (<quote>frozen</>) transaction ID in this table.  This is used to track
        whether the table needs to be vacuumed in order to prevent transaction
-       ID wraparound or to allow <literal>pg_clog</> to be shrunk.  Zero
+       ID wraparound or to allow <literal>pg_xact</> to be shrunk.  Zero
        (<symbol>InvalidTransactionId</symbol>) if the relation is not a table.
       </entry>
      </row>
@@ -2514,7 +2514,7 @@
        All transaction IDs before this one have been replaced with a permanent
        (<quote>frozen</>) transaction ID in this database.  This is used to
        track whether the database needs to be vacuumed in order to prevent
-       transaction ID wraparound or to allow <literal>pg_clog</> to be shrunk.
+       transaction ID wraparound or to allow <literal>pg_xact</> to be shrunk.
        It is the minimum of the per-table
        <structname>pg_class</>.<structfield>relfrozenxid</> values.
       </entry>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index adab2f8..8a5d202 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -5834,7 +5834,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH 
csv;
 
        <para>
         Vacuum also allows removal of old files from the
-        <filename>pg_clog</> subdirectory, which is why the default
+        <filename>pg_xact</> subdirectory, which is why the default
         is a relatively low 200 million transactions.
         This parameter can only be set at server start, but the setting
         can be reduced for individual tables by
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 2e64cc4..e9cfb06 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15323,7 +15323,7 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
  postmaster.pid  |  9
  pg_ident.conf   | 10
  global          | 11
- pg_clog         | 12
+ pg_xact         | 12
  pg_snapshots    | 13
  pg_multixact    | 14
  PG_VERSION      | 15
diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml
index f87f3e0..65a64c8 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -527,18 +527,18 @@
    <para>
     The sole disadvantage of increasing <varname>autovacuum_freeze_max_age</>
     (and <varname>vacuum_freeze_table_age</> along with it)
-    is that the <filename>pg_clog</> subdirectory of the database cluster
+    is that the <filename>pg_xact</> subdirectory of the database cluster
     will take more space, because it must store the commit status of all
     transactions back to the <varname>autovacuum_freeze_max_age</> horizon.
     The commit status uses two bits per transaction, so if
     <varname>autovacuum_freeze_max_age</> is set to its maximum allowed
-    value of two billion, <filename>pg_clog</> can be expected to
+    value of two billion, <filename>pg_xact</> can be expected to
     grow to about half a gigabyte.  If this is trivial compared to your
     total database size, setting <varname>autovacuum_freeze_max_age</> to
     its maximum allowed value is recommended.  Otherwise, set it depending
-    on what you are willing to allow for <filename>pg_clog</> storage.
+    on what you are willing to allow for <filename>pg_xact</> storage.
     (The default, 200 million transactions, translates to about 50MB of
-    <filename>pg_clog</> storage.)
+    <filename>pg_xact</> storage.)
    </para>
 
    <para>
diff --git a/doc/src/sgml/ref/pg_resetxlog.sgml 
b/doc/src/sgml/ref/pg_resetxlog.sgml
index c949c5e..6ebc68b 100644
--- a/doc/src/sgml/ref/pg_resetxlog.sgml
+++ b/doc/src/sgml/ref/pg_resetxlog.sgml
@@ -256,12 +256,12 @@ PostgreSQL documentation
 
      <para>
       A safe value can be determined by looking for the numerically largest
-      file name in the directory <filename>pg_clog</> under the data directory,
+      file name in the directory <filename>pg_xact</> under the data directory,
       adding one,
       and then multiplying by 1048576 (0x100000).  Note that the file names 
are in
       hexadecimal.  It is usually easiest to specify the option value in
       hexadecimal too. For example, if <filename>0011</> is the largest entry
-      in <filename>pg_clog</>, <literal>-x 0x1200000</> will work (five
+      in <filename>pg_xact</>, <literal>-x 0x1200000</> will work (five
       trailing zeroes provide the proper multiplier).
      </para>
     </listitem>
diff --git a/doc/src/sgml/ref/pg_rewind.sgml b/doc/src/sgml/ref/pg_rewind.sgml
index 371c4a4..d5430d4 100644
--- a/doc/src/sgml/ref/pg_rewind.sgml
+++ b/doc/src/sgml/ref/pg_rewind.sgml
@@ -229,7 +229,7 @@ PostgreSQL documentation
     </step>
     <step>
      <para>
-      Copy all other files such as <filename>pg_clog</filename> and
+      Copy all other files such as <filename>pg_xact</filename> and
       configuration files from the source cluster to the target cluster
       (everything except the relation files).
      </para>
diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml
index fddb69b..56aef3c 100644
--- a/doc/src/sgml/storage.sgml
+++ b/doc/src/sgml/storage.sgml
@@ -72,11 +72,6 @@ Item
 </row>
 
 <row>
- <entry><filename>pg_clog</></entry>
- <entry>Subdirectory containing transaction commit status data</entry>
-</row>
-
-<row>
  <entry><filename>pg_dynshmem</></entry>
  <entry>Subdirectory containing files used by the dynamic shared memory
   subsystem</entry>
@@ -146,6 +141,11 @@ Item
 </row>
 
 <row>
+ <entry><filename>pg_xact</></entry>
+ <entry>Subdirectory containing transaction commit status data</entry>
+</row>
+
+<row>
  <entry><filename>postgresql.auto.conf</></entry>
  <entry>A file used for storing configuration parameters that are set by
 <command>ALTER SYSTEM</command></entry>
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 346aa76..1f9fac9 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_clog</filename>, 
<filename>pg_subtrans</filename>, <filename>pg_multixact</filename>,
+      Internal data structures such as <filename>pg_xact</filename>, 
<filename>pg_subtrans</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/heap/heapam.c b/src/backend/access/heap/heapam.c
index b019bc1..560a8da 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -6762,8 +6762,8 @@ heap_prepare_freeze_tuple(HeapTupleHeader tuple, 
TransactionId cutoff_xid,
  * Note: it might seem we could make the changes without exclusive lock, since
  * TransactionId read/write is assumed atomic anyway.  However there is a race
  * condition: someone who just fetched an old XID that we overwrite here could
- * conceivably not finish checking the XID against pg_clog before we finish
- * the VACUUM and perhaps truncate off the part of pg_clog he needs.  Getting
+ * conceivably not finish checking the XID against pg_xact before we finish
+ * the VACUUM and perhaps truncate off the part of pg_xact he needs.  Getting
  * exclusive lock ensures no other backend is in process of checking the
  * tuple status.  Also, getting exclusive lock makes it safe to adjust the
  * infomask bits.
diff --git a/src/backend/access/transam/README 
b/src/backend/access/transam/README
index 4ae4715..e7dd19f 100644
--- a/src/backend/access/transam/README
+++ b/src/backend/access/transam/README
@@ -331,17 +331,17 @@ of the xid fields is atomic, so assuming it for xmin as 
well is no extra
 risk.
 
 
-pg_clog and pg_subtrans
+pg_xact and pg_subtrans
 -----------------------
 
-pg_clog and pg_subtrans are permanent (on-disk) storage of transaction related
+pg_xact and pg_subtrans 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
 transaction, it may be necessary to be able to read and write this information
 from disk.  They also allow information to be permanent across server restarts.
 
-pg_clog records the commit status for each transaction that has been assigned
+pg_xact records the commit status for each transaction that has been assigned
 an XID.  A transaction can be in progress, committed, aborted, or
 "sub-committed".  This last state means that it's a subtransaction that's no
 longer running, but its parent has not updated its state yet.  It is not
@@ -381,9 +381,9 @@ 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
 cache has been overflowed.  See storage/ipc/procarray.c for the gory details.
 
-slru.c is the supporting mechanism for both pg_clog and pg_subtrans.  It
+slru.c is the supporting mechanism for both pg_xact and pg_subtrans.  It
 implements the LRU policy for in-memory buffer pages.  The high-level routines
-for pg_clog are implemented in transam.c, while the low-level functions are in
+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.
 
 
diff --git a/src/backend/access/transam/clog.c 
b/src/backend/access/transam/clog.c
index 2634476..08e1edd 100644
--- a/src/backend/access/transam/clog.c
+++ b/src/backend/access/transam/clog.c
@@ -450,7 +450,7 @@ CLOGShmemInit(void)
 {
        ClogCtl->PagePrecedes = CLOGPagePrecedes;
        SimpleLruInit(ClogCtl, "clog", CLOGShmemBuffers(), CLOG_LSNS_PER_PAGE,
-                                 CLogControlLock, "pg_clog", 
LWTRANCHE_CLOG_BUFFERS);
+                                 CLogControlLock, "pg_xact", 
LWTRANCHE_CLOG_BUFFERS);
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c 
b/src/backend/access/transam/commit_ts.c
index a8d275f..0d03700 100644
--- a/src/backend/access/transam/commit_ts.c
+++ b/src/backend/access/transam/commit_ts.c
@@ -3,7 +3,7 @@
  * commit_ts.c
  *             PostgreSQL commit timestamp manager
  *
- * This module is a pg_clog-like system that stores the commit timestamp
+ * This module is a pg_xact-like system that stores the commit timestamp
  * for each transaction.
  *
  * XLOG interactions: this module generates an XLOG record whenever a new
diff --git a/src/backend/access/transam/multixact.c 
b/src/backend/access/transam/multixact.c
index e9588a7..287e435 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -3,7 +3,7 @@
  * multixact.c
  *             PostgreSQL multi-transaction-log manager
  *
- * The pg_multixact manager is a pg_clog-like manager that stores an array of
+ * The pg_multixact manager is a pg_xact-like manager that stores an array of
  * MultiXactMember for each MultiXactId.  It is a fundamental part of the
  * shared-row-lock implementation.  Each MultiXactMember is comprised of a
  * TransactionId and a set of flag bits.  The name is a bit historical:
diff --git a/src/backend/access/transam/subtrans.c 
b/src/backend/access/transam/subtrans.c
index 908fe2d..6871239 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -3,15 +3,14 @@
  * subtrans.c
  *             PostgreSQL subtransaction-log manager
  *
- * The pg_subtrans manager is a pg_clog-like manager that stores the parent
+ * The pg_subtrans 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.
  * The tree can easily be walked from child to parent, but not in the
  * opposite direction.
  *
- * This code is based on clog.c, but the robustness requirements
- * are completely different from pg_clog, because we only need to remember
+ * are completely different from pg_xact, because we only need to remember
  * pg_subtrans information for currently-open transactions.  Thus, there is
  * no need to preserve data over a crash and restart.
  *
diff --git a/src/backend/access/transam/transam.c 
b/src/backend/access/transam/transam.c
index 1eba49a..0a103c3 100644
--- a/src/backend/access/transam/transam.c
+++ b/src/backend/access/transam/transam.c
@@ -224,7 +224,7 @@ TransactionIdDidAbort(TransactionId transactionId)
  *             True iff transaction associated with the identifier is currently
  *             known to have either committed or aborted.
  *
- * This does NOT look into pg_clog but merely probes our local cache
+ * This does NOT look into pg_xact but merely probes our local cache
  * (and so it's not named TransactionIdDidComplete, which would be the
  * appropriate name for a function that worked that way).  The intended
  * use is just to short-circuit TransactionIdIsInProgress calls when doing
diff --git a/src/backend/access/transam/twophase.c 
b/src/backend/access/transam/twophase.c
index 5415604..8bed3f5 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -1379,7 +1379,7 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
        /*
         * The order of operations here is critical: make the XLOG entry for
         * commit or abort, then mark the transaction committed or aborted in
-        * pg_clog, then remove its PGPROC from the global ProcArray (which 
means
+        * pg_xact, then remove its PGPROC from the global ProcArray (which 
means
         * TransactionIdIsInProgress will stop saying the prepared xact is in
         * progress), then run the post-commit or post-abort callbacks. The
         * callbacks will release the locks the transaction held.
@@ -2093,7 +2093,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
        /* Flush XLOG to disk */
        XLogFlush(recptr);
 
-       /* Mark the transaction committed in pg_clog */
+       /* Mark the transaction committed in pg_xact */
        TransactionIdCommitTree(xid, nchildren, children);
 
        /* Checkpoint can proceed now */
diff --git a/src/backend/access/transam/xact.c 
b/src/backend/access/transam/xact.c
index e11b229..0dc4d43 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -1206,8 +1206,8 @@ RecordTransactionCommit(void)
                /*
                 * Mark ourselves as within our "commit critical section".  This
                 * forces any concurrent checkpoint to wait until we've updated
-                * pg_clog.  Without this, it is possible for the checkpoint to 
set
-                * REDO after the XLOG record but fail to flush the pg_clog 
update to
+                * pg_xact.  Without this, it is possible for the checkpoint to 
set
+                * REDO after the XLOG record but fail to flush the pg_xact 
update to
                 * disk, leading to loss of the transaction commit if the system
                 * crashes a little later.
                 *
@@ -2033,7 +2033,7 @@ CommitTransaction(void)
        if (!is_parallel_worker)
        {
                /*
-                * We need to mark our XIDs as committed in pg_clog.  This is 
where we
+                * We need to mark our XIDs as committed in pg_xact.  This is 
where we
                 * durably commit.
                 */
                latestXid = RecordTransactionCommit();
@@ -2539,7 +2539,7 @@ AbortTransaction(void)
        AtAbort_Twophase();
 
        /*
-        * Advertise the fact that we aborted in pg_clog (assuming that we got 
as
+        * Advertise the fact that we aborted in pg_xact (assuming that we got 
as
         * far as assigning an XID to advertise).  But if we're inside a 
parallel
         * worker, skip this; the user backend must be the one to write the 
abort
         * record.
@@ -4625,7 +4625,7 @@ AbortSubTransaction(void)
                                                                
s->parent->subTransactionId);
                AtSubAbort_Notify();
 
-               /* Advertise the fact that we aborted in pg_clog. */
+               /* Advertise the fact that we aborted in pg_xact. */
                (void) RecordTransactionAbort(true);
 
                /* Post-abort cleanup */
@@ -5371,7 +5371,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
        if (standbyState == STANDBY_DISABLED)
        {
                /*
-                * Mark the transaction committed in pg_clog.
+                * Mark the transaction committed in pg_xact.
                 */
                TransactionIdCommitTree(xid, parsed->nsubxacts, 
parsed->subxacts);
        }
@@ -5389,7 +5389,7 @@ xact_redo_commit(xl_xact_parsed_commit *parsed,
                RecordKnownAssignedTransactionIds(max_xid);
 
                /*
-                * Mark the transaction committed in pg_clog. We use async 
commit
+                * Mark the transaction committed in pg_xact. We use async 
commit
                 * protocol during recovery to provide information on database
                 * consistency for when users try to set hint bits. It is 
important
                 * that we do not set hint bits until the minRecoveryPoint is 
past
@@ -5526,7 +5526,7 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, 
TransactionId xid)
 
        if (standbyState == STANDBY_DISABLED)
        {
-               /* Mark the transaction aborted in pg_clog, no need for async 
stuff */
+               /* Mark the transaction aborted in pg_xact, no need for async 
stuff */
                TransactionIdAbortTree(xid, parsed->nsubxacts, 
parsed->subxacts);
        }
        else
@@ -5542,7 +5542,7 @@ xact_redo_abort(xl_xact_parsed_abort *parsed, 
TransactionId xid)
                 */
                RecordKnownAssignedTransactionIds(max_xid);
 
-               /* Mark the transaction aborted in pg_clog, no need for async 
stuff */
+               /* Mark the transaction aborted in pg_xact, no need for async 
stuff */
                TransactionIdAbortTree(xid, parsed->nsubxacts, 
parsed->subxacts);
 
                /*
diff --git a/src/backend/access/transam/xlog.c 
b/src/backend/access/transam/xlog.c
index d6c057a..ba1bce2 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8488,7 +8488,7 @@ CreateCheckPoint(int flags)
         * that are currently in commit critical sections.  If an xact inserted
         * its commit record into XLOG just before the REDO point, then a crash
         * restart from the REDO point would not replay that record, which means
-        * that our flushing had better include the xact's update of pg_clog.  
So
+        * that our flushing had better include the xact's update of pg_xact.  
So
         * we wait till he's out of his commit critical section before 
proceeding.
         * See notes in RecordTransactionCommit().
         *
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 58bbf55..d673031 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -356,7 +356,7 @@ vacuum(int options, RangeVar *relation, Oid relid, 
VacuumParams *params,
        if ((options & VACOPT_VACUUM) && !IsAutoVacuumWorkerProcess())
        {
                /*
-                * Update pg_database.datfrozenxid, and truncate pg_clog if 
possible.
+                * Update pg_database.datfrozenxid, and truncate pg_xact if 
possible.
                 * (autovacuum.c does this for itself.)
                 */
                vac_update_datfrozenxid();
@@ -880,7 +880,7 @@ vac_update_relstats(Relation relation,
  *             pg_class.relminmxid values.
  *
  *             If we are able to advance either pg_database value, also try to
- *             truncate pg_clog and pg_multixact.
+ *             truncate pg_xact and pg_multixact.
  *
  *             We violate transaction semantics here by overwriting the 
database's
  *             existing pg_database tuple with the new values.  This is 
reasonably
@@ -1026,7 +1026,7 @@ vac_update_datfrozenxid(void)
 
        /*
         * If we were able to advance datfrozenxid or datminmxid, see if we can
-        * truncate pg_clog and/or pg_multixact.  Also do it if the shared
+        * truncate pg_xact and/or pg_multixact.  Also do it if the shared
         * XID-wrap-limit info is stale, since this action will update that too.
         */
        if (dirty || ForceTransactionIdLimitUpdate())
@@ -1039,7 +1039,7 @@ vac_update_datfrozenxid(void)
  *     vac_truncate_clog() -- attempt to truncate the commit log
  *
  *             Scan pg_database to determine the system-wide oldest 
datfrozenxid,
- *             and use it to truncate the transaction commit log (pg_clog).
+ *             and use it to truncate the transaction commit log (pg_xact).
  *             Also update the XID wrap limit info maintained by varsup.c.
  *             Likewise for datminmxid.
  *
@@ -1086,7 +1086,7 @@ vac_truncate_clog(TransactionId frozenXID,
         * of the interlock against copying a DB containing an active backend.
         * Hence the new entry will not reduce the minimum.  Also, if two 
VACUUMs
         * concurrently modify the datfrozenxid's of different databases, the
-        * worst possible outcome is that pg_clog is not truncated as 
aggressively
+        * worst possible outcome is that pg_xact is not truncated as 
aggressively
         * as it could be.
         */
        relation = heap_open(DatabaseRelationId, AccessShareLock);
diff --git a/src/backend/postmaster/autovacuum.c 
b/src/backend/postmaster/autovacuum.c
index e3a6911..29a555e 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2395,7 +2395,7 @@ deleted:
         */
 
        /*
-        * Update pg_database.datfrozenxid, and truncate pg_clog if possible. We
+        * Update pg_database.datfrozenxid, and truncate pg_xact if possible. We
         * only need to do this once, not after each table.
         */
        vac_update_datfrozenxid();
diff --git a/src/backend/storage/buffer/README 
b/src/backend/storage/buffer/README
index 248883f..bc80777 100644
--- a/src/backend/storage/buffer/README
+++ b/src/backend/storage/buffer/README
@@ -63,7 +63,7 @@ at about the same time would OR the same bits into the field, 
so there
 is little or no risk of conflicting update; what's more, if there did
 manage to be a conflict it would merely mean that one bit-update would
 be lost and need to be done again later.  These four bits are only hints
-(they cache the results of transaction status lookups in pg_clog), so no
+(they cache the results of transaction status lookups in pg_xact), so no
 great harm is done if they get reset to zero by conflicting updates.
 Note, however, that a tuple is frozen by setting both HEAP_XMIN_INVALID
 and HEAP_XMIN_COMMITTED; this is a critical update and accordingly requires
diff --git a/src/backend/storage/ipc/procarray.c 
b/src/backend/storage/ipc/procarray.c
index e5d487d..d41a79f 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -388,7 +388,7 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
  * ProcArrayEndTransaction -- mark a transaction as no longer running
  *
  * This is used interchangeably for commit and abort cases.  The transaction
- * commit/abort must already be reported to WAL and pg_clog.
+ * commit/abort must already be reported to WAL and pg_xact.
  *
  * proc is currently always MyProc, but we pass it explicitly for flexibility.
  * latestXid is the latest Xid among the transaction's main XID and
@@ -1180,7 +1180,7 @@ TransactionIdIsInProgress(TransactionId xid)
         * 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
         * subtransaction, we want to say "not running" even though its parent 
may
-        * still be running.  So first, check pg_clog to see if it's been 
aborted.
+        * still be running.  So first, check pg_xact to see if it's been 
aborted.
         */
        xc_slow_answer_inc();
 
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c
index 26a3be3..41e89e1 100644
--- a/src/backend/utils/time/tqual.c
+++ b/src/backend/utils/time/tqual.c
@@ -13,9 +13,9 @@
  * NOTE: When using a non-MVCC snapshot, we must check
  * TransactionIdIsInProgress (which looks in the PGXACT array)
  * before TransactionIdDidCommit/TransactionIdDidAbort (which look in
- * pg_clog).  Otherwise we have a race condition: we might decide that a
+ * pg_xact).  Otherwise we have a race condition: we might decide that a
  * just-committed transaction crashed, because none of the tests succeed.
- * xact.c is careful to record commit/abort in pg_clog before it unsets
+ * xact.c is careful to record commit/abort in pg_xact before it unsets
  * MyPgXact->xid in the PGXACT array.  That fixes that problem, but it
  * also means there is a window where TransactionIdIsInProgress and
  * TransactionIdDidCommit will both return true.  If we check only
@@ -29,7 +29,7 @@
  *
  * When using an MVCC snapshot, we rely on XidInMVCCSnapshot rather than
  * TransactionIdIsInProgress, but the logic is otherwise the same: do not
- * check pg_clog until after deciding that the xact is no longer in progress.
+ * check pg_xact until after deciding that the xact is no longer in progress.
  *
  *
  * Summary of visibility functions:
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index c8a8c52..9b82622 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -196,7 +196,6 @@ static const char *backend_options = "--single -F -O -j -c 
search_path=pg_catalo
 static const char *const subdirs[] = {
        "global",
        "pg_wal/archive_status",
-       "pg_clog",
        "pg_commit_ts",
        "pg_dynshmem",
        "pg_notify",
@@ -213,6 +212,7 @@ static const char *const subdirs[] = {
        "pg_tblspc",
        "pg_stat",
        "pg_stat_tmp",
+       "pg_xact",
        "pg_logical",
        "pg_logical/snapshots",
        "pg_logical/mappings"
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 55a6f0d..b242e30 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -309,6 +309,12 @@ check_data_dir(ClusterInfo *cluster)
                check_single_dir(pg_data, "pg_xlog");
        else
                check_single_dir(pg_data, "pg_wal");
+
+       /* 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_clog");
+       else
+               check_single_dir(pg_data, "pg_xact");
 }
 
 
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index 90c0720..9c475df 100644
--- a/src/bin/pg_upgrade/pg_upgrade.c
+++ b/src/bin/pg_upgrade/pg_upgrade.c
@@ -47,7 +47,7 @@
 static void prepare_new_cluster(void);
 static void prepare_new_databases(void);
 static void create_new_objects(void);
-static void copy_clog_xlog_xid(void);
+static void copy_xact_xlog_xid(void);
 static void set_frozenxids(bool minmxid_only);
 static void setup(char *argv0, bool *live_check);
 static void cleanup(void);
@@ -113,7 +113,7 @@ main(int argc, char **argv)
         * Destructive Changes to New Cluster
         */
 
-       copy_clog_xlog_xid();
+       copy_xact_xlog_xid();
 
        /* New now using xids of the old system */
 
@@ -374,17 +374,17 @@ remove_new_subdir(char *subdir, bool rmtopdir)
  * Copy the files from the old cluster into it
  */
 static void
-copy_subdir_files(char *subdir)
+copy_subdir_files(char *old_subdir, char *new_subdir)
 {
        char            old_path[MAXPGPATH];
        char            new_path[MAXPGPATH];
 
-       remove_new_subdir(subdir, true);
+       remove_new_subdir(new_subdir, true);
 
-       snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, 
subdir);
-       snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, 
subdir);
+       snprintf(old_path, sizeof(old_path), "%s/%s", old_cluster.pgdata, 
old_subdir);
+       snprintf(new_path, sizeof(new_path), "%s/%s", new_cluster.pgdata, 
new_subdir);
 
-       prep_status("Copying old %s to new server", subdir);
+       prep_status("Copying old %s to new server", old_subdir);
 
        exec_prog(UTILITY_LOG_FILE, NULL, true,
 #ifndef WIN32
@@ -399,10 +399,16 @@ copy_subdir_files(char *subdir)
 }
 
 static void
-copy_clog_xlog_xid(void)
+copy_xact_xlog_xid(void)
 {
-       /* copy old commit logs to new data dir */
-       copy_subdir_files("pg_clog");
+       /*
+        * Copy old commit logs to new data dir. pg_clog has been renamed to
+        * pg_xact in post-10 clusters.
+        */
+       copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) < 1000 ?
+                                         "pg_clog" : "pg_xact",
+                                         
GET_MAJOR_VERSION(new_cluster.major_version) < 1000 ?
+                                         "pg_clog" : "pg_xact");
 
        /* set the next transaction id and epoch of the new cluster */
        prep_status("Setting next transaction ID and epoch for new cluster");
@@ -432,8 +438,8 @@ copy_clog_xlog_xid(void)
        if (old_cluster.controldata.cat_ver >= MULTIXACT_FORMATCHANGE_CAT_VER &&
                new_cluster.controldata.cat_ver >= 
MULTIXACT_FORMATCHANGE_CAT_VER)
        {
-               copy_subdir_files("pg_multixact/offsets");
-               copy_subdir_files("pg_multixact/members");
+               copy_subdir_files("pg_multixact/offsets", 
"pg_multixact/offsets");
+               copy_subdir_files("pg_multixact/members", 
"pg_multixact/members");
 
                prep_status("Setting next multixact ID and offset for new 
cluster");
 
diff --git a/src/include/access/slru.h b/src/include/access/slru.h
index 5fcebc5..96a1e44 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_clog, false for multixact, pg_subtrans, pg_notify).  
group_lsn[]
+        * for pg_xact, false for multixact, pg_subtrans, 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
        SlruShared      shared;
 
        /*
-        * This flag tells whether to fsync writes (true for pg_clog and 
multixact
+        * This flag tells whether to fsync writes (true for pg_xact and 
multixact
         * stuff, false for pg_subtrans and pg_notify).
         */
        bool            do_fsync;
-- 
2.10.1

From f7b2413b716ae93bd5f2b7b3abb892c8a936f271 Mon Sep 17 00:00:00 2001
From: Michael Paquier <mich...@paquier.xyz>
Date: Sun, 23 Oct 2016 21:33:02 +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/func.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 +-
 19 files changed, 53 insertions(+), 48 deletions(-)

diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index e9cfb06..74ccb77 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15330,7 +15330,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/storage.sgml b/doc/src/sgml/storage.sgml
index 56aef3c..e72331d 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 1f9fac9..aa0eccb 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 e7dd19f..94553f1 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 6871239..e0f0395 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 0a103c3..9f11dfd 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 8bed3f5..5b3831a 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 2f7e645..8703eea 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 0dc4d43..5703234 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -544,7 +544,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 ba1bce2..c21362d 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8640,9 +8640,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.
         */
@@ -8979,9 +8979,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 ffc7e58..32c1998 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 8b59fc5..2d73734 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 d41a79f..e4e88a9 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -935,7 +935,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
@@ -1152,7 +1152,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
@@ -1166,7 +1166,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)
        {
@@ -1175,7 +1175,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
@@ -1276,7 +1276,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.
  *
@@ -3081,14 +3081,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 41e89e1..5cfa917 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 9b82622..8f0460d 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 579d7a1..61a1491 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 b242e30..c6633c9 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 96a1e44..54ad056 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.
@@ -121,7 +121,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 7dc8dac..08c2d68 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.10.1

-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to