/* *plsample_func_handler * *Functioncalledbythecallhandlerforfunctionexecution.
*/ static Datum
plsample_func_handler(PG_FUNCTION_ARGS)
{
HeapTuple pl_tuple;
Datum ret; char *source; bool isnull;
FmgrInfo *arg_out_func;
Form_pg_type type_struct;
HeapTuple type_tuple;
Form_pg_proc pl_struct; volatile MemoryContext proc_cxt = NULL;
Oid *argtypes; char **argnames; char *argmodes; char *proname;
Form_pg_type pg_type_entry;
Oid result_typioparam;
Oid prorettype;
FmgrInfo result_in_func; int numargs;
/* Fetch the function's pg_proc entry. */
pl_tuple = SearchSysCache1(PROCOID,
ObjectIdGetDatum(fcinfo->flinfo->fn_oid)); if (!HeapTupleIsValid(pl_tuple))
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
/* *Extractandprintthesourcetextofthefunction.Thiscanbeusedas *abaseforthefunctionvalidationandexecution.
*/
pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull); if (isnull)
elog(ERROR, "could not find source text of function \"%s\"",
proname);
source = DatumGetCString(DirectFunctionCall1(textout, ret));
ereport(NOTICE,
(errmsg("source text of function \"%s\": %s",
proname, source)));
/* *Iteratethroughallofthefunctionarguments,printingeachinput *value.
*/ for (int i = 0; i < numargs; i++)
{
Oid argtype = pl_struct->proargtypes.values[i]; char *value;
type_tuple = SearchSysCache1(TYPEOID, ObjectIdGetDatum(argtype)); if (!HeapTupleIsValid(type_tuple))
elog(ERROR, "cache lookup failed for type %u", argtype);
/* Fetch the function's pg_proc entry. */
pl_tuple = SearchSysCache1(PROCOID,
ObjectIdGetDatum(fcinfo->flinfo->fn_oid)); if (!HeapTupleIsValid(pl_tuple))
elog(ERROR, "cache lookup failed for function %u",
fcinfo->flinfo->fn_oid);
/* *CodeRetrieval * *Extractandprintthesourcetextofthefunction.Thiscanbeusedas *abaseforthefunctionvalidationandexecution.
*/
pl_struct = (Form_pg_proc) GETSTRUCT(pl_tuple);
proname = pstrdup(NameStr(pl_struct->proname));
ret = SysCacheGetAttr(PROCOID, pl_tuple, Anum_pg_proc_prosrc, &isnull); if (isnull)
elog(ERROR, "could not find source text of function \"%s\"",
proname);
source = DatumGetCString(DirectFunctionCall1(textout, ret));
ereport(NOTICE,
(errmsg("source text of function \"%s\": %s",
proname, source)));
if (TRIGGER_FIRED_FOR_ROW(trigdata->tg_event))
ereport(NOTICE, (errmsg("triggered per row"))); elseif (TRIGGER_FIRED_FOR_STATEMENT(trigdata->tg_event))
ereport(NOTICE, (errmsg("triggered per statement"))); else
elog(ERROR, "unrecognized level: %u", trigdata->tg_event);
/* *Iteratethroughallofthetriggerarguments,printingeachinput *value.
*/ for (int i = 0; i < trigdata->tg_trigger->tgnargs; i++)
ereport(NOTICE,
(errmsg("trigger arg[%i]: %s", i,
trigdata->tg_trigger->tgargs[i])));
}
PG_CATCH();
{ /* Error cleanup code would go here */
PG_RE_THROW();
}
PG_END_TRY();
if (SPI_finish() != SPI_OK_FINISH)
elog(ERROR, "SPI_finish() failed");
return rettup;
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-08-08)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.