From 0a803d65e4ae1f6817dcc196f7e59f36e438df52 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Thu, 25 Aug 2011 12:37:32 -0400 Subject: [PATCH] Properly quote SQL/MED generic options in pg_dump output. Shigeru Hanada --- src/bin/pg_dump/pg_dump.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index cf0fc4b5d3..d7a147eb1f 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -5626,7 +5626,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables) "CASE WHEN a.attcollation <> t.typcollation " "THEN a.attcollation ELSE 0 END AS attcollation, " "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(attfdwoptions)), ', ') " " AS attfdwoptions " "FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t " @@ -6420,7 +6421,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); @@ -6432,7 +6434,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); @@ -6519,7 +6522,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); @@ -11446,7 +11450,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); @@ -12094,7 +12098,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) " -- 2.40.0