Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f7d02a

Browse files
committed
instr_time.h: add INSTR_TIME_SET_CURRENT_LAZY
Sets the timestamp to current if not already set. Will acquire morecallers momentarily.Author: Fabien CoelhoDiscussion:https://postgr.es/m/alpine.DEB.2.21.1808111104320.1705@lancre
1 parent7306d5e commit6f7d02a

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

‎src/backend/executor/instrument.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,9 @@ InstrInit(Instrumentation *instr, int instrument_options)
6262
void
6363
InstrStartNode(Instrumentation*instr)
6464
{
65-
if (instr->need_timer)
66-
{
67-
if (INSTR_TIME_IS_ZERO(instr->starttime))
68-
INSTR_TIME_SET_CURRENT(instr->starttime);
69-
else
70-
elog(ERROR,"InstrStartNode called twice in a row");
71-
}
65+
if (instr->need_timer&&
66+
INSTR_TIME_SET_CURRENT_LAZY(instr->starttime))
67+
elog(ERROR,"InstrStartNode called twice in a row");
7268

7369
/* save buffer usage totals at node entry, if needed */
7470
if (instr->need_bufusage)

‎src/include/portability/instr_time.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
*
2121
* INSTR_TIME_SET_CURRENT(t)set t to current time
2222
*
23+
* INSTR_TIME_SET_CURRENT_LAZY(t)set t to current time if t is zero,
24+
*evaluates to whether t changed
25+
*
2326
* INSTR_TIME_ADD(x, y)x += y
2427
*
2528
* INSTR_TIME_SUBTRACT(x, y)x -= y
@@ -245,4 +248,9 @@ GetTimerFrequency(void)
245248

246249
#endif/* WIN32 */
247250

251+
/* same macro on all platforms */
252+
253+
#defineINSTR_TIME_SET_CURRENT_LAZY(t) \
254+
(INSTR_TIME_IS_ZERO(t) ? INSTR_TIME_SET_CURRENT(t), true : false)
255+
248256
#endif/* INSTR_TIME_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp