diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-15 00:17:41 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-05-15 00:17:41 +0000 |
commit | 93c701edc6c6f065cd25f77f63ab31aff085d6ac (patch) | |
tree | 7eaa06d9c2b64ec7f5647bcf3851281180c783e1 /src/backend/commands/trigger.c | |
parent | 3bc25384d7a698f25e418bdc5aa7cdd038477d9c (diff) | |
download | postgresql-93c701edc6c6f065cd25f77f63ab31aff085d6ac.tar.gz postgresql-93c701edc6c6f065cd25f77f63ab31aff085d6ac.zip |
Add support for tracking call counts and elapsed runtime for user-defined
functions.
Note that because this patch changes FmgrInfo, any external C functions
you might be testing with 8.4 will need to be recompiled.
Patch by Martin Pihlak, some editorialization by me (principally, removing
tracking of getrusage() numbers)
Diffstat (limited to 'src/backend/commands/trigger.c')
-rw-r--r-- | src/backend/commands/trigger.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 7685906aeb0..76a373343de 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.233 2008/05/12 20:01:59 alvherre Exp $ + * $PostgreSQL: pgsql/src/backend/commands/trigger.c,v 1.234 2008/05/15 00:17:39 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -32,6 +32,7 @@ #include "miscadmin.h" #include "nodes/makefuncs.h" #include "parser/parse_func.h" +#include "pgstat.h" #include "storage/bufmgr.h" #include "tcop/utility.h" #include "utils/acl.h" @@ -1566,6 +1567,7 @@ ExecCallTriggerFunc(TriggerData *trigdata, MemoryContext per_tuple_context) { FunctionCallInfoData fcinfo; + PgStat_FunctionCallUsage fcusage; Datum result; MemoryContext oldContext; @@ -1599,8 +1601,12 @@ ExecCallTriggerFunc(TriggerData *trigdata, */ InitFunctionCallInfoData(fcinfo, finfo, 0, (Node *) trigdata, NULL); + pgstat_init_function_usage(&fcinfo, &fcusage); + result = FunctionCallInvoke(&fcinfo); + pgstat_end_function_usage(&fcusage, true); + MemoryContextSwitchTo(oldContext); /* |