Sophie

Sophie

distrib > Mandriva > 10.1 > i586 > by-pkgid > d3ccea9879dfa9a4a8c2e285986eb445 > files > 22

postgresql-7.4.5-4.3.101mdk.src.rpm

diff -ruN postgresql-7.4.5-old/src/backend/catalog/pg_aggregate.c postgresql-7.4.5/src/backend/catalog/pg_aggregate.c
--- postgresql-7.4.5-old/src/backend/catalog/pg_aggregate.c	2003-09-25 08:57:58.000000000 +0200
+++ postgresql-7.4.5/src/backend/catalog/pg_aggregate.c	2005-02-10 15:09:40.577696632 +0100
@@ -22,10 +22,13 @@
 #include "catalog/pg_aggregate.h"
 #include "catalog/pg_language.h"
 #include "catalog/pg_proc.h"
+#include "miscadmin.h"
 #include "optimizer/cost.h"
 #include "parser/parse_coerce.h"
 #include "parser/parse_func.h"
+#include "utils/acl.h"
 #include "utils/builtins.h"
+#include "utils/lsyscache.h"
 #include "utils/syscache.h"
 
 
@@ -261,6 +264,7 @@
 	bool		retset;
 	Oid		   *true_oid_array;
 	FuncDetailCode fdresult;
+	AclResult	aclresult;
 
 	/*
 	 * func_get_detail looks up the function in the catalogs, does
@@ -325,5 +329,10 @@
 				 errmsg("function %s requires run-time type coercion",
 				 func_signature_string(fnName, nargs, true_oid_array))));
 
+	/* Check aggregate creator has permission to call the function */
+	aclresult = pg_proc_aclcheck(fnOid, GetUserId(), ACL_EXECUTE);
+	if (aclresult != ACLCHECK_OK)
+		aclcheck_error(aclresult, ACL_KIND_PROC, get_func_name(fnOid));
+
 	return fnOid;
 }