Skip to content

Commit 0a803d6

Browse files
committed
Properly quote SQL/MED generic options in pg_dump output.
Shigeru Hanada
1 parent 48bc576 commit 0a803d6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/bin/pg_dump/pg_dump.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5626,7 +5626,8 @@ getTableAttrs(TableInfo *tblinfo, int numTables)
56265626
"CASE WHEN a.attcollation <> t.typcollation "
56275627
"THEN a.attcollation ELSE 0 END AS attcollation, "
56285628
"array_to_string(ARRAY("
5629-
" SELECT option_name || ' ' || quote_literal(option_value) "
5629+
" SELECT quote_ident(option_name) || ' ' || "
5630+
" quote_literal(option_value) "
56305631
" FROM pg_options_to_table(attfdwoptions)), ', ') "
56315632
" AS attfdwoptions "
56325633
"FROM pg_catalog.pg_attribute a LEFT JOIN pg_catalog.pg_type t "
@@ -6420,7 +6421,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
64206421
"fdwhandler::pg_catalog.regproc, "
64216422
"fdwvalidator::pg_catalog.regproc, fdwacl, "
64226423
"array_to_string(ARRAY("
6423-
" SELECT option_name || ' ' || quote_literal(option_value) "
6424+
" SELECT quote_ident(option_name) || ' ' || "
6425+
" quote_literal(option_value) "
64246426
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
64256427
"FROM pg_foreign_data_wrapper",
64266428
username_subquery);
@@ -6432,7 +6434,8 @@ getForeignDataWrappers(int *numForeignDataWrappers)
64326434
"'-' AS fdwhandler, "
64336435
"fdwvalidator::pg_catalog.regproc, fdwacl, "
64346436
"array_to_string(ARRAY("
6435-
" SELECT option_name || ' ' || quote_literal(option_value) "
6437+
" SELECT quote_ident(option_name) || ' ' || "
6438+
" quote_literal(option_value) "
64366439
" FROM pg_options_to_table(fdwoptions)), ', ') AS fdwoptions "
64376440
"FROM pg_foreign_data_wrapper",
64386441
username_subquery);
@@ -6519,7 +6522,8 @@ getForeignServers(int *numForeignServers)
65196522
"(%s srvowner) AS rolname, "
65206523
"srvfdw, srvtype, srvversion, srvacl,"
65216524
"array_to_string(ARRAY("
6522-
" SELECT option_name || ' ' || quote_literal(option_value) "
6525+
" SELECT quote_ident(option_name) || ' ' || "
6526+
" quote_literal(option_value) "
65236527
" FROM pg_options_to_table(srvoptions)), ', ') AS srvoptions "
65246528
"FROM pg_foreign_server",
65256529
username_subquery);
@@ -11446,7 +11450,7 @@ dumpUserMappings(Archive *fout,
1144611450

1144711451
appendPQExpBuffer(query,
1144811452
"SELECT usename, "
11449-
"array_to_string(ARRAY(SELECT option_name || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n"
11453+
"array_to_string(ARRAY(SELECT quote_ident(option_name) || ' ' || quote_literal(option_value) FROM pg_options_to_table(umoptions)), ', ') AS umoptions\n"
1145011454
"FROM pg_user_mappings "
1145111455
"WHERE srvid = %u",
1145211456
catalogId.oid);
@@ -12094,7 +12098,8 @@ dumpTableSchema(Archive *fout, TableInfo *tbinfo)
1209412098
/* retrieve name of foreign server and generic options */
1209512099
appendPQExpBuffer(query,
1209612100
"SELECT fs.srvname, array_to_string(ARRAY("
12097-
" SELECT option_name || ' ' || quote_literal(option_value)"
12101+
" SELECT quote_ident(option_name) || ' ' || "
12102+
" quote_literal(option_value)"
1209812103
" FROM pg_options_to_table(ftoptions)), ', ') AS ftoptions "
1209912104
"FROM pg_foreign_table ft JOIN pg_foreign_server fs "
1210012105
" ON (fs.oid = ft.ftserver) "

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy