From c755f6027f41f1fab78b3bebad5a64128d81d728 Mon Sep 17 00:00:00 2001
From: "Thomas G. Lockhart" <lockhart@fourpalms.org>
Date: Sun, 4 Aug 2002 06:53:10 +0000
Subject: [PATCH] Implement WAL log location control using "-X" or PGXLOG.

---
 src/backend/access/transam/xlog.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 57e2dc6053a..fa9cc90dd53 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
  * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.98 2002/06/20 20:29:25 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.99 2002/08/04 06:53:10 thomas Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -389,7 +389,7 @@ static ControlFileData *ControlFile = NULL;
 
 
 /* File path names */
-static char XLogDir[MAXPGPATH];
+static char XLogDir[MAXPGPATH] = "";
 static char ControlFilePath[MAXPGPATH];
 
 /*
@@ -2065,11 +2065,28 @@ ValidXLOGHeader(XLogPageHeader hdr, int emode, bool checkSUI)
  * I/O and compatibility-check functions, but there seems no need currently.
  */
 
+void
+SetXLogDir(char *path)
+{
+	if (path != NULL)
+	{
+		if (strlen(path) >= MAXPGPATH)
+			elog(FATAL, "XLOG path '%s' is too long"
+				 "; maximum length is %d characters", path, MAXPGPATH-1);
+		strcpy(XLogDir, path);
+	}
+	else
+	{
+		snprintf(XLogDir, MAXPGPATH, "%s/pg_xlog", DataDir);
+	}
+}
+
 void
 XLOGPathInit(void)
 {
 	/* Init XLOG file paths */
-	snprintf(XLogDir, MAXPGPATH, "%s/pg_xlog", DataDir);
+	if (strlen(XLogDir) <= 0)
+		SetXLogDir(NULL);
 	snprintf(ControlFilePath, MAXPGPATH, "%s/global/pg_control", DataDir);
 }
 
-- 
GitLab