From 729205571e81b4767efc42ad7beb53663e08d1ff Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 20 Dec 2011 00:05:19 +0200 Subject: Add support for privileges on types This adds support for the more or less SQL-conforming USAGE privilege on types and domains. The intent is to be able restrict which users can create dependencies on types, which restricts the way in which owners can alter types. reviewed by Yeb Havinga --- src/backend/executor/execMain.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/backend/executor/execMain.c') diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 3dbd80d53bc..0cbe93c5c91 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -2490,6 +2490,21 @@ OpenIntoRel(QueryDesc *queryDesc) (errcode(ERRCODE_INVALID_TABLE_DEFINITION), errmsg("ON COMMIT can only be used on temporary tables"))); + { + AclResult aclresult; + int i; + + for (i = 0; i < intoTupDesc->natts; i++) + { + Oid atttypid = intoTupDesc->attrs[i]->atttypid; + + aclresult = pg_type_aclcheck(atttypid, GetUserId(), ACL_USAGE); + if (aclresult != ACLCHECK_OK) + aclcheck_error(aclresult, ACL_KIND_TYPE, + format_type_be(atttypid)); + } + } + /* * If a column name list was specified in CREATE TABLE AS, override the * column names derived from the query. (Too few column names are OK, too -- cgit v1.2.3