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 @@ ...@@ -2674,7 +2674,8 @@
Type of object this entry is for: Type of object this entry is for:
<literal>r</> = relation (table, view), <literal>r</> = relation (table, view),
<literal>S</> = sequence, <literal>S</> = sequence,
<literal>f</> = function <literal>f</> = function,
<literal>T</> = type
</entry> </entry>
</row> </row>
......
...@@ -1346,10 +1346,13 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid) ...@@ -1346,10 +1346,13 @@ RemoveRoleFromObjectACL(Oid roleid, Oid classid, Oid objid)
case DEFACLOBJ_FUNCTION: case DEFACLOBJ_FUNCTION:
iacls.objtype = ACL_OBJECT_FUNCTION; iacls.objtype = ACL_OBJECT_FUNCTION;
break; break;
case DEFACLOBJ_TYPE:
iacls.objtype = ACL_OBJECT_TYPE;
break;
default: default:
/* Shouldn't get here */ /* Shouldn't get here */
elog(ERROR, "unexpected default ACL type %d", elog(ERROR, "unexpected default ACL type: %d",
pg_default_acl_tuple->defaclobjtype); (int) pg_default_acl_tuple->defaclobjtype);
break; break;
} }
......
...@@ -2899,6 +2899,11 @@ getObjectDescription(const ObjectAddress *object) ...@@ -2899,6 +2899,11 @@ getObjectDescription(const ObjectAddress *object)
_("default privileges on new functions belonging to role %s"), _("default privileges on new functions belonging to role %s"),
GetUserNameFromId(defacl->defaclrole)); GetUserNameFromId(defacl->defaclrole));
break; break;
case DEFACLOBJ_TYPE:
appendStringInfo(&buffer,
_("default privileges on new types belonging to role %s"),
GetUserNameFromId(defacl->defaclrole));
break;
default: default:
/* shouldn't get here */ /* shouldn't get here */
appendStringInfo(&buffer, appendStringInfo(&buffer,
......
...@@ -890,6 +890,9 @@ do { \ ...@@ -890,6 +890,9 @@ do { \
} }
else if (strcmp(type, "TABLESPACE") == 0) else if (strcmp(type, "TABLESPACE") == 0)
CONVERT_PRIV('C', "CREATE"); 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) else if (strcmp(type, "FOREIGN DATA WRAPPER") == 0)
CONVERT_PRIV('U', "USAGE"); CONVERT_PRIV('U', "USAGE");
else if (strcmp(type, "FOREIGN SERVER") == 0) else if (strcmp(type, "FOREIGN SERVER") == 0)
......
This diff is collapsed.
...@@ -164,6 +164,7 @@ typedef struct _typeInfo ...@@ -164,6 +164,7 @@ typedef struct _typeInfo
* produce something different than typname * produce something different than typname
*/ */
char *rolname; /* name of owner, or empty string */ char *rolname; /* name of owner, or empty string */
char *typacl;
Oid typelem; Oid typelem;
Oid typrelid; Oid typrelid;
char typrelkind; /* 'r', 'v', 'c', etc */ char typrelkind; /* 'r', 'v', 'c', etc */
......
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
#include <ctype.h> #include <ctype.h>
#include "catalog/pg_default_acl.h"
#include "common.h" #include "common.h"
#include "describe.h" #include "describe.h"
#include "dumputils.h" #include "dumputils.h"
...@@ -774,7 +776,7 @@ permissionsList(const char *pattern) ...@@ -774,7 +776,7 @@ permissionsList(const char *pattern)
/* /*
* \ddp * \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 bool
listDefaultACLs(const char *pattern) listDefaultACLs(const char *pattern)
...@@ -796,13 +798,18 @@ listDefaultACLs(const char *pattern) ...@@ -796,13 +798,18 @@ listDefaultACLs(const char *pattern)
printfPQExpBuffer(&buf, printfPQExpBuffer(&buf,
"SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS \"%s\",\n" "SELECT pg_catalog.pg_get_userbyid(d.defaclrole) AS \"%s\",\n"
" n.nspname 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("Owner"),
gettext_noop("Schema"), gettext_noop("Schema"),
DEFACLOBJ_RELATION,
gettext_noop("table"), gettext_noop("table"),
DEFACLOBJ_SEQUENCE,
gettext_noop("sequence"), gettext_noop("sequence"),
DEFACLOBJ_FUNCTION,
gettext_noop("function"), gettext_noop("function"),
DEFACLOBJ_TYPE,
gettext_noop("type"),
gettext_noop("Type")); gettext_noop("Type"));
printACLColumn(&buf, "d.defaclacl"); 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