Skip to content
Snippets Groups Projects
Commit b0cadc08 authored by Tom Lane's avatar Tom Lane
Browse files

Fix regrole and regnamespace output functions to do quoting, too.

We discussed this but somehow failed to implement it...
parent fb1227af
No related branches found
No related tags found
No related merge requests found
...@@ -1642,12 +1642,18 @@ regroleout(PG_FUNCTION_ARGS) ...@@ -1642,12 +1642,18 @@ regroleout(PG_FUNCTION_ARGS)
result = GetUserNameFromId(roleoid, true); 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 */ /* If OID doesn't match any role, return it numerically */
result = (char *) palloc(NAMEDATALEN); result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", roleoid); snprintf(result, NAMEDATALEN, "%u", roleoid);
} }
PG_RETURN_CSTRING(result); PG_RETURN_CSTRING(result);
} }
...@@ -1757,12 +1763,18 @@ regnamespaceout(PG_FUNCTION_ARGS) ...@@ -1757,12 +1763,18 @@ regnamespaceout(PG_FUNCTION_ARGS)
result = get_namespace_name(nspid); 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 */ /* If OID doesn't match any namespace, return it numerically */
result = (char *) palloc(NAMEDATALEN); result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", nspid); snprintf(result, NAMEDATALEN, "%u", nspid);
} }
PG_RETURN_CSTRING(result); PG_RETURN_CSTRING(result);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment