diff --git a/contrib/pg_upgrade/exec.c b/contrib/pg_upgrade/exec.c index 2543763cbc..a8797be9d7 100644 --- a/contrib/pg_upgrade/exec.c +++ b/contrib/pg_upgrade/exec.c @@ -138,7 +138,7 @@ check_exec(migratorContext *ctx, const char *dir, const char *cmdName) char path[MAXPGPATH]; const char *errMsg; - snprintf(path, sizeof(path), "%s%c%s", dir, pathSeparator, cmdName); + snprintf(path, sizeof(path), "%s/%s", dir, cmdName); if ((errMsg = validate_exec(path)) == NULL) return 1; /* 1 -> first alternative OK */ @@ -286,8 +286,8 @@ check_data_dir(migratorContext *ctx, const char *pg_data) { struct stat statBuf; - snprintf(subDirName, sizeof(subDirName), "%s%c%s", pg_data, - pathSeparator, requiredSubdirs[subdirnum]); + snprintf(subDirName, sizeof(subDirName), "%s/%s", pg_data, + requiredSubdirs[subdirnum]); if ((stat(subDirName, &statBuf)) != 0) { diff --git a/contrib/pg_upgrade/file.c b/contrib/pg_upgrade/file.c index 3ffea54ef2..f035a6ad2f 100644 --- a/contrib/pg_upgrade/file.c +++ b/contrib/pg_upgrade/file.c @@ -13,12 +13,6 @@ #include #endif -#ifndef WIN32 -char pathSeparator = '/'; -#else -char pathSeparator = '\\'; -#endif - static int copy_file(const char *fromfile, const char *tofile, bool force); diff --git a/contrib/pg_upgrade/option.c b/contrib/pg_upgrade/option.c index f95cb4c70d..4d97da05ab 100644 --- a/contrib/pg_upgrade/option.c +++ b/contrib/pg_upgrade/option.c @@ -308,9 +308,13 @@ validateDirectoryOption(migratorContext *ctx, char **dirpath, /* * Trim off any trailing path separators */ - if ((*dirpath)[strlen(*dirpath) - 1] == pathSeparator) +#ifndef WIN32 + if ((*dirpath)[strlen(*dirpath) - 1] == '/') +#else + if ((*dirpath)[strlen(*dirpath) - 1] == '/' || + (*dirpath)[strlen(*dirpath) - 1] == '\\') +#endif (*dirpath)[strlen(*dirpath) - 1] = 0; - } diff --git a/contrib/pg_upgrade/pg_upgrade.h b/contrib/pg_upgrade/pg_upgrade.h index 773ff6c88c..e6f4d3ea11 100644 --- a/contrib/pg_upgrade/pg_upgrade.h +++ b/contrib/pg_upgrade/pg_upgrade.h @@ -16,8 +16,6 @@ #include "libpq-fe.h" /* Allocate for null byte */ -#define NAMEDATASIZE (NAMEDATALEN + 1) - #define USER_NAME_SIZE 128 #define MAX_STRING 1024 @@ -73,15 +71,13 @@ extern int pgunlink(const char *path); extern void copydir(char *fromdir, char *todir, bool recurse); extern bool rmtree(const char *path, bool rmtopdir); -extern char pathSeparator; - /* * Each relation is represented by a relinfo structure. */ typedef struct { - char nspname[NAMEDATASIZE]; /* namespace name */ - char relname[NAMEDATASIZE]; /* relation name */ + char nspname[NAMEDATALEN]; /* namespace name */ + char relname[NAMEDATALEN]; /* relation name */ Oid reloid; /* relation oid */ Oid relfilenode; /* relation relfile node */ Oid toastrelid; /* oid of the toast relation */ @@ -103,10 +99,10 @@ typedef struct Oid new; /* Relfilenode of the new relation */ char old_file[MAXPGPATH]; char new_file[MAXPGPATH]; - char old_nspname[NAMEDATASIZE]; /* old name of the namespace */ - char old_relname[NAMEDATASIZE]; /* old name of the relation */ - char new_nspname[NAMEDATASIZE]; /* new name of the namespace */ - char new_relname[NAMEDATASIZE]; /* new name of the relation */ + char old_nspname[NAMEDATALEN]; /* old name of the namespace */ + char old_relname[NAMEDATALEN]; /* old name of the relation */ + char new_nspname[NAMEDATALEN]; /* new name of the namespace */ + char new_relname[NAMEDATALEN]; /* new name of the relation */ } FileNameMap; /* @@ -115,7 +111,7 @@ typedef struct typedef struct { Oid db_oid; /* oid of the database */ - char db_name[NAMEDATASIZE]; /* database name */ + char db_name[NAMEDATALEN]; /* database name */ char db_tblspace[MAXPGPATH]; /* database default tablespace path */ RelInfoArr rel_arr; /* array of all user relinfos */ } DbInfo; diff --git a/contrib/pg_upgrade/version_old_8_3.c b/contrib/pg_upgrade/version_old_8_3.c index f15f5613cf..8d56893f77 100644 --- a/contrib/pg_upgrade/version_old_8_3.c +++ b/contrib/pg_upgrade/version_old_8_3.c @@ -318,8 +318,8 @@ old_8_3_rebuild_tsvector_tables(migratorContext *ctx, bool check_mode, { PGresult *res; bool db_used = false; - char old_nspname[NAMEDATASIZE] = "", - old_relname[NAMEDATASIZE] = ""; + char old_nspname[NAMEDATALEN] = "", + old_relname[NAMEDATALEN] = ""; int ntups; int rowno; int i_nspname,