]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
instrumentation: Drop INSTR_TIME_SET_CURRENT_LAZY macro
authorAndres Freund <andres@anarazel.de>
Thu, 26 Feb 2026 15:38:20 +0000 (10:38 -0500)
committerAndres Freund <andres@anarazel.de>
Thu, 26 Feb 2026 15:39:29 +0000 (10:39 -0500)
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

src/backend/executor/instrument.c
src/include/portability/instr_time.h

index 4c3930a4f868009924a9a3aded326a956070256d..a40610bc2522f8d2e671174666f603f8ab70c411 100644 (file)
@@ -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)
index 87b9ec95531b973526360f785a3ce6bb84502a7e..8b6baeffd3e467919e4a43ef01047be092252bf3 100644 (file)
@@ -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)