From 15b1918e7d3532f0e4ec3455ae6ce45fae09c86f Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Fri, 15 Jun 2012 22:55:03 +0300 Subject: Improve reporting of permission errors for array types Because permissions are assigned to element types, not array types, complaining about permission denied on an array type would be misleading to users. So adjust the reporting to refer to the element type instead. In order not to duplicate the required logic in two dozen places, refactor the permission denied reporting for types a bit. pointed out by Yeb Havinga during the review of the type privilege feature --- src/backend/commands/functioncmds.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/backend/commands/functioncmds.c') diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 13e30f4a556..9ba6dd8fcf1 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -154,8 +154,7 @@ compute_return_type(TypeName *returnType, Oid languageOid, aclresult = pg_type_aclcheck(rettype, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) - aclcheck_error(aclresult, ACL_KIND_TYPE, - format_type_be(rettype)); + aclcheck_error_type(aclresult, rettype); *prorettype_p = rettype; *returnsSet_p = returnType->setof; @@ -247,8 +246,7 @@ examine_parameter_list(List *parameters, Oid languageOid, aclresult = pg_type_aclcheck(toid, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) - aclcheck_error(aclresult, ACL_KIND_TYPE, - format_type_be(toid)); + aclcheck_error_type(aclresult, toid); if (t->setof) ereport(ERROR, @@ -1510,13 +1508,11 @@ CreateCast(CreateCastStmt *stmt) aclresult = pg_type_aclcheck(sourcetypeid, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) - aclcheck_error(aclresult, ACL_KIND_TYPE, - format_type_be(sourcetypeid)); + aclcheck_error_type(aclresult, sourcetypeid); aclresult = pg_type_aclcheck(targettypeid, GetUserId(), ACL_USAGE); if (aclresult != ACLCHECK_OK) - aclcheck_error(aclresult, ACL_KIND_TYPE, - format_type_be(targettypeid)); + aclcheck_error_type(aclresult, targettypeid); /* Domains are allowed for historical reasons, but we warn */ if (sourcetyptype == TYPTYPE_DOMAIN) -- cgit v1.2.3