On Mon, Aug 29, 2016 at 2:36 PM, Craig Ringer
<craig.rin...@2ndquadrant.com> wrote:
> I don't care if it comes as part of some greater reorg or not but I'll be
> really annoyed if scope creep lands up killing the original proposal to just
> rename these dirs. I think that a simple rename should be done first. Then
> if some greater reorg is to be done it can be done shortly after. The only
> people that'll upset are folks tracking early 10.0 dev and they'll be aware
> it's coming.

Okay, so let's do it. Attached are two patches:
- 0001 renames pg_clog to pg_trans. I have let clog.c with its current
name, as well as its structures. That's the mechanical patch, the ony
interesting part being in pg_upgrade.
- 0002 renames pg_xlog to pg_wal.
-- 
Michael
From 74ff97a9520f496e0df303e777ad93d5eca054f5 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Mon, 29 Aug 2016 15:05:46 +0900
Subject: [PATCH 1/2] Rename pg_clog to pg_trans

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      | 12 +++---
 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  |  4 +-
 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              | 79 +++++++++++++++++++++-------------
 src/bin/pg_upgrade/pg_upgrade.c        | 30 +++++++------
 src/include/access/slru.h              |  4 +-
 28 files changed, 127 insertions(+), 102 deletions(-)

diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index 0f09d82..18d4bd5 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_trans/*</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_trans</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 4e09e06..783d49c 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_trans</> 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_trans</> 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 7c483c6..c32da94 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -5816,7 +5816,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_trans</> 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 5148095..626e428 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15312,7 +15312,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_trans        | 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 2713883..75f61cd 100644
--- a/doc/src/sgml/maintenance.sgml
+++ b/doc/src/sgml/maintenance.sgml
@@ -505,18 +505,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_trans</> 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_trans</> 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_trans</> storage.
     (The default, 200 million transactions, translates to about 50MB of
-    <filename>pg_clog</> storage.)
+    <filename>pg_trans</> storage.)
    </para>
 
    <para>
diff --git a/doc/src/sgml/ref/pg_resetxlog.sgml b/doc/src/sgml/ref/pg_resetxlog.sgml
index fd9d0be..7253b40 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_trans</> 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_trans</>, <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 42ebfbf..fb64305 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_trans</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 1b812bd..1528a2e 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>
@@ -136,6 +131,11 @@ Item
 </row>
 
 <row>
+ <entry><filename>pg_trans</></entry>
+ <entry>Subdirectory containing transaction commit status data</entry>
+</row>
+
+<row>
  <entry><filename>pg_twophase</></entry>
  <entry>Subdirectory containing state files for prepared transactions</entry>
 </row>
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index 503ea8a..fd179ec 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_trans</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 6a27ef4..39a3dc3 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -6751,8 +6751,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_trans before we finish
+ * the VACUUM and perhaps truncate off the part of pg_trans 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..f941cfd 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_trans and pg_subtrans
+------------------------
 
-pg_clog and pg_subtrans are permanent (on-disk) storage of transaction related
+pg_trans 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_trans 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_trans 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_trans 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..a6bddd1 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_trans", LWTRANCHE_CLOG_BUFFERS);
 }
 
 /*
diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c
index e330105..08a0251 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_trans-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..303acf6 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_trans-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..8962c26 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_clog-like manager that stores the parent
+ * The pg_subtrans manager is a pg_trans-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.
  *
  * 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_trans, 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..108c1da 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_trans 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 9f55adc..2a51f67 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_trans, 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.
@@ -2089,7 +2089,7 @@ RecordTransactionCommitPrepared(TransactionId xid,
 	/* Flush XLOG to disk */
 	XLogFlush(recptr);
 
-	/* Mark the transaction committed in pg_clog */
+	/* Mark the transaction committed in pg_trans */
 	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..2f5bf34 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_trans.  Without this, it is possible for the checkpoint to set
+		 * REDO after the XLOG record but fail to flush the pg_trans 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_trans.  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_trans (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_trans. */
 		(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_trans.
 		 */
 		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_trans. 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_trans, 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_trans, 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 acd95aa..4333903 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8392,7 +8392,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_trans.  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..a5babef 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_trans 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_trans 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_trans 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_trans).
  *		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_trans 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 1a92ca1..f77aa01 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2394,7 +2394,7 @@ deleted:
 	 */
 
 	/*
-	 * Update pg_database.datfrozenxid, and truncate pg_clog if possible. We
+	 * Update pg_database.datfrozenxid, and truncate pg_trans 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..e7dda01 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_trans), 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..5ce3a44 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_trans.
  *
  * 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_trans 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..c4202e5 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_trans).  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_trans 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_trans 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 aad6ba5..ec06e34 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -201,7 +201,6 @@ static const char *backend_options = "--single -F -O -j -c search_path=pg_catalo
 static const char *const subdirs[] = {
 	"global",
 	"pg_xlog/archive_status",
-	"pg_clog",
 	"pg_commit_ts",
 	"pg_dynshmem",
 	"pg_notify",
@@ -218,6 +217,7 @@ static const char *const subdirs[] = {
 	"pg_tblspc",
 	"pg_stat",
 	"pg_stat_tmp",
+	"pg_trans",
 	"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 dd30952..5f6a6ea 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -14,7 +14,7 @@
 #include <fcntl.h>
 #include <sys/types.h>
 
-static void check_data_dir(const char *pg_data);
+static void check_data_dir(ClusterInfo *cluster);
 static void check_bin_dir(ClusterInfo *cluster);
 static void validate_exec(const char *dir, const char *cmdName);
 
@@ -220,9 +220,9 @@ verify_directories(void)
 		pg_fatal("You must have read and write access in the current directory.\n");
 
 	check_bin_dir(&old_cluster);
-	check_data_dir(old_cluster.pgdata);
+	check_data_dir(&old_cluster);
 	check_bin_dir(&new_cluster);
-	check_data_dir(new_cluster.pgdata);
+	check_data_dir(&new_cluster);
 }
 
 
@@ -253,6 +253,31 @@ win32_check_directory_write_permissions(void)
 
 
 /*
+ * check_single_dir()
+ *
+ *  Check for the presence of a single directory in PGDATA, and fail if
+ * is it missing or not accessible.
+ */
+static void
+check_single_dir(const char *pg_data, const char *subdir)
+{
+	struct stat statBuf;
+	char        subDirName[MAXPGPATH];
+
+	snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
+	/* Win32 can't stat() a directory with a trailing slash. */
+				 *subdir ? "/" : "",
+				 subdir);
+
+	if (stat(subDirName, &statBuf) != 0)
+		report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
+					  subDirName, getErrorText());
+	else if (!S_ISDIR(statBuf.st_mode))
+		report_status(PG_FATAL, "%s is not a directory\n",
+					  subDirName);
+}
+
+/*
  * check_data_dir()
  *
  *	This function validates the given cluster directory - we search for a
@@ -262,34 +287,28 @@ win32_check_directory_write_permissions(void)
  *
  */
 static void
-check_data_dir(const char *pg_data)
+check_data_dir(ClusterInfo *cluster)
 {
-	char		subDirName[MAXPGPATH];
-	int			subdirnum;
-
-	/* start check with top-most directory */
-	const char *requiredSubdirs[] = {"", "base", "global", "pg_clog",
-		"pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase",
-	"pg_xlog"};
-
-	for (subdirnum = 0;
-		 subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]);
-		 ++subdirnum)
-	{
-		struct stat statBuf;
-
-		snprintf(subDirName, sizeof(subDirName), "%s%s%s", pg_data,
-		/* Win32 can't stat() a directory with a trailing slash. */
-				 *requiredSubdirs[subdirnum] ? "/" : "",
-				 requiredSubdirs[subdirnum]);
-
-		if (stat(subDirName, &statBuf) != 0)
-			report_status(PG_FATAL, "check for \"%s\" failed: %s\n",
-						  subDirName, getErrorText());
-		else if (!S_ISDIR(statBuf.st_mode))
-			report_status(PG_FATAL, "%s is not a directory\n",
-						  subDirName);
-	}
+	const char *pg_data = cluster->pgdata;
+
+	/* get old and new cluster versions */
+	old_cluster.major_version = get_major_server_version(&old_cluster);
+	new_cluster.major_version = get_major_server_version(&new_cluster);
+
+	check_single_dir(pg_data, "");
+	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");
+	check_single_dir(pg_data, "pg_xlog");
+
+	/* pg_clog has been renamed to pg_trans 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_trans");
 }
 
 
diff --git a/src/bin/pg_upgrade/pg_upgrade.c b/src/bin/pg_upgrade/pg_upgrade.c
index fa118e9..dd7a54b 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_trans_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_trans_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_trans_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_trans in post-10 clusters.
+	 */
+	copy_subdir_files(GET_MAJOR_VERSION(old_cluster.major_version) < 1000 ?
+					  "pg_clog" : "pg_trans",
+					  GET_MAJOR_VERSION(new_cluster.major_version) < 1000 ?
+					  "pg_clog" : "pg_trans");
 
 	/* 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..e279d0d 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_trans, 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_trans and multixact
 	 * stuff, false for pg_subtrans and pg_notify).
 	 */
 	bool		do_fsync;
-- 
2.9.3

From 02687ad0239f3ba617b78f88cf1630c2b0886a73 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@otacoo.com>
Date: Mon, 29 Aug 2016 15:26:38 +0900
Subject: [PATCH 2/2] Rename pg_xlog to pg_wal

Additional check handling is needed in pg_upgrade regarding the clusters
worked on, except that it is a very mechanical patch.
---
 doc/src/sgml/backup.sgml                     |  28 ++++----
 doc/src/sgml/config.sgml                     |   6 +-
 doc/src/sgml/func.sgml                       |   2 +-
 doc/src/sgml/high-availability.sgml          |  14 ++--
 doc/src/sgml/perform.sgml                    |   2 +-
 doc/src/sgml/protocol.sgml                   |   6 +-
 doc/src/sgml/ref/pg_resetxlog.sgml           |  10 +--
 doc/src/sgml/ref/pg_rewind.sgml              |   4 +-
 doc/src/sgml/ref/pg_xlogdump.sgml            |   2 +-
 doc/src/sgml/ref/pgtestfsync.sgml            |   4 +-
 doc/src/sgml/ref/pgupgrade.sgml              |   4 +-
 doc/src/sgml/storage.sgml                    |   2 +-
 doc/src/sgml/wal.sgml                        |  10 +--
 src/backend/access/transam/timeline.c        |   4 +-
 src/backend/access/transam/xlog.c            | 100 +++++++++++++--------------
 src/backend/access/transam/xlogarchive.c     |   2 +-
 src/backend/access/transam/xlogfuncs.c       |   2 +-
 src/backend/replication/README               |   2 +-
 src/backend/replication/basebackup.c         |  20 +++---
 src/backend/replication/walreceiver.c        |   6 +-
 src/backend/replication/walsender.c          |   4 +-
 src/backend/storage/file/fd.c                |  16 ++---
 src/bin/initdb/initdb.c                      |  26 +++----
 src/bin/pg_basebackup/pg_basebackup.c        |  16 ++---
 src/bin/pg_basebackup/t/010_pg_basebackup.pl |   6 +-
 src/bin/pg_resetxlog/pg_resetxlog.c          |   2 +-
 src/bin/pg_rewind/copy_fetch.c               |   4 +-
 src/bin/pg_rewind/filemap.c                  |   8 +--
 src/bin/pg_rewind/parsexlog.c                |   2 +-
 src/bin/pg_rewind/t/004_pg_xlog_symlink.pl   |  10 +--
 src/bin/pg_upgrade/exec.c                    |   7 +-
 src/bin/pg_xlogdump/pg_xlogdump.c            |   2 +-
 src/include/access/xlog_internal.h           |   2 +-
 src/include/postmaster/pgarch.h              |   2 +-
 34 files changed, 171 insertions(+), 166 deletions(-)

diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml
index 18d4bd5..1fa4d0e 100644
--- a/doc/src/sgml/backup.sgml
+++ b/doc/src/sgml/backup.sgml
@@ -472,7 +472,7 @@ tar -cf backup.tar /usr/local/pgsql/data
 
   <para>
    At all times, <productname>PostgreSQL</> maintains a
-   <firstterm>write ahead log</> (WAL) in the <filename>pg_xlog/</>
+   <firstterm>write ahead log</> (WAL) in the <filename>pg_wal/</>
    subdirectory of the cluster's data directory. The log records
    every change made to the database's data files.  This log exists
    primarily for crash-safety purposes: if the system crashes, the
@@ -616,7 +616,7 @@ archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"'  # Windows
     <literal>%p</> and <literal>%f</> parameters have been replaced,
     the actual command executed might look like this:
 <programlisting>
-test ! -f /mnt/server/archivedir/00000001000000A900000065 &amp;&amp; cp pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065
+test ! -f /mnt/server/archivedir/00000001000000A900000065 &amp;&amp; cp pg_wal/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065
 </programlisting>
     A similar command will be generated for each new file to be archived.
    </para>
@@ -668,9 +668,9 @@ test ! -f /mnt/server/archivedir/00000001000000A900000065 &amp;&amp; cp pg_xlog/
     fills, nothing further can be archived until the tape is swapped.
     You should ensure that any error condition or request to a human operator
     is reported appropriately so that the situation can be
-    resolved reasonably quickly. The <filename>pg_xlog/</> directory will
+    resolved reasonably quickly. The <filename>pg_wal/</> directory will
     continue to fill with WAL segment files until the situation is resolved.
-    (If the file system containing <filename>pg_xlog/</> fills up,
+    (If the file system containing <filename>pg_wal/</> fills up,
     <productname>PostgreSQL</> will do a PANIC shutdown.  No committed
     transactions will be lost, but the database will remain offline until
     you free some space.)
@@ -682,7 +682,7 @@ test ! -f /mnt/server/archivedir/00000001000000A900000065 &amp;&amp; cp pg_xlog/
     operation continues even if the archiving process falls a little behind.
     If archiving falls significantly behind, this will increase the amount of
     data that would be lost in the event of a disaster. It will also mean that
-    the <filename>pg_xlog/</> directory will contain large numbers of
+    the <filename>pg_wal/</> directory will contain large numbers of
     not-yet-archived segment files, which could eventually exceed available
     disk space. You are advised to monitor the archiving process to ensure that
     it is working as you intend.
@@ -743,7 +743,7 @@ test ! -f /mnt/server/archivedir/00000001000000A900000065 &amp;&amp; cp pg_xlog/
     configuration file reload.  If you wish to temporarily stop archiving,
     one way to do it is to set <varname>archive_command</> to the empty
     string (<literal>''</>).
-    This will cause WAL files to accumulate in <filename>pg_xlog/</> until a
+    This will cause WAL files to accumulate in <filename>pg_wal/</> until a
     working <varname>archive_command</> is re-established.
    </para>
   </sect2>
@@ -1062,10 +1062,10 @@ SELECT pg_stop_backup();
 
    <para>
     You should, however, omit from the backup the files within the
-    cluster's <filename>pg_xlog/</> subdirectory.  This
+    cluster's <filename>pg_wal/</> subdirectory.  This
     slight adjustment is worthwhile because it reduces the risk
     of mistakes when restoring.  This is easy to arrange if
-    <filename>pg_xlog/</> is a symbolic link pointing to someplace outside
+    <filename>pg_wal/</> is a symbolic link pointing to someplace outside
     the cluster directory, which is a common setup anyway for performance
     reasons.  You might also want to exclude <filename>postmaster.pid</>
     and <filename>postmaster.opts</>, which record information
@@ -1133,7 +1133,7 @@ SELECT pg_stop_backup();
      location in case you need them later. Note that this precaution will
      require that you have enough free space on your system to hold two
      copies of your existing database. If you do not have enough space,
-     you should at least save the contents of the cluster's <filename>pg_xlog</>
+     you should at least save the contents of the cluster's <filename>pg_wal</>
      subdirectory, as it might contain logs which
      were not archived before the system went down.
     </para>
@@ -1156,9 +1156,9 @@ SELECT pg_stop_backup();
    </listitem>
    <listitem>
     <para>
-     Remove any files present in <filename>pg_xlog/</>; these came from the
+     Remove any files present in <filename>pg_wal/</>; these came from the
      file system backup and are therefore probably obsolete rather than current.
-     If you didn't archive <filename>pg_xlog/</> at all, then recreate
+     If you didn't archive <filename>pg_wal/</> at all, then recreate
      it with proper permissions,
      being careful to ensure that you re-establish it as a symbolic link
      if you had it set up that way before.
@@ -1167,7 +1167,7 @@ SELECT pg_stop_backup();
    <listitem>
     <para>
      If you have unarchived WAL segment files that you saved in step 2,
-     copy them into <filename>pg_xlog/</>.  (It is best to copy them,
+     copy them into <filename>pg_wal/</>.  (It is best to copy them,
      not move them, so you still have the unmodified files if a
      problem occurs and you have to start over.)
     </para>
@@ -1249,9 +1249,9 @@ restore_command = 'cp /mnt/server/archivedir/%f %p'
 
    <para>
     WAL segments that cannot be found in the archive will be sought in
-    <filename>pg_xlog/</>; this allows use of recent un-archived segments.
+    <filename>pg_wal/</>; this allows use of recent un-archived segments.
     However, segments that are available from the archive will be used in
-    preference to files in <filename>pg_xlog/</>.
+    preference to files in <filename>pg_wal/</>.
    </para>
 
    <para>
diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml
index c32da94..dff2945 100644
--- a/doc/src/sgml/config.sgml
+++ b/doc/src/sgml/config.sgml
@@ -2926,7 +2926,7 @@ include_dir 'conf.d'
        <listitem>
        <para>
         Specifies the minimum number of past log file segments kept in the
-        <filename>pg_xlog</>
+        <filename>pg_wal</>
         directory, in case a standby server needs to fetch them for streaming
         replication. Each segment is normally 16 megabytes. If a standby
         server connected to the sending server falls behind by more than
@@ -2940,7 +2940,7 @@ include_dir 'conf.d'
 
        <para>
         This sets only the minimum number of segments retained in
-        <filename>pg_xlog</>; the system might need to retain more segments
+        <filename>pg_wal</>; the system might need to retain more segments
         for WAL archival or to recover from a checkpoint. If
         <varname>wal_keep_segments</> is zero (the default), the system
         doesn't keep any extra segments for standby purposes, so the number
@@ -3316,7 +3316,7 @@ include_dir 'conf.d'
        <para>
         Specify how long the standby server should wait when WAL data is not
         available from any sources (streaming replication,
-        local <filename>pg_xlog</> or WAL archive) before retrying to
+        local <filename>pg_wal</> or WAL archive) before retrying to
         retrieve WAL data.  This parameter can only be set in the
         <filename>postgresql.conf</> file or on the server command line.
         The default value is 5 seconds. Units are milliseconds if not specified.
diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml
index 626e428..0fd06d6 100644
--- a/doc/src/sgml/func.sgml
+++ b/doc/src/sgml/func.sgml
@@ -15316,7 +15316,7 @@ SELECT * FROM pg_ls_dir('.') WITH ORDINALITY AS t(ls,n);
  pg_snapshots    | 13
  pg_multixact    | 14
  PG_VERSION      | 15
- pg_xlog         | 16
+ pg_wal          | 16
  pg_hba.conf     | 17
  pg_stat_tmp     | 18
  pg_subtrans     | 19
diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml
index 06f49db..5bedaf2 100644
--- a/doc/src/sgml/high-availability.sgml
+++ b/doc/src/sgml/high-availability.sgml
@@ -594,24 +594,24 @@ protocol to make nodes agree on a serializable transactional order.
     (see <xref linkend="restore-command">) or directly from the master
     over a TCP connection (streaming replication). The standby server will
     also attempt to restore any WAL found in the standby cluster's
-    <filename>pg_xlog</> directory. That typically happens after a server
+    <filename>pg_wal</> directory. That typically happens after a server
     restart, when the standby replays again WAL that was streamed from the
     master before the restart, but you can also manually copy files to
-    <filename>pg_xlog</> at any time to have them replayed.
+    <filename>pg_wal</> at any time to have them replayed.
    </para>
 
    <para>
     At startup, the standby begins by restoring all WAL available in the
     archive location, calling <varname>restore_command</>. Once it
     reaches the end of WAL available there and <varname>restore_command</>
-    fails, it tries to restore any WAL available in the <filename>pg_xlog</> directory.
+    fails, it tries to restore any WAL available in the <filename>pg_wal</> directory.
     If that fails, and streaming replication has been configured, the
     standby tries to connect to the primary server and start streaming WAL
-    from the last valid record found in archive or <filename>pg_xlog</>. If that fails
+    from the last valid record found in archive or <filename>pg_wal</>. If that fails
     or streaming replication is not configured, or if the connection is
     later disconnected, the standby goes back to step 1 and tries to
     restore the file from the archive again. This loop of retries from the
-    archive, <filename>pg_xlog</>, and via streaming replication goes on until the server
+    archive, <filename>pg_wal</>, and via streaming replication goes on until the server
     is stopped or failover is triggered by a trigger file.
    </para>
 
@@ -619,7 +619,7 @@ protocol to make nodes agree on a serializable transactional order.
     Standby mode is exited and the server switches to normal operation
     when <command>pg_ctl promote</> is run or a trigger file is found
     (<varname>trigger_file</>). Before failover,
-    any WAL immediately available in the archive or in <filename>pg_xlog</> will be
+    any WAL immediately available in the archive or in <filename>pg_wal</> will be
     restored, but no attempt is made to connect to the master.
    </para>
   </sect2>
@@ -895,7 +895,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
     However, these methods often result in retaining more WAL segments than
     required, whereas replication slots retain only the number of segments
     known to be needed.  An advantage of these methods is that they bound
-    the space requirement for <literal>pg_xlog</>; there is currently no way
+    the space requirement for <literal>pg_wal</>; there is currently no way
     to do this using replication slots.
    </para>
    <para>
diff --git a/doc/src/sgml/perform.sgml b/doc/src/sgml/perform.sgml
index 7bcbfa7..8d30fd1 100644
--- a/doc/src/sgml/perform.sgml
+++ b/doc/src/sgml/perform.sgml
@@ -1612,7 +1612,7 @@ SELECT * FROM x, y, a, b, c WHERE something AND somethingelse;
        Increase <xref linkend="guc-max-wal-size"> and <xref
        linkend="guc-checkpoint-timeout"> ; this reduces the frequency
        of checkpoints, but increases the storage requirements of
-       <filename>/pg_xlog</>.
+       <filename>/pg_wal</>.
       </para>
      </listitem>
 
diff --git a/doc/src/sgml/protocol.sgml b/doc/src/sgml/protocol.sgml
index 68b0941..800e39d 100644
--- a/doc/src/sgml/protocol.sgml
+++ b/doc/src/sgml/protocol.sgml
@@ -1947,7 +1947,7 @@ The commands accepted in walsender mode are:
          <para>
           Include the necessary WAL segments in the backup. This will include
           all the files between start and stop backup in the
-          <filename>pg_xlog</filename> directory of the base directory tar
+          <filename>pg_wal</filename> directory of the base directory tar
           file.
          </para>
         </listitem>
@@ -2074,8 +2074,8 @@ The commands accepted in walsender mode are:
        </listitem>
        <listitem>
         <para>
-         <filename>pg_xlog</>, including subdirectories. If the backup is run
-         with WAL files included, a synthesized version of <filename>pg_xlog</filename> will be
+         <filename>pg_wal</>, including subdirectories. If the backup is run
+         with WAL files included, a synthesized version of <filename>pg_wal</filename> will be
          included, but it will only contain the files necessary for the
          backup to work, not the rest of the contents.
         </para>
diff --git a/doc/src/sgml/ref/pg_resetxlog.sgml b/doc/src/sgml/ref/pg_resetxlog.sgml
index 7253b40..6226a33 100644
--- a/doc/src/sgml/ref/pg_resetxlog.sgml
+++ b/doc/src/sgml/ref/pg_resetxlog.sgml
@@ -173,22 +173,22 @@ PostgreSQL documentation
      <para>
       The WAL starting address should be
       larger than any WAL segment file name currently existing in
-      the directory <filename>pg_xlog</> under the data directory.
+      the directory <filename>pg_wal</> under the data directory.
       These names are also in hexadecimal and have three parts.  The first
       part is the <quote>timeline ID</> and should usually be kept the same.
       For example, if <filename>00000001000000320000004A</> is the
-      largest entry in <filename>pg_xlog</>, use <literal>-l 00000001000000320000004B</> or higher.
+      largest entry in <filename>pg_wal</>, use <literal>-l 00000001000000320000004B</> or higher.
      </para>
 
      <note>
       <para>
        <command>pg_resetxlog</command> itself looks at the files in
-       <filename>pg_xlog</> and chooses a default <option>-l</> setting
+       <filename>pg_wal</> and chooses a default <option>-l</> setting
        beyond the last existing file name.  Therefore, manual adjustment of
        <option>-l</> should only be needed if you are aware of WAL segment
-       files that are not currently present in <filename>pg_xlog</>, such as
+       files that are not currently present in <filename>pg_wal</>, such as
        entries in an offline archive; or if the contents of
-       <filename>pg_xlog</> have been lost entirely.
+       <filename>pg_wal</> have been lost entirely.
       </para>
      </note>
     </listitem>
diff --git a/doc/src/sgml/ref/pg_rewind.sgml b/doc/src/sgml/ref/pg_rewind.sgml
index fb64305..57ba80f 100644
--- a/doc/src/sgml/ref/pg_rewind.sgml
+++ b/doc/src/sgml/ref/pg_rewind.sgml
@@ -61,14 +61,14 @@ PostgreSQL documentation
   <para>
    <application>pg_rewind</> examines the timeline histories of the source
    and target clusters to determine the point where they diverged, and
-   expects to find WAL in the target cluster's <filename>pg_xlog</> directory
+   expects to find WAL in the target cluster's <filename>pg_wal</> directory
    reaching all the way back to the point of divergence. The point of divergence
    can be found either on the target timeline, the source timeline, or their common
    ancestor. In the typical failover scenario where the target cluster was
    shut down soon after the divergence, this is not a problem, but if the
    target cluster ran for a long time after the divergence, the old WAL
    files might no longer be present. In that case, they can be manually
-   copied from the WAL archive to the <filename>pg_xlog</> directory, or
+   copied from the WAL archive to the <filename>pg_wal</> directory, or
    fetched on startup by configuring <filename>recovery.conf</>.  The use of
    <application>pg_rewind</> is not limited to failover, e.g.  a standby
    server can be promoted, run some write transactions, and then rewinded
diff --git a/doc/src/sgml/ref/pg_xlogdump.sgml b/doc/src/sgml/ref/pg_xlogdump.sgml
index 177caab..cfb6d87 100644
--- a/doc/src/sgml/ref/pg_xlogdump.sgml
+++ b/doc/src/sgml/ref/pg_xlogdump.sgml
@@ -118,7 +118,7 @@ PostgreSQL documentation
       <listitem>
        <para>
         Directory in which to find log segment files.  The default is to search
-        for them in the <literal>pg_xlog</literal> subdirectory of the current
+        for them in the <literal>pg_wal</literal> subdirectory of the current
         directory.
        </para>
       </listitem>
diff --git a/doc/src/sgml/ref/pgtestfsync.sgml b/doc/src/sgml/ref/pgtestfsync.sgml
index 6e134c7..5856356 100644
--- a/doc/src/sgml/ref/pgtestfsync.sgml
+++ b/doc/src/sgml/ref/pgtestfsync.sgml
@@ -57,8 +57,8 @@
        <para>
         Specifies the file name to write test data in.
         This file should be in the same file system that the
-        <filename>pg_xlog</> directory is or will be placed in.
-        (<filename>pg_xlog</> contains the <acronym>WAL</> files.)
+        <filename>pg_wal</> directory is or will be placed in.
+        (<filename>pg_wal</> contains the <acronym>WAL</> files.)
         The default is <filename>pg_test_fsync.out</> in the current
         directory.
        </para>
diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index 9685193..4b9aab2 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -345,7 +345,7 @@ NET STOP postgresql-9.0
      your old cluster
      once you start the new cluster after the upgrade.  Link mode also
      requires that the old and new cluster data directories be in the
-     same file system.  (Tablespaces and <filename>pg_xlog</> can be on
+     same file system.  (Tablespaces and <filename>pg_wal</> can be on
      different file systems.)  See <literal>pg_upgrade --help</> for a full
      list of options.
     </para>
@@ -508,7 +508,7 @@ rsync --archive --delete --hard-links --size-only old_pgdata new_pgdata remote_d
       <para>
        If you have tablespaces, you will need to run a similar
        <application>rsync</> command for each tablespace directory.  If you
-       have relocated <filename>pg_xlog</> outside the data directories,
+       have relocated <filename>pg_wal</> outside the data directories,
        <application>rsync</> must be run on those directories too.
       </para>
      </step>
diff --git a/doc/src/sgml/storage.sgml b/doc/src/sgml/storage.sgml
index 1528a2e..000f3fd 100644
--- a/doc/src/sgml/storage.sgml
+++ b/doc/src/sgml/storage.sgml
@@ -141,7 +141,7 @@ Item
 </row>
 
 <row>
- <entry><filename>pg_xlog</></entry>
+ <entry><filename>pg_wal</></entry>
  <entry>Subdirectory containing WAL (Write Ahead Log) files</entry>
 </row>
 
diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml
index fd179ec..79d9986 100644
--- a/doc/src/sgml/wal.sgml
+++ b/doc/src/sgml/wal.sgml
@@ -557,7 +557,7 @@
   </para>
 
   <para>
-   The number of WAL segment files in <filename>pg_xlog</> directory depends on
+   The number of WAL segment files in <filename>pg_wal</> directory depends on
    <varname>min_wal_size</>, <varname>max_wal_size</> and
    the amount of WAL generated in previous checkpoint cycles. When old log
    segment files are no longer needed, they are removed or recycled (that is,
@@ -582,7 +582,7 @@
    kept at all times. Also, if WAL archiving is used, old segments can not be
    removed or recycled until they are archived. If WAL archiving cannot keep up
    with the pace that WAL is generated, or if <varname>archive_command</varname>
-   fails repeatedly, old WAL files will accumulate in <filename>pg_xlog</>
+   fails repeatedly, old WAL files will accumulate in <filename>pg_wal</>
    until the situation is resolved. A slow or failed standby server that
    uses a replication slot will have the same effect (see
    <xref linkend="streaming-replication-slots">).
@@ -594,7 +594,7 @@
    which are similar to checkpoints in normal operation: the server forces
    all its state to disk, updates the <filename>pg_control</> file to
    indicate that the already-processed WAL data need not be scanned again,
-   and then recycles any old log segment files in the <filename>pg_xlog</>
+   and then recycles any old log segment files in the <filename>pg_wal</>
    directory.
    Restartpoints can't be performed more frequently than checkpoints in the
    master because restartpoints can only be performed at checkpoint records.
@@ -734,7 +734,7 @@
 
   <para>
    <acronym>WAL</acronym> logs are stored in the directory
-   <filename>pg_xlog</filename> under the data directory, as a set of
+   <filename>pg_wal</filename> under the data directory, as a set of
    segment files, normally each 16 MB in size (but the size can be changed
    by altering the <option>--with-wal-segsize</> configure option when
    building the server).  Each segment is divided into pages, normally
@@ -751,7 +751,7 @@
   <para>
    It is advantageous if the log is located on a different disk from the
    main database files.  This can be achieved by moving the
-   <filename>pg_xlog</filename> directory to another location (while the server
+   <filename>pg_wal</filename> directory to another location (while the server
    is shut down, of course) and creating a symbolic link from the
    original location in the main data directory to the new location.
   </para>
diff --git a/src/backend/access/transam/timeline.c b/src/backend/access/transam/timeline.c
index bd91573..43436a9 100644
--- a/src/backend/access/transam/timeline.c
+++ b/src/backend/access/transam/timeline.c
@@ -43,7 +43,7 @@
 
 /*
  * Copies all timeline history files with id's between 'begin' and 'end'
- * from archive to pg_xlog.
+ * from archive to pg_wal.
  */
 void
 restoreTimeLineHistoryFiles(TimeLineID begin, TimeLineID end)
@@ -191,7 +191,7 @@ readTimeLineHistory(TimeLineID targetTLI)
 	result = lcons(entry, result);
 
 	/*
-	 * If the history file was fetched from archive, save it in pg_xlog for
+	 * If the history file was fetched from archive, save it in pg_wal for
 	 * future reference.
 	 */
 	if (fromArchive)
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 4333903..6946d4a 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -234,9 +234,9 @@ static int	LocalXLogInsertAllowed = -1;
  * valid in the startup process.
  *
  * When ArchiveRecoveryRequested is true, but InArchiveRecovery is false, we're
- * currently performing crash recovery using only XLOG files in pg_xlog, but
+ * currently performing crash recovery using only XLOG files in pg_wal, but
  * will switch to using offline XLOG archives as soon as we reach the end of
- * WAL in pg_xlog.
+ * WAL in pg_wal.
 */
 bool		ArchiveRecoveryRequested = false;
 bool		InArchiveRecovery = false;
@@ -697,12 +697,12 @@ typedef enum
 {
 	XLOG_FROM_ANY = 0,			/* request to read WAL from any source */
 	XLOG_FROM_ARCHIVE,			/* restored using restore_command */
-	XLOG_FROM_PG_XLOG,			/* existing file in pg_xlog */
+	XLOG_FROM_PG_WAL,			/* existing file in pg_wal */
 	XLOG_FROM_STREAM			/* streamed from master */
 } XLogSource;
 
 /* human-readable names for XLogSources, for debugging output */
-static const char *xlogSourceNames[] = {"any", "archive", "pg_xlog", "stream"};
+static const char *xlogSourceNames[] = {"any", "archive", "pg_wal", "stream"};
 
 /*
  * openLogFile is -1 or a kernel FD for an open log file segment.
@@ -3342,7 +3342,7 @@ XLogFileOpen(XLogSegNo segno)
  * Open a logfile segment for reading (during recovery).
  *
  * If source == XLOG_FROM_ARCHIVE, the segment is retrieved from archive.
- * Otherwise, it's assumed to be already available in pg_xlog.
+ * Otherwise, it's assumed to be already available in pg_wal.
  */
 static int
 XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
@@ -3371,7 +3371,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
 				return -1;
 			break;
 
-		case XLOG_FROM_PG_XLOG:
+		case XLOG_FROM_PG_WAL:
 		case XLOG_FROM_STREAM:
 			XLogFilePath(path, tli, segno);
 			restoredFromArchive = false;
@@ -3390,7 +3390,7 @@ XLogFileRead(XLogSegNo segno, int emode, TimeLineID tli,
 		KeepFileRestoredFromArchive(path, xlogfname);
 
 		/*
-		 * Set path to point at the new file in pg_xlog.
+		 * Set path to point at the new file in pg_wal.
 		 */
 		snprintf(path, MAXPGPATH, XLOGDIR "/%s", xlogfname);
 	}
@@ -3478,10 +3478,10 @@ XLogFileReadAnyTLI(XLogSegNo segno, int emode, int source)
 			}
 		}
 
-		if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_XLOG)
+		if (source == XLOG_FROM_ANY || source == XLOG_FROM_PG_WAL)
 		{
 			fd = XLogFileRead(segno, emode, tli,
-							  XLOG_FROM_PG_XLOG, true);
+							  XLOG_FROM_PG_WAL, true);
 			if (fd != -1)
 			{
 				if (!expectedTLEs)
@@ -3690,10 +3690,10 @@ RemoveOldXlogFiles(XLogSegNo segno, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
  *
  * This is called during recovery, whenever we switch to follow a new
  * timeline, and at the end of recovery when we create a new timeline. We
- * wouldn't otherwise care about extra WAL files lying in pg_xlog, but they
+ * wouldn't otherwise care about extra WAL files lying in pg_wal, but they
  * might be leftover pre-allocated or recycled WAL segments on the old timeline
  * that we haven't used yet, and contain garbage. If we just leave them in
- * pg_xlog, they will eventually be archived, and we can't let that happen.
+ * pg_wal, they will eventually be archived, and we can't let that happen.
  * Files that belong to our timeline history are valid, because we have
  * successfully replayed them, but from others we can't be sure.
  *
@@ -3850,15 +3850,15 @@ RemoveXlogFile(const char *segname, XLogRecPtr PriorRedoPtr, XLogRecPtr endptr)
 }
 
 /*
- * Verify whether pg_xlog and pg_xlog/archive_status exist.
+ * Verify whether pg_wal and pg_wal/archive_status exist.
  * If the latter does not exist, recreate it.
  *
  * It is not the goal of this function to verify the contents of these
  * directories, but to help in cases where someone has performed a cluster
- * copy for PITR purposes but omitted pg_xlog from the copy.
+ * copy for PITR purposes but omitted pg_wal from the copy.
  *
- * We could also recreate pg_xlog if it doesn't exist, but a deliberate
- * policy decision was made not to.  It is fairly common for pg_xlog to be
+ * We could also recreate pg_wal if it doesn't exist, but a deliberate
+ * policy decision was made not to.  It is fairly common for pg_wal to be
  * a symlink, and if that was the DBA's intent then automatically making a
  * plain directory would result in degraded performance with no notice.
  */
@@ -3868,7 +3868,7 @@ ValidateXLOGDirectoryStructure(void)
 	char		path[MAXPGPATH];
 	struct stat stat_buf;
 
-	/* Check for pg_xlog; if it doesn't exist, error out */
+	/* Check for pg_wal; if it doesn't exist, error out */
 	if (stat(XLOGDIR, &stat_buf) != 0 ||
 		!S_ISDIR(stat_buf.st_mode))
 		ereport(FATAL,
@@ -4024,11 +4024,11 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode,
 			 * If archive recovery was requested, but we were still doing
 			 * crash recovery, switch to archive recovery and retry using the
 			 * offline archive. We have now replayed all the valid WAL in
-			 * pg_xlog, so we are presumably now consistent.
+			 * pg_wal, so we are presumably now consistent.
 			 *
 			 * We require that there's at least some valid WAL present in
-			 * pg_xlog, however (!fetch_ckpt). We could recover using the WAL
-			 * from the archive, even if pg_xlog is completely empty, but we'd
+			 * pg_wal, however (!fetch_ckpt). We could recover using the WAL
+			 * from the archive, even if pg_wal is completely empty, but we'd
 			 * have no idea how far we'd have to replay to reach consistency.
 			 * So err on the safe side and give up.
 			 */
@@ -4036,7 +4036,7 @@ ReadRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr, int emode,
 				!fetching_ckpt)
 			{
 				ereport(DEBUG1,
-						(errmsg_internal("reached end of WAL in pg_xlog, entering archive recovery")));
+						(errmsg_internal("reached end of WAL in pg_wal, entering archive recovery")));
 				InArchiveRecovery = true;
 				if (StandbyModeRequested)
 					StandbyMode = true;
@@ -4153,7 +4153,7 @@ rescanLatestTimeLine(void)
 
 	/*
 	 * As in StartupXLOG(), try to ensure we have all the history files
-	 * between the old target and new target in pg_xlog.
+	 * between the old target and new target in pg_wal.
 	 */
 	restoreTimeLineHistoryFiles(oldtarget + 1, newtarget);
 
@@ -5166,7 +5166,7 @@ readRecoveryCommandFile(void)
 			ereport(WARNING,
 					(errmsg("recovery command file \"%s\" specified neither primary_conninfo nor restore_command",
 							RECOVERY_COMMAND_FILE),
-					 errhint("The database server will regularly poll the pg_xlog subdirectory to check for files placed there.")));
+					 errhint("The database server will regularly poll the pg_wal subdirectory to check for files placed there.")));
 	}
 	else
 	{
@@ -5982,7 +5982,7 @@ StartupXLOG(void)
 #endif
 
 	/*
-	 * Verify that pg_xlog and pg_xlog/archive_status exist.  In cases where
+	 * Verify that pg_wal and pg_wal/archive_status exist.  In cases where
 	 * someone has performed a copy for PITR, these directories may have been
 	 * excluded and need to be re-created.
 	 */
@@ -6190,7 +6190,7 @@ StartupXLOG(void)
 		 * and put it into archive recovery by creating a recovery.conf file.
 		 *
 		 * Our strategy in that case is to perform crash recovery first,
-		 * replaying all the WAL present in pg_xlog, and only enter archive
+		 * replaying all the WAL present in pg_wal, and only enter archive
 		 * recovery after that.
 		 *
 		 * But usually we already know how far we need to replay the WAL (up
@@ -6394,7 +6394,7 @@ StartupXLOG(void)
 
 	/*
 	 * Copy any missing timeline history files between 'now' and the recovery
-	 * target timeline from archive to pg_xlog. While we don't need those
+	 * target timeline from archive to pg_wal. While we don't need those
 	 * files ourselves - the history file of the recovery target timeline
 	 * covers all the previous timelines in the history too - a cascading
 	 * standby server might be interested in them. Or, if you archive the WAL
@@ -7015,7 +7015,7 @@ StartupXLOG(void)
 	/*
 	 * We are now done reading the xlog from stream. Turn off streaming
 	 * recovery to force fetching the files (which would be required at end of
-	 * recovery, e.g., timeline history file) from archive or pg_xlog.
+	 * recovery, e.g., timeline history file) from archive or pg_wal.
 	 */
 	StandbyMode = false;
 
@@ -7297,7 +7297,7 @@ StartupXLOG(void)
 		 * As a compromise, we rename the last segment with the .partial
 		 * suffix, and archive it. Archive recovery will never try to read
 		 * .partial segments, so they will normally go unused. But in the odd
-		 * PITR case, the administrator can copy them manually to the pg_xlog
+		 * PITR case, the administrator can copy them manually to the pg_wal
 		 * directory (removing the suffix). They can be useful in debugging,
 		 * too.
 		 *
@@ -9862,7 +9862,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
 		 * first WAL segment containing the startup checkpoint has pages in
 		 * the beginning with the old timeline ID.  That can cause trouble at
 		 * recovery: we won't have a history file covering the old timeline if
-		 * pg_xlog directory was not included in the base backup and the WAL
+		 * pg_wal directory was not included in the base backup and the WAL
 		 * archive was cleared too before starting the backup.
 		 *
 		 * This also ensures that we have emitted a WAL page header that has
@@ -10509,7 +10509,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
 	 * archived before returning. If archiving isn't enabled, the required WAL
 	 * needs to be transported via streaming replication (hopefully with
 	 * wal_keep_segments set high enough), or some more exotic mechanism like
-	 * polling and copying files from pg_xlog with script. We have no
+	 * polling and copying files from pg_wal with script. We have no
 	 * knowledge of those mechanisms, so it's up to the user to ensure that he
 	 * gets all the required WAL.
 	 *
@@ -11099,9 +11099,9 @@ next_record_is_invalid:
  * Open the WAL segment containing WAL position 'RecPtr'.
  *
  * The segment can be fetched via restore_command, or via walreceiver having
- * streamed the record, or it can already be present in pg_xlog. Checking
- * pg_xlog is mainly for crash recovery, but it will be polled in standby mode
- * too, in case someone copies a new segment directly to pg_xlog. That is not
+ * streamed the record, or it can already be present in pg_wal. Checking
+ * pg_wal is mainly for crash recovery, but it will be polled in standby mode
+ * too, in case someone copies a new segment directly to pg_wal. That is not
  * documented or recommended, though.
  *
  * If 'fetching_ckpt' is true, we're fetching a checkpoint record, and should
@@ -11131,8 +11131,8 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 	/*-------
 	 * Standby mode is implemented by a state machine:
 	 *
-	 * 1. Read from either archive or pg_xlog (XLOG_FROM_ARCHIVE), or just
-	 *	  pg_xlog (XLOG_FROM_XLOG)
+	 * 1. Read from either archive or pg_wal (XLOG_FROM_ARCHIVE), or just
+	 *	  pg_wal (XLOG_FROM_PG_WAL)
 	 * 2. Check trigger file
 	 * 3. Read from primary server via walreceiver (XLOG_FROM_STREAM)
 	 * 4. Rescan timelines
@@ -11148,7 +11148,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 	 *-------
 	 */
 	if (!InArchiveRecovery)
-		currentSource = XLOG_FROM_PG_XLOG;
+		currentSource = XLOG_FROM_PG_WAL;
 	else if (currentSource == 0)
 		currentSource = XLOG_FROM_ARCHIVE;
 
@@ -11167,13 +11167,13 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 			switch (currentSource)
 			{
 				case XLOG_FROM_ARCHIVE:
-				case XLOG_FROM_PG_XLOG:
+				case XLOG_FROM_PG_WAL:
 
 					/*
 					 * Check to see if the trigger file exists. Note that we
 					 * do this only after failure, so when you create the
 					 * trigger file, we still finish replaying as much as we
-					 * can from archive and pg_xlog before failover.
+					 * can from archive and pg_wal before failover.
 					 */
 					if (StandbyMode && CheckForStandbyTrigger())
 					{
@@ -11183,7 +11183,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 
 					/*
 					 * Not in standby mode, and we've now tried the archive
-					 * and pg_xlog.
+					 * and pg_wal.
 					 */
 					if (!StandbyMode)
 						return false;
@@ -11243,7 +11243,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 					 * little chance that the problem will just go away, but
 					 * PANIC is not good for availability either, especially
 					 * in hot standby mode. So, we treat that the same as
-					 * disconnection, and retry from archive/pg_xlog again.
+					 * disconnection, and retry from archive/pg_wal again.
 					 * The WAL in the archive should be identical to what was
 					 * streamed, so it's unlikely that it helps, but one can
 					 * hope...
@@ -11304,11 +11304,11 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 					elog(ERROR, "unexpected WAL source %d", currentSource);
 			}
 		}
-		else if (currentSource == XLOG_FROM_PG_XLOG)
+		else if (currentSource == XLOG_FROM_PG_WAL)
 		{
 			/*
-			 * We just successfully read a file in pg_xlog. We prefer files in
-			 * the archive over ones in pg_xlog, so try the next file again
+			 * We just successfully read a file in pg_wal. We prefer files in
+			 * the archive over ones in pg_wal, so try the next file again
 			 * from the archive first.
 			 */
 			if (InArchiveRecovery)
@@ -11329,7 +11329,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 		switch (currentSource)
 		{
 			case XLOG_FROM_ARCHIVE:
-			case XLOG_FROM_PG_XLOG:
+			case XLOG_FROM_PG_WAL:
 				/* Close any old file we might have open. */
 				if (readFile >= 0)
 				{
@@ -11342,7 +11342,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 
 				/*
 				 * Try to restore the file from archive, or read an existing
-				 * file from pg_xlog.
+				 * file from pg_wal.
 				 */
 				readFile = XLogFileReadAnyTLI(readSegNo, DEBUG2,
 						 currentSource == XLOG_FROM_ARCHIVE ? XLOG_FROM_ANY :
@@ -11351,7 +11351,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 					return true;	/* success! */
 
 				/*
-				 * Nope, not found in archive or pg_xlog.
+				 * Nope, not found in archive or pg_wal.
 				 */
 				lastSourceFailed = true;
 				break;
@@ -11407,7 +11407,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 						 * not open already.  Also read the timeline history
 						 * file if we haven't initialized timeline history
 						 * yet; it should be streamed over and present in
-						 * pg_xlog by now.  Use XLOG_FROM_STREAM so that
+						 * pg_wal by now.  Use XLOG_FROM_STREAM so that
 						 * source info is set correctly and XLogReceiptTime
 						 * isn't changed.
 						 */
@@ -11439,10 +11439,10 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
 						/*
 						 * Note that we don't "return false" immediately here.
 						 * After being triggered, we still want to replay all
-						 * the WAL that was already streamed. It's in pg_xlog
+						 * the WAL that was already streamed. It's in pg_wal
 						 * now, so we just treat this as a failure, and the
 						 * state machine will move on to replay the streamed
-						 * WAL from pg_xlog, and then recheck the trigger and
+						 * WAL from pg_wal, and then recheck the trigger and
 						 * exit replay.
 						 */
 						lastSourceFailed = true;
@@ -11482,7 +11482,7 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
  * or legitimate end-of-WAL situation.   Generally, we use it as-is, but if
  * we're retrying the exact same record that we've tried previously, only
  * complain the first time to keep the noise down.  However, we only do when
- * reading from pg_xlog, because we don't expect any invalid records in archive
+ * reading from pg_wal, because we don't expect any invalid records in archive
  * or in records streamed from master. Files in the archive should be complete,
  * and we should never hit the end of WAL because we stop and wait for more WAL
  * to arrive before replaying it.
@@ -11497,7 +11497,7 @@ emode_for_corrupt_record(int emode, XLogRecPtr RecPtr)
 {
 	static XLogRecPtr lastComplaint = 0;
 
-	if (readSource == XLOG_FROM_PG_XLOG && emode == LOG)
+	if (readSource == XLOG_FROM_PG_WAL && emode == LOG)
 	{
 		if (RecPtr == lastComplaint)
 			emode = DEBUG1;
diff --git a/src/backend/access/transam/xlogarchive.c b/src/backend/access/transam/xlogarchive.c
index d153a44..b919164 100644
--- a/src/backend/access/transam/xlogarchive.c
+++ b/src/backend/access/transam/xlogarchive.c
@@ -421,7 +421,7 @@ ExecuteRecoveryCommand(char *command, char *commandName, bool failOnSignal)
 /*
  * A file was restored from the archive under a temporary filename (path),
  * and now we want to keep it. Rename it under the permanent filename in
- * in pg_xlog (xlogfname), replacing any existing file with the same name.
+ * in pg_wal (xlogfname), replacing any existing file with the same name.
  */
 void
 KeepFileRestoredFromArchive(char *path, char *xlogfname)
diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c
index 33383b4..01cbd90 100644
--- a/src/backend/access/transam/xlogfuncs.c
+++ b/src/backend/access/transam/xlogfuncs.c
@@ -128,7 +128,7 @@ pg_start_backup(PG_FUNCTION_ARGS)
  * pg_stop_backup: finish taking an on-line backup dump
  *
  * We write an end-of-backup WAL record, and remove the backup label file
- * created by pg_start_backup, creating a backup history file in pg_xlog
+ * created by pg_start_backup, creating a backup history file in pg_wal
  * instead (whence it will immediately be archived). The backup history file
  * contains the same info found in the label file, plus the backup-end time
  * and WAL location. Before 9.0, the backup-end time was read from the backup
diff --git a/src/backend/replication/README b/src/backend/replication/README
index ad4864d..0cbb990 100644
--- a/src/backend/replication/README
+++ b/src/backend/replication/README
@@ -54,7 +54,7 @@ and WalRcvData->slotname, and initializes the starting point in
 WalRcvData->receiveStart.
 
 As walreceiver receives WAL from the master server, and writes and flushes
-it to disk (in pg_xlog), it updates WalRcvData->receivedUpto and signals
+it to disk (in pg_wal), it updates WalRcvData->receivedUpto and signals
 the startup process to know how far WAL replay can advance.
 
 Walreceiver sends information about replication progress to the master server
diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index da9b7a6..3ffc665 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -276,7 +276,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
 		TimeLineID	tli;
 
 		/*
-		 * I'd rather not worry about timelines here, so scan pg_xlog and
+		 * I'd rather not worry about timelines here, so scan pg_wal and
 		 * include all WAL files in the range between 'startptr' and 'endptr',
 		 * regardless of the timeline the file is stamped with. If there are
 		 * some spurious WAL files belonging to timelines that don't belong in
@@ -289,11 +289,11 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
 		XLByteToPrevSeg(endptr, endsegno);
 		XLogFileName(lastoff, ThisTimeLineID, endsegno);
 
-		dir = AllocateDir("pg_xlog");
+		dir = AllocateDir("pg_wal");
 		if (!dir)
 			ereport(ERROR,
-				 (errmsg("could not open directory \"%s\": %m", "pg_xlog")));
-		while ((de = ReadDir(dir, "pg_xlog")) != NULL)
+				 (errmsg("could not open directory \"%s\": %m", "pg_wal")));
+		while ((de = ReadDir(dir, "pg_wal")) != NULL)
 		{
 			/* Does it look like a WAL segment, and is it in the range? */
 			if (IsXLogFileName(de->d_name) &&
@@ -331,7 +331,7 @@ perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
 		qsort(walFiles, nWalFiles, sizeof(char *), compareWalFileNames);
 
 		/*
-		 * There must be at least one xlog file in the pg_xlog directory,
+		 * There must be at least one xlog file in the pg_wal directory,
 		 * since we are doing backup-including-xlog.
 		 */
 		if (nWalFiles < 1)
@@ -988,15 +988,15 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
 		}
 
 		/*
-		 * We can skip pg_xlog, the WAL segments need to be fetched from the
+		 * We can skip pg_wal, the WAL segments need to be fetched from the
 		 * WAL archive anyway. But include it as an empty directory anyway, so
 		 * we get permissions right.
 		 */
-		if (strcmp(pathbuf, "./pg_xlog") == 0)
+		if (strcmp(pathbuf, "./pg_wal") == 0)
 		{
 			if (!sizeonly)
 			{
-				/* If pg_xlog is a symlink, write it as a directory anyway */
+				/* If pg_wal is a symlink, write it as a directory anyway */
 #ifndef WIN32
 				if (S_ISLNK(statbuf.st_mode))
 #else
@@ -1012,10 +1012,10 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces,
 			 * statbuf from above ...).
 			 */
 			if (!sizeonly)
-				_tarWriteHeader("./pg_xlog/archive_status", NULL, &statbuf);
+				_tarWriteHeader("./pg_wal/archive_status", NULL, &statbuf);
 			size += 512;		/* Size of the header just added */
 
-			continue;			/* don't recurse into pg_xlog */
+			continue;			/* don't recurse into pg_wal */
 		}
 
 		/* Allow symbolic links in pg_tblspc only */
diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c
index 413ee3a..d40b5e9 100644
--- a/src/backend/replication/walreceiver.c
+++ b/src/backend/replication/walreceiver.c
@@ -18,7 +18,7 @@
  * If the primary server ends streaming, but doesn't disconnect, walreceiver
  * goes into "waiting" mode, and waits for the startup process to give new
  * instructions. The startup process will treat that the same as
- * disconnection, and will rescan the archive/pg_xlog directory. But when the
+ * disconnection, and will rescan the archive/pg_wal directory. But when the
  * startup process wants to try streaming replication again, it will just
  * nudge the existing walreceiver process that's waiting, instead of launching
  * a new one.
@@ -364,7 +364,7 @@ WalReceiverMain(void)
 		 * we've already reached the end of the old timeline, the server will
 		 * finish the streaming immediately, and we will go back to await
 		 * orders from the startup process. If recovery_target_timeline is
-		 * 'latest', the startup process will scan pg_xlog and find the new
+		 * 'latest', the startup process will scan pg_wal and find the new
 		 * history file, bump recovery target timeline, and ask us to restart
 		 * on the new timeline.
 		 */
@@ -739,7 +739,7 @@ WalRcvFetchTimeLineHistoryFiles(TimeLineID first, TimeLineID last)
 										 tli)));
 
 			/*
-			 * Write the file to pg_xlog.
+			 * Write the file to pg_wal.
 			 */
 			writeTimeLineHistoryFile(tli, content, len);
 
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 1ea2a5c..34e4dd0 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -586,7 +586,7 @@ StartReplication(StartReplicationCmd *cmd)
 			 * segment that contains switchpoint, but on the new timeline, so
 			 * that it doesn't end up with a partial segment. If you ask for a
 			 * too old starting point, you'll get an error later when we fail
-			 * to find the requested WAL segment in pg_xlog.
+			 * to find the requested WAL segment in pg_wal.
 			 *
 			 * XXX: we could be more strict here and only allow a startpoint
 			 * that's older than the switchpoint, if it's still in the same
@@ -2052,7 +2052,7 @@ retry:
 			 *
 			 * For example, imagine that this server is currently on timeline
 			 * 5, and we're streaming timeline 4. The switch from timeline 4
-			 * to 5 happened at 0/13002088. In pg_xlog, we have these files:
+			 * to 5 happened at 0/13002088. In pg_wal, we have these files:
 			 *
 			 * ...
 			 * 000000040000000000000012
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 03143f1..b7ff5ef 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -2787,7 +2787,7 @@ looks_like_temp_rel_name(const char *name)
  * Issue fsync recursively on PGDATA and all its contents.
  *
  * We fsync regular files and directories wherever they are, but we
- * follow symlinks only for pg_xlog and immediately under pg_tblspc.
+ * follow symlinks only for pg_wal and immediately under pg_tblspc.
  * Other symlinks are presumed to point at files we're not responsible
  * for fsyncing, and might not have privileges to write at all.
  *
@@ -2811,7 +2811,7 @@ SyncDataDirectory(void)
 		return;
 
 	/*
-	 * If pg_xlog is a symlink, we'll need to recurse into it separately,
+	 * If pg_wal is a symlink, we'll need to recurse into it separately,
 	 * because the first walkdir below will ignore it.
 	 */
 	xlog_is_symlink = false;
@@ -2820,16 +2820,16 @@ SyncDataDirectory(void)
 	{
 		struct stat st;
 
-		if (lstat("pg_xlog", &st) < 0)
+		if (lstat("pg_wal", &st) < 0)
 			ereport(LOG,
 					(errcode_for_file_access(),
 					 errmsg("could not stat file \"%s\": %m",
-							"pg_xlog")));
+							"pg_wal")));
 		else if (S_ISLNK(st.st_mode))
 			xlog_is_symlink = true;
 	}
 #else
-	if (pgwin32_is_junction("pg_xlog"))
+	if (pgwin32_is_junction("pg_wal"))
 		xlog_is_symlink = true;
 #endif
 
@@ -2841,7 +2841,7 @@ SyncDataDirectory(void)
 #ifdef PG_FLUSH_DATA_WORKS
 	walkdir(".", pre_sync_fname, false, DEBUG1);
 	if (xlog_is_symlink)
-		walkdir("pg_xlog", pre_sync_fname, false, DEBUG1);
+		walkdir("pg_wal", pre_sync_fname, false, DEBUG1);
 	walkdir("pg_tblspc", pre_sync_fname, true, DEBUG1);
 #endif
 
@@ -2849,14 +2849,14 @@ SyncDataDirectory(void)
 	 * Now we do the fsync()s in the same order.
 	 *
 	 * The main call ignores symlinks, so in addition to specially processing
-	 * pg_xlog if it's a symlink, pg_tblspc has to be visited separately with
+	 * pg_wal if it's a symlink, pg_tblspc has to be visited separately with
 	 * process_symlinks = true.  Note that if there are any plain directories
 	 * in pg_tblspc, they'll get fsync'd twice.  That's not an expected case
 	 * so we don't worry about optimizing it.
 	 */
 	walkdir(".", datadir_fsync_fname, false, LOG);
 	if (xlog_is_symlink)
-		walkdir("pg_xlog", datadir_fsync_fname, false, LOG);
+		walkdir("pg_wal", datadir_fsync_fname, false, LOG);
 	walkdir("pg_tblspc", datadir_fsync_fname, true, LOG);
 }
 
diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index ec06e34..08e7338 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -200,7 +200,7 @@ static const char *backend_options = "--single -F -O -j -c search_path=pg_catalo
 
 static const char *const subdirs[] = {
 	"global",
-	"pg_xlog/archive_status",
+	"pg_wal/archive_status",
 	"pg_commit_ts",
 	"pg_dynshmem",
 	"pg_notify",
@@ -2281,7 +2281,7 @@ make_postgres(FILE *cmdfd)
  * Issue fsync recursively on PGDATA and all its contents.
  *
  * We fsync regular files and directories wherever they are, but we
- * follow symlinks only for pg_xlog and immediately under pg_tblspc.
+ * follow symlinks only for pg_wal and immediately under pg_tblspc.
  * Other symlinks are presumed to point at files we're not responsible
  * for fsyncing, and might not have privileges to write at all.
  *
@@ -2291,17 +2291,17 @@ static void
 fsync_pgdata(void)
 {
 	bool		xlog_is_symlink;
-	char		pg_xlog[MAXPGPATH];
+	char		pg_wal[MAXPGPATH];
 	char		pg_tblspc[MAXPGPATH];
 
 	fputs(_("syncing data to disk ... "), stdout);
 	fflush(stdout);
 
-	snprintf(pg_xlog, MAXPGPATH, "%s/pg_xlog", pg_data);
+	snprintf(pg_wal, MAXPGPATH, "%s/pg_wal", pg_data);
 	snprintf(pg_tblspc, MAXPGPATH, "%s/pg_tblspc", pg_data);
 
 	/*
-	 * If pg_xlog is a symlink, we'll need to recurse into it separately,
+	 * If pg_wal is a symlink, we'll need to recurse into it separately,
 	 * because the first walkdir below will ignore it.
 	 */
 	xlog_is_symlink = false;
@@ -2310,14 +2310,14 @@ fsync_pgdata(void)
 	{
 		struct stat st;
 
-		if (lstat(pg_xlog, &st) < 0)
+		if (lstat(pg_wal, &st) < 0)
 			fprintf(stderr, _("%s: could not stat file \"%s\": %s\n"),
-					progname, pg_xlog, strerror(errno));
+					progname, pg_wal, strerror(errno));
 		else if (S_ISLNK(st.st_mode))
 			xlog_is_symlink = true;
 	}
 #else
-	if (pgwin32_is_junction(pg_xlog))
+	if (pgwin32_is_junction(pg_wal))
 		xlog_is_symlink = true;
 #endif
 
@@ -2328,7 +2328,7 @@ fsync_pgdata(void)
 #ifdef PG_FLUSH_DATA_WORKS
 	walkdir(pg_data, pre_sync_fname, false);
 	if (xlog_is_symlink)
-		walkdir(pg_xlog, pre_sync_fname, false);
+		walkdir(pg_wal, pre_sync_fname, false);
 	walkdir(pg_tblspc, pre_sync_fname, true);
 #endif
 
@@ -2336,14 +2336,14 @@ fsync_pgdata(void)
 	 * Now we do the fsync()s in the same order.
 	 *
 	 * The main call ignores symlinks, so in addition to specially processing
-	 * pg_xlog if it's a symlink, pg_tblspc has to be visited separately with
+	 * pg_wal if it's a symlink, pg_tblspc has to be visited separately with
 	 * process_symlinks = true.  Note that if there are any plain directories
 	 * in pg_tblspc, they'll get fsync'd twice.  That's not an expected case
 	 * so we don't worry about optimizing it.
 	 */
 	walkdir(pg_data, fsync_fname_ext, false);
 	if (xlog_is_symlink)
-		walkdir(pg_xlog, fsync_fname_ext, false);
+		walkdir(pg_wal, fsync_fname_ext, false);
 	walkdir(pg_tblspc, fsync_fname_ext, true);
 
 	check_ok();
@@ -3087,7 +3087,7 @@ create_xlog_or_symlink(void)
 	char	   *subdirloc;
 
 	/* form name of the place for the subdirectory or symlink */
-	subdirloc = psprintf("%s/pg_xlog", pg_data);
+	subdirloc = psprintf("%s/pg_wal", pg_data);
 
 	if (strcmp(xlog_dir, "") != 0)
 	{
@@ -3220,7 +3220,7 @@ initialize_data_directory(void)
 
 	create_xlog_or_symlink();
 
-	/* Create required subdirectories (other than pg_xlog) */
+	/* Create required subdirectories (other than pg_wal) */
 	printf(_("creating subdirectories ... "));
 	fflush(stdout);
 
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index 351a420..74cdac5 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -445,14 +445,14 @@ StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier)
 		/* Error message already written in GetConnection() */
 		exit(1);
 
-	snprintf(param->xlogdir, sizeof(param->xlogdir), "%s/pg_xlog", basedir);
+	snprintf(param->xlogdir, sizeof(param->xlogdir), "%s/pg_wal", basedir);
 
 	/*
-	 * Create pg_xlog/archive_status (and thus pg_xlog) so we can write to
-	 * basedir/pg_xlog as the directory entry in the tar file may arrive
+	 * Create pg_wal/archive_status (and thus pg_wal) so we can write to
+	 * basedir/pg_wal as the directory entry in the tar file may arrive
 	 * later.
 	 */
-	snprintf(statusdir, sizeof(statusdir), "%s/pg_xlog/archive_status",
+	snprintf(statusdir, sizeof(statusdir), "%s/pg_wal/archive_status",
 			 basedir);
 
 	if (pg_mkdir_p(statusdir, S_IRWXU) != 0 && errno != EEXIST)
@@ -1249,14 +1249,14 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
 					if (mkdir(filename, S_IRWXU) != 0)
 					{
 						/*
-						 * When streaming WAL, pg_xlog will have been created
+						 * When streaming WAL, pg_wal will have been created
 						 * by the wal receiver process. Also, when transaction
-						 * log directory location was specified, pg_xlog has
+						 * log directory location was specified, pg_wal has
 						 * already been created as a symbolic link before
 						 * starting the actual backup. So just ignore creation
 						 * failures on related directories.
 						 */
-						if (!((pg_str_endswith(filename, "/pg_xlog") ||
+						if (!((pg_str_endswith(filename, "/pg_wal") ||
 							 pg_str_endswith(filename, "/archive_status")) &&
 							  errno == EEXIST))
 						{
@@ -2180,7 +2180,7 @@ main(int argc, char **argv)
 		verify_dir_is_empty_or_create(xlog_dir);
 
 		/* form name of the place where the symlink must go */
-		linkloc = psprintf("%s/pg_xlog", basedir);
+		linkloc = psprintf("%s/pg_wal", basedir);
 
 #ifdef HAVE_SYMLINK
 		if (symlink(xlog_dir, linkloc) != 0)
diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
index 6c33936..11642e4 100644
--- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl
+++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl
@@ -52,7 +52,7 @@ $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup" ],
 ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
 
 is_deeply(
-	[ sort(slurp_dir("$tempdir/backup/pg_xlog/")) ],
+	[ sort(slurp_dir("$tempdir/backup/pg_wal/")) ],
 	[ sort qw(. .. archive_status) ],
 	'no WAL files copied');
 
@@ -182,12 +182,12 @@ like(
 $node->command_ok(
 	[ 'pg_basebackup', '-D', "$tempdir/backupxf", '-X', 'fetch' ],
 	'pg_basebackup -X fetch runs');
-ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")),
+ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")),
 	'WAL files copied');
 $node->command_ok(
 	[ 'pg_basebackup', '-D', "$tempdir/backupxs", '-X', 'stream' ],
 	'pg_basebackup -X stream runs');
-ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_xlog")),
+ok(grep(/^[0-9A-F]{24}$/, slurp_dir("$tempdir/backupxf/pg_wal")),
 	'WAL files copied');
 
 $node->command_fails(
diff --git a/src/bin/pg_resetxlog/pg_resetxlog.c b/src/bin/pg_resetxlog/pg_resetxlog.c
index 525b82ba..2b76f64 100644
--- a/src/bin/pg_resetxlog/pg_resetxlog.c
+++ b/src/bin/pg_resetxlog/pg_resetxlog.c
@@ -890,7 +890,7 @@ FindEndOfXLOG(void)
 	newXlogSegNo = ControlFile.checkPointCopy.redo / ControlFile.xlog_seg_size;
 
 	/*
-	 * Scan the pg_xlog directory to find existing WAL segment files. We
+	 * Scan the pg_wal directory to find existing WAL segment files. We
 	 * assume any present have been used; in most scenarios this should be
 	 * conservative, because of xlog.c's attempts to pre-create files.
 	 */
diff --git a/src/bin/pg_rewind/copy_fetch.c b/src/bin/pg_rewind/copy_fetch.c
index 327e7ef..d0c1586 100644
--- a/src/bin/pg_rewind/copy_fetch.c
+++ b/src/bin/pg_rewind/copy_fetch.c
@@ -131,10 +131,10 @@ recurse_dir(const char *datadir, const char *parentpath,
 			/*
 			 * If it's a symlink within pg_tblspc, we need to recurse into it,
 			 * to process all the tablespaces.  We also follow a symlink if
-			 * it's for pg_xlog.  Symlinks elsewhere are ignored.
+			 * it's for pg_wal.  Symlinks elsewhere are ignored.
 			 */
 			if ((parentpath && strcmp(parentpath, "pg_tblspc") == 0) ||
-				strcmp(path, "pg_xlog") == 0)
+				strcmp(path, "pg_wal") == 0)
 				recurse_dir(datadir, path, callback);
 #else
 			pg_fatal("\"%s\" is a symbolic link, but symbolic links are not supported on this platform\n",
diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
index 9b00dc1..3905a5d 100644
--- a/src/bin/pg_rewind/filemap.c
+++ b/src/bin/pg_rewind/filemap.c
@@ -79,11 +79,11 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
 		return;
 
 	/*
-	 * Pretend that pg_xlog is a directory, even if it's really a symlink. We
+	 * Pretend that pg_wal is a directory, even if it's really a symlink. We
 	 * don't want to mess with the symlink itself, nor complain if it's a
 	 * symlink in source but not in target or vice versa.
 	 */
-	if (strcmp(path, "pg_xlog") == 0 && type == FILE_TYPE_SYMLINK)
+	if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK)
 		type = FILE_TYPE_DIRECTORY;
 
 	/*
@@ -120,7 +120,7 @@ process_source_file(const char *path, file_type_t type, size_t newsize,
 	switch (type)
 	{
 		case FILE_TYPE_DIRECTORY:
-			if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_xlog") != 0)
+			if (exists && !S_ISDIR(statbuf.st_mode) && strcmp(path, "pg_wal") != 0)
 			{
 				/* it's a directory in source, but not in target. Strange.. */
 				pg_fatal("\"%s\" is not a directory\n", localpath);
@@ -296,7 +296,7 @@ process_target_file(const char *path, file_type_t type, size_t oldsize,
 	/*
 	 * Like in process_source_file, pretend that xlog is always a  directory.
 	 */
-	if (strcmp(path, "pg_xlog") == 0 && type == FILE_TYPE_SYMLINK)
+	if (strcmp(path, "pg_wal") == 0 && type == FILE_TYPE_SYMLINK)
 		type = FILE_TYPE_DIRECTORY;
 
 	key.path = (char *) path;
diff --git a/src/bin/pg_rewind/parsexlog.c b/src/bin/pg_rewind/parsexlog.c
index b53591d..23ac4e7 100644
--- a/src/bin/pg_rewind/parsexlog.c
+++ b/src/bin/pg_rewind/parsexlog.c
@@ -54,7 +54,7 @@ static int SimpleXLogPageRead(XLogReaderState *xlogreader,
 				   TimeLineID *pageTLI);
 
 /*
- * Read WAL from the datadir/pg_xlog, starting from 'startpoint' on timeline
+ * Read WAL from the datadir/pg_wal, starting from 'startpoint' on timeline
  * index 'tliIndex' in target timeline history, until 'endpoint'. Make note of
  * the data blocks touched by the WAL records, and return them in a page map.
  */
diff --git a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
index bdcab56..12950ea 100644
--- a/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
+++ b/src/bin/pg_rewind/t/004_pg_xlog_symlink.pl
@@ -1,5 +1,5 @@
 #
-# Test pg_rewind when the target's pg_xlog directory is a symlink.
+# Test pg_rewind when the target's pg_wal directory is a symlink.
 #
 use strict;
 use warnings;
@@ -30,10 +30,10 @@ sub run_test
 
 	my $test_master_datadir = $node_master->data_dir;
 
-	# turn pg_xlog into a symlink
-	print("moving $test_master_datadir/pg_xlog to $master_xlogdir\n");
-	move("$test_master_datadir/pg_xlog", $master_xlogdir) or die;
-	symlink($master_xlogdir, "$test_master_datadir/pg_xlog") or die;
+	# turn pg_wal into a symlink
+	print("moving $test_master_datadir/pg_wal to $master_xlogdir\n");
+	move("$test_master_datadir/pg_wal", $master_xlogdir) or die;
+	symlink($master_xlogdir, "$test_master_datadir/pg_wal") or die;
 
 	RewindTest::start_master();
 
diff --git a/src/bin/pg_upgrade/exec.c b/src/bin/pg_upgrade/exec.c
index 5f6a6ea..9621d21 100644
--- a/src/bin/pg_upgrade/exec.c
+++ b/src/bin/pg_upgrade/exec.c
@@ -302,7 +302,12 @@ check_data_dir(ClusterInfo *cluster)
 	check_single_dir(pg_data, "pg_subtrans");
 	check_single_dir(pg_data, "pg_tblspc");
 	check_single_dir(pg_data, "pg_twophase");
-	check_single_dir(pg_data, "pg_xlog");
+
+	/* pg_xlog has been renamed to pg_wal in post-10 cluster */
+	if (GET_MAJOR_VERSION(cluster->major_version) < 1000)
+		check_single_dir(pg_data, "pg_xlog");
+	else
+		check_single_dir(pg_data, "pg_wal");
 
 	/* pg_clog has been renamed to pg_trans in post-10 cluster */
 	if (GET_MAJOR_VERSION(cluster->major_version) < 1000)
diff --git a/src/bin/pg_xlogdump/pg_xlogdump.c b/src/bin/pg_xlogdump/pg_xlogdump.c
index 02575eb..abc6fb9 100644
--- a/src/bin/pg_xlogdump/pg_xlogdump.c
+++ b/src/bin/pg_xlogdump/pg_xlogdump.c
@@ -656,7 +656,7 @@ usage(void)
 	printf("  -f, --follow           keep retrying after reaching end of WAL\n");
 	printf("  -n, --limit=N          number of records to display\n");
 	printf("  -p, --path=PATH        directory in which to find log segment files\n");
-	printf("                         (default: ./pg_xlog)\n");
+	printf("                         (default: ./pg_wal)\n");
 	printf("  -r, --rmgr=RMGR        only show records generated by resource manager RMGR\n");
 	printf("                         use --rmgr=list to list valid resource manager names\n");
 	printf("  -s, --start=RECPTR     start reading at log position RECPTR\n");
diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h
index 0a595cc..ceb0462 100644
--- a/src/include/access/xlog_internal.h
+++ b/src/include/access/xlog_internal.h
@@ -128,7 +128,7 @@ typedef XLogLongPageHeaderData *XLogLongPageHeader;
 /*
  * The XLog directory and control file (relative to $PGDATA)
  */
-#define XLOGDIR				"pg_xlog"
+#define XLOGDIR				"pg_wal"
 #define XLOG_CONTROL_FILE	"global/pg_control"
 
 /*
diff --git a/src/include/postmaster/pgarch.h b/src/include/postmaster/pgarch.h
index f2cbfb3..6df73c9 100644
--- a/src/include/postmaster/pgarch.h
+++ b/src/include/postmaster/pgarch.h
@@ -16,7 +16,7 @@
 /* ----------
  * Archiver control info.
  *
- * We expect that archivable files within pg_xlog will have names between
+ * We expect that archivable files within pg_wal will have names between
  * MIN_XFN_CHARS and MAX_XFN_CHARS in length, consisting only of characters
  * appearing in VALID_XFN_CHARS.  The status files in archive_status have
  * corresponding names with ".ready" or ".done" appended.
-- 
2.9.3

-- 
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