@@ -324,15 +324,16 @@ standard_ExplainOneQuery(Query *query, int cursorOptions,
324324 QueryEnvironment * queryEnv )
325325{
326326 PlannedStmt * plan ;
327- QueryInstrumentation * instr = NULL ;
327+ QueryInstrumentation * plan_instr = NULL ;
328+ InstrumentOption plan_instr_opts = INSTRUMENT_TIMER ;
328329 MemoryContextCounters mem_counters ;
329330 MemoryContext planner_ctx = NULL ;
330331 MemoryContext saved_ctx = NULL ;
331332
332333 if (es -> buffers )
333- instr = InstrQueryAlloc ( INSTRUMENT_TIMER | INSTRUMENT_BUFFERS ) ;
334- else
335- instr = InstrQueryAlloc (INSTRUMENT_TIMER );
334+ plan_instr_opts |= INSTRUMENT_BUFFERS ;
335+
336+ plan_instr = InstrQueryAlloc (plan_instr_opts );
336337
337338 if (es -> memory )
338339 {
@@ -350,12 +351,12 @@ standard_ExplainOneQuery(Query *query, int cursorOptions,
350351 saved_ctx = MemoryContextSwitchTo (planner_ctx );
351352 }
352353
353- InstrQueryStart (instr );
354+ InstrQueryStart (plan_instr );
354355
355356 /* plan the query */
356357 plan = pg_plan_query (query , queryString , cursorOptions , params , es );
357358
358- InstrQueryStopFinalize (instr );
359+ InstrQueryStopFinalize (plan_instr );
359360
360361 if (es -> memory )
361362 {
@@ -365,7 +366,7 @@ standard_ExplainOneQuery(Query *query, int cursorOptions,
365366
366367 /* run it (if needed) and produce output */
367368 ExplainOnePlan (plan , into , es , queryString , params , queryEnv ,
368- & instr -> instr .total , (es -> buffers ? & instr -> instr .bufusage : NULL ),
369+ & plan_instr -> instr .total , (es -> buffers ? & plan_instr -> instr .bufusage : NULL ),
369370 es -> memory ? & mem_counters : NULL );
370371}
371372
0 commit comments