mirror of
https://github.com/postgres/postgres.git
synced 2025-10-22 14:32:25 +03:00
Rename "pg_xlog" directory to "pg_wal".
"xlog" is not a particularly clear abbreviation for "write-ahead log", and it sometimes confuses users into believe that the contents of the "pg_xlog" directory are not critical data, leading to unpleasant consequences. So, rename the directory to "pg_wal". This patch modifies pg_upgrade and pg_basebackup to understand both the old and new directory layouts; the former is necessary given the purpose of the tool, while the latter merely avoids an unnecessary backward-compatibility break. We may wish to consider renaming other programs, switches, and functions which still use the old "xlog" naming to also refer to "wal". However, that's still under discussion, so let's do just this much for now. Discussion: CAB7nPqTeC-8+zux8_-4ZD46V7YPwooeFxgndfsq5Rg8ibLVm1A@mail.gmail.com Michael Paquier
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -252,6 +252,32 @@ win32_check_directory_write_permissions(void)
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* 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, strerror(errno));
|
||||
else if (!S_ISDIR(statBuf.st_mode))
|
||||
report_status(PG_FATAL, "%s is not a directory\n",
|
||||
subDirName);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* check_data_dir()
|
||||
*
|
||||
@@ -262,34 +288,27 @@ 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;
|
||||
const char *pg_data = cluster->pgdata;
|
||||
|
||||
/* start check with top-most directory */
|
||||
const char *requiredSubdirs[] = {"", "base", "global", "pg_clog",
|
||||
"pg_multixact", "pg_subtrans", "pg_tblspc", "pg_twophase",
|
||||
"pg_xlog"};
|
||||
/* 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);
|
||||
|
||||
for (subdirnum = 0;
|
||||
subdirnum < sizeof(requiredSubdirs) / sizeof(requiredSubdirs[0]);
|
||||
++subdirnum)
|
||||
{
|
||||
struct stat statBuf;
|
||||
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");
|
||||
|
||||
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, strerror(errno));
|
||||
else if (!S_ISDIR(statBuf.st_mode))
|
||||
report_status(PG_FATAL, "%s is not a directory\n",
|
||||
subDirName);
|
||||
}
|
||||
/* 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");
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user