1 /*-------------------------------------------------------------------------
4 * Code for the 'function cache' used in Oper and Func nodes.
7 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
8 * Portions Copyright (c) 1994, Regents of the University of California
11 * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.42 2002/02/18 23:11:25 petere Exp $
13 *-------------------------------------------------------------------------
17 #include "miscadmin.h"
18 #include "utils/acl.h"
19 #include "utils/fcache.h"
23 * Build a 'FunctionCache' struct given the PG_PROC oid.
26 init_fcache(Oid foid, int nargs, MemoryContext fcacheCxt)
28 FunctionCachePtr retval;
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");
34 /* Create fcache entry in the desired context */
35 retval = (FunctionCachePtr) MemoryContextAlloc(fcacheCxt,
36 sizeof(FunctionCache));
37 MemSet(retval, 0, sizeof(FunctionCache));
39 /* Set up the primary fmgr lookup information */
40 fmgr_info_cxt(foid, &(retval->func), fcacheCxt);
42 /* Initialize additional info */
43 retval->setArgsValid = false;
45 retval->permission_ok = pg_proc_aclcheck(foid, GetUserId()) == ACLCHECK_OK;