]> granicus.if.org Git - postgresql/commitdiff
Use NAMEDATALEN instead of local define.
authorBruce Momjian <bruce@momjian.us>
Fri, 14 May 2010 00:13:38 +0000 (00:13 +0000)
committerBruce Momjian <bruce@momjian.us>
Fri, 14 May 2010 00:13:38 +0000 (00:13 +0000)
Modify path separators for Win32.

Per ideas from Takahiro Itagaki

contrib/pg_upgrade/exec.c
contrib/pg_upgrade/file.c
contrib/pg_upgrade/option.c
contrib/pg_upgrade/pg_upgrade.h
contrib/pg_upgrade/version_old_8_3.c

index 2543763cbc43fceeee37380fd9b7df2930ff29a0..a8797be9d7c5802151d91959ce75760a615a229d 100644 (file)
@@ -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)
                {
index 3ffea54ef2692a8c24692e603e469ecd6732a59b..f035a6ad2f629fc6ea83ea6b3e1cc77885c6e638 100644 (file)
 #include <windows.h>
 #endif
 
-#ifndef WIN32
-char           pathSeparator = '/';
-#else
-char           pathSeparator = '\\';
-#endif
-
 
 static int     copy_file(const char *fromfile, const char *tofile, bool force);
 
index f95cb4c70d5cf941457b0a071a92d04c485e0248..4d97da05aba693f264457a6d1e6d2aa5ff7bc46f 100644 (file)
@@ -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;
-
 }
 
 
index 773ff6c88c2fff92652e5f6b4159d2e17afd107d..e6f4d3ea11ab80bc399db97a597ea942b05b6e7d 100644 (file)
@@ -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;
index f15f5613cf8714490629ed965b15bfe22c16476e..8d56893f778e7fda17c73d1ad8ec0d3088aeaf3e 100644 (file)
@@ -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,