aboutsummaryrefslogtreecommitdiff
path: root/src/bin/pg_dump/pg_dump.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/pg_dump/pg_dump.c')
-rw-r--r--src/bin/pg_dump/pg_dump.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 503279733ca..8080155a957 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -11482,14 +11482,36 @@ dumpFunc(Archive *fout, FuncInfo *finfo)
/*
* Variables that are marked GUC_LIST_QUOTE were already fully quoted
* by flatten_set_variable_args() before they were put into the
- * proconfig array; we mustn't re-quote them or we'll make a mess.
+ * proconfig array. However, because the quoting rules used there
+ * aren't exactly like SQL's, we have to break the list value apart
+ * and then quote the elements as string literals. (The elements may
+ * be double-quoted as-is, but we can't just feed them to the SQL
+ * parser; it would do the wrong thing with elements that are
+ * zero-length or longer than NAMEDATALEN.)
+ *
* Variables that are not so marked should just be emitted as simple
* string literals. If the variable is not known to
- * variable_is_guc_list_quote(), we'll do the latter; this makes it
- * unsafe to use GUC_LIST_QUOTE for extension variables.
+ * variable_is_guc_list_quote(), we'll do that; this makes it unsafe
+ * to use GUC_LIST_QUOTE for extension variables.
*/
if (variable_is_guc_list_quote(configitem))
- appendPQExpBufferStr(q, pos);
+ {
+ char **namelist;
+ char **nameptr;
+
+ /* Parse string into list of identifiers */
+ /* this shouldn't fail really */
+ if (SplitGUCList(pos, ',', &namelist))
+ {
+ for (nameptr = namelist; *nameptr; nameptr++)
+ {
+ if (nameptr != namelist)
+ appendPQExpBufferStr(q, ", ");
+ appendStringLiteralAH(q, *nameptr, fout);
+ }
+ }
+ pg_free(namelist);
+ }
else
appendStringLiteralAH(q, pos, fout);
}