Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Properly quote SQL/MED generic options in pg_dump output.
authorRobert Haas <rhaas@postgresql.org>
Thu, 25 Aug 2011 16:37:32 +0000 (12:37 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 25 Aug 2011 16:37:50 +0000 (12:37 -0400)
Shigeru Hanada

src/bin/pg_dump/pg_dump.c

index 9e69b0fc5241e0ceedb304a9f62b9f56095f76da..ec1ce13e478bc92707903788e5842c4454590584 100644 (file)
@@ -6369,7 +6369,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
                          "fdwhandler::pg_catalog.regproc, "
                          "fdwvalidator::pg_catalog.regproc, fdwacl, "
                          "array_to_string(ARRAY("
-                         "     SELECT option_name || ' ' || quote_literal(option_value) "
+                         "     SELECT quote_ident(option_name) || ' ' || "
+                         "            quote_literal(option_value) "
                          "     FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
                          "FROM pg_foreign_data_wrapper",
                          username_subquery);
@@ -6381,7 +6382,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
                          "'-' AS fdwhandler, "
                          "fdwvalidator::pg_catalog.regproc, fdwacl, "
                          "array_to_string(ARRAY("
-                         "     SELECT option_name || ' ' || quote_literal(option_value) "
+                         "     SELECT quote_ident(option_name) || ' ' || "
+                         "            quote_literal(option_value) "
                          "     FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
                          "FROM pg_foreign_data_wrapper",
                          username_subquery);
@@ -6468,7 +6470,8 @@ getForeignServers(int *numForeignServers)
                      "(%s srvowner) AS rolname, "
                      "srvfdw, srvtype, srvversion, srvacl,"
                      "array_to_string(ARRAY("
-        "      SELECT option_name || ' ' || quote_literal(option_value) "
+        "      SELECT quote_ident(option_name) || ' ' || "
+        "             quote_literal(option_value) "
       "        FROM pg_options_to_table(srvoptions)), ', ') AS srvoptions "
                      "FROM pg_foreign_server",
                      username_subquery);
@@ -11395,7 +11398,7 @@ dumpUserMappings(Archive *fout,
 
    appendPQExpBuffer(query,
                      "SELECT usename, "
-                     "array_to_string(ARRAY(SELECT option_name || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n"
+                     "array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n"
                      "FROM pg_user_mappings "
                      "WHERE srvid = %u",
                      catalogId.oid);
@@ -12043,7 +12046,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
            /* retrieve name of foreign server and generic options */
            appendPQExpBuffer(query,
                              "SELECT fs.srvname, array_to_string(ARRAY("
-               "   SELECT option_name || ' ' || quote_literal(option_value)"
+               "   SELECT quote_ident(option_name) || ' ' || "
+               "          quote_literal(option_value)"
               "   FROM pg_options_to_table(ftoptions)), ', ') AS ftoptions "
                        "FROM pg_foreign_table ft JOIN pg_foreign_server fs "
                              " ON (fs.oid = ft.ftserver) "