Commit b46c9211 authored by Tom Lane's avatar Tom Lane

Fix assorted bugs in privileges-for-types patch.

Commit 72920557 added privileges on data
types, but there were a number of oversights.  The implementation of
default privileges for types missed a few places, and pg_dump was
utterly innocent of the whole concept.  Per bug #7741 from Nathan Alden,
and subsequent wider investigation.
parent a99c42f2
......@@ -2674,7 +2674,8 @@
Type of object this entry is for:
<literal>r</> = relation (table, view),
<literal>S</> = sequence,
<literal>f</> = function
<literal>f</> = function,
<literal>T</> = type
</entry>
</row>
......
......@@ -1346,10 +1346,13 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
case DEFACLOBJ_FUNCTION:
iacls.objtype = ACL_OBJECT_FUNCTION;
break;
case DEFACLOBJ_TYPE:
iacls.objtype = ACL_OBJECT_TYPE;
break;
default:
/* Shouldn't get here */
elog(ERROR, "unexpected default ACL type %d",
pg_default_acl_tuple->defaclobjtype);
elog(ERROR, "unexpected default ACL type: %d",
(int) pg_default_acl_tuple->defaclobjtype);
break;
}
......
......@@ -2899,6 +2899,11 @@ getObjectDescription(const ObjectAddress *object)
_("default privileges on new functions belonging to role %s"),
GetUserNameFromId(defacl->defaclrole));
break;
case DEFACLOBJ_TYPE:
appendStringInfo(&buffer,
_("default privileges on new types belonging to role %s"),
GetUserNameFromId(defacl->defaclrole));
break;
default:
/* shouldn't get here */
appendStringInfo(&buffer,
......
......@@ -890,6 +890,9 @@ do { \
}
else if (strcmp(type, "TABLESPACE") == 0)
CONVERT_PRIV('C', "CREATE");
else if (strcmp(type, "TYPE") == 0 ||
strcmp(type, "TYPES") == 0)
CONVERT_PRIV('U', "USAGE");
else if (strcmp(type, "FOREIGN DATA WRAPPER") == 0)
CONVERT_PRIV('U', "USAGE");
else if (strcmp(type, "FOREIGN SERVER") == 0)
......
This diff is collapsed.
......@@ -164,6 +164,7 @@ typedef struct _typeInfo
* produce something different than typname
*/
char *rolname; /* name of owner, or empty string */
char *typacl;
Oid typelem;
Oid typrelid;
char typrelkind; /* 'r', 'v', 'c', etc */
......
......@@ -14,6 +14,8 @@
#include <ctype.h>
#include "catalog/pg_default_acl.h"
#include "common.h"
#include "describe.h"
#include "dumputils.h"
......@@ -774,7 +776,7 @@ permissionsList(const char *pattern)
/*
* \ddp
*
* List DefaultACLs. The pattern can match either schema or role name.
* List Default ACLs. The pattern can match either schema or role name.
*/
bool
listDefaultACLs(const char *pattern)
......@@ -796,13 +798,18 @@ listDefaultACLs(const char *pattern)
printfPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS \"%s\",\n"
" n.nspname AS \"%s\",\n"
" CASE d.defaclobjtype WHEN 'r' THEN '%s' WHEN 'S' THEN '%s' WHEN 'f' THEN '%s' END AS \"%s\",\n"
" CASE d.defaclobjtype WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' WHEN '%c' THEN '%s' END AS \"%s\",\n"
" ",
gettext_noop("Owner"),
gettext_noop("Schema"),
DEFACLOBJ_RELATION,
gettext_noop("table"),
DEFACLOBJ_SEQUENCE,
gettext_noop("sequence"),
DEFACLOBJ_FUNCTION,
gettext_noop("function"),
DEFACLOBJ_TYPE,
gettext_noop("type"),
gettext_noop("Type"));
printACLColumn(&buf, "d.defaclacl");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment