summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/ruleutils.c13
-rw-r--r--src/backend/utils/misc/guc.c28
2 files changed, 35 insertions, 6 deletions
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 1b2486c2707..8b755c4f0cd 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -58,6 +58,7 @@
#include "utils/array.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
+#include "utils/guc.h"
#include "utils/hsearch.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
@@ -2197,11 +2198,15 @@ pg_get_functiondef(PG_FUNCTION_ARGS)
quote_identifier(configitem));
/*
- * Some GUC variable names are 'LIST' type and hence must not
- * be quoted.
+ * 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. Variables that are not so marked should just
+ * be emitted as simple string literals. If the variable is
+ * not known to guc.c, we'll do the latter; this makes it
+ * unsafe to use GUC_LIST_QUOTE for extension variables.
*/
- if (pg_strcasecmp(configitem, "DateStyle") == 0
- || pg_strcasecmp(configitem, "search_path") == 0)
+ if (GetConfigOptionFlags(configitem, true) & GUC_LIST_QUOTE)
appendStringInfoString(&buf, pos);
else
simple_quote_literal(&buf, pos);
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 9ecbe4a9ba9..0b403a32729 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -769,8 +769,8 @@ static const unit_conversion time_unit_conversion_table[] =
*
* 6. Don't forget to document the option (at least in config.sgml).
*
- * 7. If it's a new GUC_LIST option you must edit pg_dumpall.c to ensure
- * it is not single quoted at dump time.
+ * 7. If it's a new GUC_LIST_QUOTE option, you must add it to
+ * variable_is_guc_list_quote() in src/bin/pg_dump/dumputils.c.
*/
@@ -6689,6 +6689,30 @@ GetConfigOptionResetString(const char *name)
return NULL;
}
+/*
+ * Get the GUC flags associated with the given option.
+ *
+ * If the option doesn't exist, return 0 if missing_ok is true,
+ * otherwise throw an ereport and don't return.
+ */
+int
+GetConfigOptionFlags(const char *name, bool missing_ok)
+{
+ struct config_generic *record;
+
+ record = find_option(name, false, WARNING);
+ if (record == NULL)
+ {
+ if (missing_ok)
+ return 0;
+ ereport(ERROR,
+ (errcode(ERRCODE_UNDEFINED_OBJECT),
+ errmsg("unrecognized configuration parameter \"%s\"",
+ name)));
+ }
+ return record->flags;
+}
+
/*
* flatten_set_variable_args