postgres.git / summary / log / commit / refs
commit b0cadc08fea564f75a0702e15b2bd949377bd2f3
Author: Tom Lane <tgl@sss.pgh.pa.us>
Date: Mon Jan 04 06:53:24 2016 +0000
Fix regrole and regnamespace output functions to do quoting, too.
We discussed this but somehow failed to implement it...
src/backend/utils/adt/regproc.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c
index fc939e641ff..0f17eb8000f 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);
}
[parent: fb1227af67ea]