mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-18 18:44:06 +08:00
Use NAMEDATALEN instead of local define.
Modify path separators for Win32. Per ideas from Takahiro Itagaki
This commit is contained in:
parent
36d3afd2d4
commit
e9ad14f9f4
@ -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)
|
||||
{
|
||||
|
@ -13,12 +13,6 @@
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifndef WIN32
|
||||
char pathSeparator = '/';
|
||||
#else
|
||||
char pathSeparator = '\\';
|
||||
#endif
|
||||
|
||||
|
||||
static int copy_file(const char *fromfile, const char *tofile, bool force);
|
||||
|
||||
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user