From: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
To: Lukas Fittl <lukas@fittl.com>
Cc: Pg Hackers <pgsql-hackers@postgresql.org>
Subject: Re: Procedure calls are not tracked in pg_stat_user_functions / track_functions
Date: Fri, 5 Oct 2018 14:15:30 +0200
Message-ID: <6d01afee-2a3b-2871-ef41-d3fcd984b192@2ndquadrant.com> (raw)
In-Reply-To: <20181004200715.7cgrxyaxnep3mveu@alap3.anarazel.de>
References: <CAP53Pkx1JxGeXHAd3bV=EU7D2s7kAto3v4gqrDrR4as60k77Tw@mail.gmail.com>
<20181004200715.7cgrxyaxnep3mveu@alap3.anarazel.de>
On 04/10/2018 22:07, Andres Freund wrote:
> On 2018-10-04 12:15:28 -0700, Lukas Fittl wrote:
>> Was this intentional, or an oversight?
>>
>> If welcome, I would be happy to work on a patch. Whilst slightly confusing
>> in terms of naming, we could just track this together with functions, since
>> one can always join with pg_proc to determine whether something is a
>> function or a procedure.
>
> Yea, that sounds wrong / not ideal to me. I think we should just fix
> this, should be easy enough.
Here is a patch.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
Attachments:0001-Track-procedure-calls-in-pg_stat_user_functions.patch (text/plain, 1.3K) download
From 4f9e88e68ef5b29d91830b33306752dba1d25e0a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Fri, 5 Oct 2018 14:14:03 +0200
Subject: [PATCH] Track procedure calls in pg_stat_user_functions
---
src/backend/commands/functioncmds.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.cindex 68109bfda0..80ad3c770a 100644--- a/src/backend/commands/functioncmds.c+++ b/src/backend/commands/functioncmds.c@@ -60,6 +60,7 @@
#include "parser/parse_expr.h"
#include "parser/parse_func.h"
#include "parser/parse_type.h"
+#include "pgstat.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/fmgroids.h"
@@ -2219,6 +2220,7 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
EState *estate;
ExprContext *econtext;
HeapTuple tp;
+ PgStat_FunctionCallUsage fcusage;
Datum retval;
fexpr = stmt->funcexpr;
@@ -2302,7 +2304,9 @@ ExecuteCallStmt(CallStmt *stmt, ParamListInfo params, bool atomic, DestReceiver
i++;
}
+ pgstat_init_function_usage(&fcinfo, &fcusage);
retval = FunctionCallInvoke(&fcinfo);
+ pgstat_end_function_usage(&fcusage, true);
if (fexpr->funcresulttype == VOIDOID)
{
base-commit: ff347f8aff04865680c19ffc818460bb2afaad5b
--
2.19.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: peter.eisentraut@2ndquadrant.com, andres@anarazel.de, lukas@fittl.com
Subject: Re: Procedure calls are not tracked in pg_stat_user_functions / track_functions
In-Reply-To: <6d01afee-2a3b-2871-ef41-d3fcd984b192@2ndquadrant.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox