summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane2016-01-04 06:53:24 +0000
committerTom Lane2016-01-04 06:53:36 +0000
commitde93252386e25b78400228b08326a50c43dd232b (patch)
tree823f5a3b32577a6caa3d7f2234da96340565d02d
parentfa038f830b64779475b746a6840db9bdd0298d80 (diff)
Fix regrole and regnamespace output functions to do quoting, too.
We discussed this but somehow failed to implement it...
-rw-r--r--src/backend/utils/adt/regproc.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index 4660dafd28d..ac1141a04ea 100644
--- a/src/backend/utils/adt/regproc.c
+++ b/src/backend/utils/adt/regproc.c
@@ -1642,12 +1642,18 @@ regroleout(PG_FUNCTION_ARGS)
result = GetUserNameFromId(roleoid, true);
- if (!result)
+ if (result)
+ {
+ /* pstrdup is not really necessary, but it avoids a compiler warning */
+ result = pstrdup(quote_identifier(result));
+ }
+ else
{
/* If OID doesn't match any role, return it numerically */
result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", roleoid);
}
+
PG_RETURN_CSTRING(result);
}
@@ -1757,12 +1763,18 @@ regnamespaceout(PG_FUNCTION_ARGS)
result = get_namespace_name(nspid);
- if (!result)
+ if (result)
+ {
+ /* pstrdup is not really necessary, but it avoids a compiler warning */
+ result = pstrdup(quote_identifier(result));
+ }
+ else
{
/* If OID doesn't match any namespace, return it numerically */
result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", nspid);
}
+
PG_RETURN_CSTRING(result);
}