46
46
* Portions Copyright (c) 1994, Regents of the University of California
47
47
*
48
48
* IDENTIFICATION
49
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.82 2002/04/16 23:08:10 tgl Exp $
49
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.83 2002/04/29 22:28:19 tgl Exp $
50
50
*
51
51
*-------------------------------------------------------------------------
52
52
*/
58
58
#include "catalog/pg_operator.h"
59
59
#include "executor/executor.h"
60
60
#include "executor/nodeAgg.h"
61
+ #include "miscadmin.h"
61
62
#include "optimizer/clauses.h"
62
63
#include "parser/parse_coerce.h"
63
64
#include "parser/parse_expr.h"
64
65
#include "parser/parse_oper.h"
65
66
#include "parser/parse_type.h"
67
+ #include "utils/acl.h"
66
68
#include "utils/builtins.h"
67
69
#include "utils/lsyscache.h"
68
70
#include "utils/syscache.h"
@@ -843,6 +845,7 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
843
845
AggStatePerAgg peraggstate = & peragg [++ aggno ];
844
846
HeapTuple aggTuple ;
845
847
Form_pg_aggregate aggform ;
848
+ AclResult aclresult ;
846
849
Oid transfn_oid ,
847
850
finalfn_oid ;
848
851
Datum textInitVal ;
@@ -861,6 +864,12 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent)
861
864
aggref -> aggfnoid );
862
865
aggform = (Form_pg_aggregate )GETSTRUCT (aggTuple );
863
866
867
+ /* Check permission to call aggregate function */
868
+ aclresult = pg_proc_aclcheck (aggref -> aggfnoid ,GetUserId (),
869
+ ACL_EXECUTE );
870
+ if (aclresult != ACLCHECK_OK )
871
+ aclcheck_error (aclresult ,get_func_name (aggref -> aggfnoid ));
872
+
864
873
get_typlenbyval (aggref -> aggtype ,
865
874
& peraggstate -> resulttypeLen ,
866
875
& peraggstate -> resulttypeByVal );