instrumentation: Drop INSTR_TIME_SET_CURRENT_LAZY macro

This macro had exactly one user in InstrStartNode, and the caller can
instead use INSTR_TIME_IS_ZERO / INSTR_TIME_SET_CURRENT directly.

This supports a future change that intends to modify the time source being
used in the InstrStartNode case.

Author: Lukas Fittl <lukas@fittl.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CAP53Pkx1bK1FB71_nBqYmzvSSXnp_MbE0ZDnU+baPJF6Ud2WDA@mail.gmail.com
master
Andres Freund 2 months ago
parent 3218825271
commit 9d6294c09e
  1. 10
      src/backend/executor/instrument.c
  2. 6
      src/include/portability/instr_time.h

@ -67,9 +67,13 @@ InstrInit(Instrumentation *instr, int instrument_options)
void
InstrStartNode(Instrumentation *instr)
{
if (instr->need_timer &&
!INSTR_TIME_SET_CURRENT_LAZY(instr->starttime))
elog(ERROR, "InstrStartNode called twice in a row");
if (instr->need_timer)
{
if (!INSTR_TIME_IS_ZERO(instr->starttime))
elog(ERROR, "InstrStartNode called twice in a row");
else
INSTR_TIME_SET_CURRENT(instr->starttime);
}
/* save buffer usage totals at node entry, if needed */
if (instr->need_bufusage)

@ -19,8 +19,6 @@
*
* INSTR_TIME_SET_CURRENT(t) set t to current time
*
* INSTR_TIME_SET_CURRENT_LAZY(t) set t to current time if t is zero,
* evaluates to whether t changed
*
* INSTR_TIME_ADD(x, y) x += y
*
@ -170,12 +168,8 @@ GetTimerFrequency(void)
#define INSTR_TIME_IS_ZERO(t) ((t).ticks == 0)
#define INSTR_TIME_SET_ZERO(t) ((t).ticks = 0)
#define INSTR_TIME_SET_CURRENT_LAZY(t) \
(INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
#define INSTR_TIME_ADD(x,y) \
((x).ticks += (y).ticks)

Loading…
Cancel
Save