]> granicus.if.org Git - postgresql/blob - src/backend/utils/cache/fcache.c
Privileges on functions and procedural languages
[postgresql] / src / backend / utils / cache / fcache.c
1 /*-------------------------------------------------------------------------
2  *
3  * fcache.c
4  *        Code for the 'function cache' used in Oper and Func nodes.
5  *
6  *
7  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8  * Portions Copyright (c) 1994, Regents of the University of California
9  *
10  * IDENTIFICATION
11  *        $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.42 2002/02/18 23:11:25 petere Exp $
12  *
13  *-------------------------------------------------------------------------
14  */
15 #include "postgres.h"
16
17 #include "miscadmin.h"
18 #include "utils/acl.h"
19 #include "utils/fcache.h"
20
21
22 /*
23  * Build a 'FunctionCache' struct given the PG_PROC oid.
24  */
25 FunctionCachePtr
26 init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt)
27 {
28         FunctionCachePtr retval;
29
30         /* Safety check (should never fail, as parser should check sooner) */
31         if (nargs > FUNC_MAX_ARGS)
32                 elog(ERROR, "init_fcache: too many arguments");
33
34         /* Create fcache entry in the desired context */
35         retval = (FunctionCachePtr) MemoryContextAlloc(fcacheCxt,
36                                                                                                    sizeof(FunctionCache));
37         MemSet(retval, 0, sizeof(FunctionCache));
38
39         /* Set up the primary fmgr lookup information */
40         fmgr_info_cxt(foid, &(retval->func), fcacheCxt);
41
42         /* Initialize additional info */
43         retval->setArgsValid = false;
44
45         retval->permission_ok = pg_proc_aclcheck(foid, GetUserId()) == ACLCHECK_OK;
46
47         return retval;
48 }