Commit 0a803d65 authored by Robert Haas's avatar Robert Haas

Properly quote SQL/MED generic options in pg_dump output.

Shigeru Hanada
parent 48bc5765
...@@ -5626,7 +5626,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables) ...@@ -5626,7 +5626,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
"CASE WHEN a.attcollation <> t.typcollation " "CASE WHEN a.attcollation <> t.typcollation "
"THEN a.attcollation ELSE 0 END AS attcollation, " "THEN a.attcollation ELSE 0 END AS attcollation, "
"array_to_string(ARRAY(" "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)), ', ') " " FROM pg_options_to_table(attfdwoptions)), ', ') "
" AS attfdwoptions " " AS attfdwoptions "
"FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t " "FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
...@@ -6420,7 +6421,8 @@ getForeignDataWrappers(int *numForeignDataWrappers) ...@@ -6420,7 +6421,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
"fdwhandler::pg_catalog.regproc, " "fdwhandler::pg_catalog.regproc, "
"fdwvalidator::pg_catalog.regproc, fdwacl, " "fdwvalidator::pg_catalog.regproc, fdwacl, "
"array_to_string(ARRAY(" "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_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper", "FROM pg_foreign_data_wrapper",
username_subquery); username_subquery);
...@@ -6432,7 +6434,8 @@ getForeignDataWrappers(int *numForeignDataWrappers) ...@@ -6432,7 +6434,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
"'-' AS fdwhandler, " "'-' AS fdwhandler, "
"fdwvalidator::pg_catalog.regproc, fdwacl, " "fdwvalidator::pg_catalog.regproc, fdwacl, "
"array_to_string(ARRAY(" "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_options_to_table(fdwoptions)), ', ') AS fdwoptions "
"FROM pg_foreign_data_wrapper", "FROM pg_foreign_data_wrapper",
username_subquery); username_subquery);
...@@ -6519,7 +6522,8 @@ getForeignServers(int *numForeignServers) ...@@ -6519,7 +6522,8 @@ getForeignServers(int *numForeignServers)
"(%s srvowner) AS rolname, " "(%s srvowner) AS rolname, "
"srvfdw, srvtype, srvversion, srvacl," "srvfdw, srvtype, srvversion, srvacl,"
"array_to_string(ARRAY(" "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_options_to_table(srvoptions)), ', ') AS srvoptions "
"FROM pg_foreign_server", "FROM pg_foreign_server",
username_subquery); username_subquery);
...@@ -11446,7 +11450,7 @@ dumpUserMappings(Archive *fout, ...@@ -11446,7 +11450,7 @@ dumpUserMappings(Archive *fout,
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT usename, " "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 " "FROM pg_user_mappings "
"WHERE srvid = %u", "WHERE srvid = %u",
catalogId.oid); catalogId.oid);
...@@ -12094,7 +12098,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo) ...@@ -12094,7 +12098,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
/* retrieve name of foreign server and generic options */ /* retrieve name of foreign server and generic options */
appendPQExpBuffer(query, appendPQExpBuffer(query,
"SELECT fs.srvname, array_to_string(ARRAY(" "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_options_to_table(ftoptions)), ', ') AS ftoptions "
"FROM pg_foreign_table ft JOIN pg_foreign_server fs " "FROM pg_foreign_table ft JOIN pg_foreign_server fs "
" ON (fs.oid = ft.ftserver) " " ON (fs.oid = ft.ftserver) "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment