]> granicus.if.org Git - postgresql/commitdiff
Add missing SYSTEMQUOTEs
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 30 Apr 2014 07:34:15 +0000 (10:34 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 30 Apr 2014 07:36:31 +0000 (10:36 +0300)
Some popen() calls were missing SYSTEMQUOTEs, which caused initdb and
pg_upgrade to fail on Windows, if the installation path contained both
spaces and @ signs.

Patch by Nikhil Deshpande. Backpatch to all supported versions.

contrib/pg_upgrade/check.c
src/bin/initdb/initdb.c

index 32b9bb998ae91f5b9c18452f5b64026545707872..9cc0a106731fcdcad3b042addb0fcb477caec5cd 100644 (file)
@@ -936,7 +936,7 @@ get_bin_version(ClusterInfo *cluster)
        int                     pre_dot,
                                post_dot;
 
-       snprintf(cmd, sizeof(cmd), "\"%s/pg_ctl\" --version", cluster->bindir);
+       snprintf(cmd, sizeof(cmd), SYSTEMQUOTE "\"%s/pg_ctl\" --version" SYSTEMQUOTE, cluster->bindir);
 
        if ((output = popen(cmd, "r")) == NULL ||
                fgets(cmd_output, sizeof(cmd_output), output) == NULL)
index cb0f021aac2b8fb495e69344823fce13cbd720b8..13f093bb4903c3962780845eb27f6bb61fbf90f5 100644 (file)
@@ -1247,7 +1247,7 @@ bootstrap_template1(void)
        unsetenv("PGCLIENTENCODING");
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" --boot -x1 %s %s",
+                        SYSTEMQUOTE "\"%s\" --boot -x1 %s %s" SYSTEMQUOTE,
                         backend_exec, boot_options, talkargs);
 
        PG_CMD_OPEN;
@@ -1286,7 +1286,7 @@ setup_auth(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1364,7 +1364,7 @@ get_set_pwd(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1464,7 +1464,7 @@ setup_depend(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1497,7 +1497,7 @@ setup_sysviews(void)
         * We use -j here to avoid backslashing stuff in system_views.sql
         */
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s -j template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1528,7 +1528,7 @@ setup_description(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1635,7 +1635,7 @@ setup_collation(void)
 
 #if defined(HAVE_LOCALE_T) && !defined(WIN32)
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1774,7 +1774,7 @@ setup_conversion(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1812,7 +1812,7 @@ setup_dictionary(void)
         * We use -j here to avoid backslashing stuff
         */
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s -j template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1863,7 +1863,7 @@ setup_privileges(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1926,7 +1926,7 @@ setup_schema(void)
         * We use -j here to avoid backslashing stuff in information_schema.sql
         */
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s -j template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s -j template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1943,7 +1943,7 @@ setup_schema(void)
        PG_CMD_CLOSE;
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -1977,7 +1977,7 @@ load_plpgsql(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -2002,7 +2002,7 @@ vacuum_db(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -2058,7 +2058,7 @@ make_template0(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);
 
@@ -2090,7 +2090,7 @@ make_postgres(void)
        fflush(stdout);
 
        snprintf(cmd, sizeof(cmd),
-                        "\"%s\" %s template1 >%s",
+                        SYSTEMQUOTE "\"%s\" %s template1 >%s" SYSTEMQUOTE,
                         backend_exec, backend_options,
                         DEVNULL);