mirror of
https://github.com/postgres/postgres.git
synced 2025-06-30 21:42:05 +03:00
Tweak the behavior of log_duration as proposed by Guillaume Smet: rather
than being equivalent to setting log_min_duration_statement to zero, this option now forces logging of all query durations, but doesn't force logging of query text. Also, add duration logging coverage for fastpath function calls.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.91 2006/07/14 14:52:23 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/tcop/fastpath.c,v 1.92 2006/09/08 15:55:53 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This cruft is the server side of PQfn.
|
||||
@ -274,6 +274,8 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
struct fp_info my_fp;
|
||||
struct fp_info *fip;
|
||||
bool callit;
|
||||
bool was_logged = false;
|
||||
char msec_str[32];
|
||||
|
||||
/*
|
||||
* Read message contents if not already done.
|
||||
@ -314,10 +316,14 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
|
||||
fid = (Oid) pq_getmsgint(msgBuf, 4); /* function oid */
|
||||
|
||||
/* Log as soon as we have the function OID */
|
||||
if (log_statement == LOGSTMT_ALL)
|
||||
{
|
||||
ereport(LOG,
|
||||
(errmsg("fastpath function call: function OID %u",
|
||||
fid)));
|
||||
was_logged = true;
|
||||
}
|
||||
|
||||
/*
|
||||
* There used to be a lame attempt at caching lookup info here. Now we
|
||||
@ -387,6 +393,22 @@ HandleFunctionRequest(StringInfo msgBuf)
|
||||
|
||||
SendFunctionResult(retval, fcinfo.isnull, fip->rettype, rformat);
|
||||
|
||||
/*
|
||||
* Emit duration logging if appropriate.
|
||||
*/
|
||||
switch (check_log_duration(msec_str, was_logged))
|
||||
{
|
||||
case 1:
|
||||
ereport(LOG,
|
||||
(errmsg("duration: %s ms", msec_str)));
|
||||
break;
|
||||
case 2:
|
||||
ereport(LOG,
|
||||
(errmsg("duration: %s ms fastpath function call: function OID %u",
|
||||
msec_str, fid)));
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user