mirror of
https://github.com/postgres/postgres.git
synced 2025-09-03 15:22:11 +03:00
Show default privileges in information schema
Hitherto, the information schema only showed explicitly granted privileges that were visible in the *acl catalog columns. If no privileges had been granted, the implicit privileges were not shown. To fix that, add an SQL-accessible version of the acldefault() function, and use that inside the aclexplode() calls to substitute the catalog-specific default privilege set for null values. reviewed by Abhijit Menon-Sen
This commit is contained in:
@@ -834,6 +834,64 @@ acldefault(GrantObjectType objtype, Oid ownerId)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* SQL-accessible version of acldefault(). Hackish mapping from "char" type to
|
||||
* ACL_OBJECT_* values, but it's only used in the information schema, not
|
||||
* documented for general use.
|
||||
*/
|
||||
Datum
|
||||
acldefault_sql(PG_FUNCTION_ARGS)
|
||||
{
|
||||
char objtypec = PG_GETARG_CHAR(0);
|
||||
Oid owner = PG_GETARG_OID(1);
|
||||
GrantObjectType objtype = 0;
|
||||
|
||||
switch (objtypec)
|
||||
{
|
||||
case 'c':
|
||||
objtype = ACL_OBJECT_COLUMN;
|
||||
break;
|
||||
case 'r':
|
||||
objtype = ACL_OBJECT_RELATION;
|
||||
break;
|
||||
case 's':
|
||||
objtype = ACL_OBJECT_SEQUENCE;
|
||||
break;
|
||||
case 'd':
|
||||
objtype = ACL_OBJECT_DATABASE;
|
||||
break;
|
||||
case 'f':
|
||||
objtype = ACL_OBJECT_FUNCTION;
|
||||
break;
|
||||
case 'l':
|
||||
objtype = ACL_OBJECT_LANGUAGE;
|
||||
break;
|
||||
case 'L':
|
||||
objtype = ACL_OBJECT_LARGEOBJECT;
|
||||
break;
|
||||
case 'n':
|
||||
objtype = ACL_OBJECT_NAMESPACE;
|
||||
break;
|
||||
case 't':
|
||||
objtype = ACL_OBJECT_TABLESPACE;
|
||||
break;
|
||||
case 'F':
|
||||
objtype = ACL_OBJECT_FDW;
|
||||
break;
|
||||
case 'S':
|
||||
objtype = ACL_OBJECT_FOREIGN_SERVER;
|
||||
break;
|
||||
case 'T':
|
||||
objtype = ACL_OBJECT_TYPE;
|
||||
break;
|
||||
default:
|
||||
elog(ERROR, "unrecognized objtype abbreviation: %c", objtypec);
|
||||
}
|
||||
|
||||
PG_RETURN_ACL_P(acldefault(objtype, owner));
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Update an ACL array to add or remove specified privileges.
|
||||
*
|
||||
|
Reference in New Issue
Block a user