Fix regrole and regnamespace output functions to do quoting, too.
authorTom Lane
Mon, 4 Jan 2016 06:53:24 +0000 (01:53 -0500)
committerTom Lane
Mon, 4 Jan 2016 06:53:36 +0000 (01:53 -0500)
We discussed this but somehow failed to implement it...

src/backend/utils/adt/regproc.c

index 4660dafd28dca692862b0cc7a3801be60094de9a..ac1141a04eaef659749c1956bca159d859b37d21 100644 (file)
@@ -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);
 }