* procedural language
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.66 2003/08/08 19:19:32 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/pl/plpgsql/src/pl_comp.c,v 1.67 2003/08/18 19:16:02 tgl Exp $
*
* This software is copyrighted by Jan Wieck - Hamburg.
*
*/
static PLpgSQL_function *do_compile(FunctionCallInfo fcinfo,
HeapTuple procTup,
- PLpgSQL_func_hashkey * hashkey);
+ PLpgSQL_func_hashkey *hashkey);
static void plpgsql_compile_error_callback(void *arg);
static PLpgSQL_type *build_datatype(HeapTuple typeTup, int32 typmod);
-static void compute_function_hashkey(FmgrInfo *flinfo,
+static void compute_function_hashkey(FunctionCallInfo fcinfo,
Form_pg_proc procStruct,
- PLpgSQL_func_hashkey * hashkey);
-static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key);
-static void plpgsql_HashTableInsert(PLpgSQL_function * function,
- PLpgSQL_func_hashkey * func_key);
-static void plpgsql_HashTableDelete(PLpgSQL_function * function);
+ PLpgSQL_func_hashkey *hashkey);
+static PLpgSQL_function *plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key);
+static void plpgsql_HashTableInsert(PLpgSQL_function *function,
+ PLpgSQL_func_hashkey *func_key);
+static void plpgsql_HashTableDelete(PLpgSQL_function *function);
/*
* This routine is a crock, and so is everyplace that calls it. The problem
plpgsql_HashTableInit();
/* Compute hashkey using function signature and actual arg types */
- compute_function_hashkey(fcinfo->flinfo, procStruct, &hashkey);
+ compute_function_hashkey(fcinfo, procStruct, &hashkey);
hashkey_valid = true;
/* And do the lookup */
* the completed function.
*/
if (!hashkey_valid)
- compute_function_hashkey(fcinfo->flinfo, procStruct, &hashkey);
+ compute_function_hashkey(fcinfo, procStruct, &hashkey);
/*
* Do the hard part.
static PLpgSQL_function *
do_compile(FunctionCallInfo fcinfo,
HeapTuple procTup,
- PLpgSQL_func_hashkey * hashkey)
+ PLpgSQL_func_hashkey *hashkey)
{
Form_pg_proc procStruct = (Form_pg_proc) GETSTRUCT(procTup);
int functype = CALLED_AS_TRIGGER(fcinfo) ? T_TRIGGER : T_FUNCTION;
* The hashkey is returned into the caller-provided storage at *hashkey.
*/
static void
-compute_function_hashkey(FmgrInfo *flinfo,
+compute_function_hashkey(FunctionCallInfo fcinfo,
Form_pg_proc procStruct,
- PLpgSQL_func_hashkey * hashkey)
+ PLpgSQL_func_hashkey *hashkey)
{
int i;
/* Make sure any unused bytes of the struct are zero */
MemSet(hashkey, 0, sizeof(PLpgSQL_func_hashkey));
- hashkey->funcOid = flinfo->fn_oid;
+ /* get function OID */
+ hashkey->funcOid = fcinfo->flinfo->fn_oid;
+
+ /* if trigger, get relation OID */
+ if (CALLED_AS_TRIGGER(fcinfo))
+ {
+ TriggerData *trigdata = (TriggerData *) fcinfo->context;
+
+ hashkey->trigrelOid = RelationGetRelid(trigdata->tg_relation);
+ }
/* get the argument types */
for (i = 0; i < procStruct->pronargs; i++)
if (argtypeid == ANYARRAYOID || argtypeid == ANYELEMENTOID ||
argtypeid == ANYOID)
{
- argtypeid = get_fn_expr_argtype(flinfo, i);
+ argtypeid = get_fn_expr_argtype(fcinfo->flinfo, i);
if (!OidIsValid(argtypeid))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
}
static PLpgSQL_function *
-plpgsql_HashTableLookup(PLpgSQL_func_hashkey * func_key)
+plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
{
plpgsql_HashEnt *hentry;
}
static void
-plpgsql_HashTableInsert(PLpgSQL_function * function,
- PLpgSQL_func_hashkey * func_key)
+plpgsql_HashTableInsert(PLpgSQL_function *function,
+ PLpgSQL_func_hashkey *func_key)
{
plpgsql_HashEnt *hentry;
bool found;
}
static void
-plpgsql_HashTableDelete(PLpgSQL_function * function)
+plpgsql_HashTableDelete(PLpgSQL_function *function)
{
plpgsql_HashEnt *hentry;