@@ -167,23 +167,19 @@ CitusExecutorRun(QueryDesc *queryDesc,
167
167
*/
168
168
executorBoundParams = queryDesc -> params ;
169
169
170
- /*
171
- * We do some potentially time consuming operations ourself now before we hand off
172
- * control to postgres' executor. To make sure that time spent is accurately measured
173
- * we remove the totaltime instrumentation from the queryDesc. Instead we will start
174
- * and stop the instrumentation of the total time and put it back on the queryDesc
175
- * before returning (or rethrowing) from this function.
176
- */
177
- Instrumentation * volatile totalTime = queryDesc -> totaltime ;
178
- queryDesc -> totaltime = NULL ;
179
-
180
170
PG_TRY ();
181
171
{
182
172
ExecutorLevel ++ ;
183
173
184
- if (totalTime )
174
+ /*
175
+ * We do some potentially time consuming operations our self now before we hand of
176
+ * control to postgres' executor. To make sure that time spent is accurately measured
177
+ * we start and stop totaltime instrumentation from the queryDesc to mesure this
178
+ * time consuming operations before postgres' executor.
179
+ */
180
+ if (queryDesc -> totaltime )
185
181
{
186
- InstrStartNode (totalTime );
182
+ InstrStartNode (queryDesc -> totaltime );
187
183
}
188
184
189
185
/*
@@ -202,13 +198,16 @@ CitusExecutorRun(QueryDesc *queryDesc,
202
198
*/
203
199
if (AlterTableConstraintCheck (queryDesc ))
204
200
{
205
- EState * estate = queryDesc -> estate ;
206
-
207
- estate -> es_processed = 0 ;
208
-
209
201
/* start and shutdown tuple receiver to simulate empty result */
210
202
dest -> rStartup (queryDesc -> dest , CMD_SELECT , queryDesc -> tupDesc );
211
203
dest -> rShutdown (dest );
204
+
205
+ queryDesc -> estate -> es_processed = 0 ;
206
+
207
+ if (queryDesc -> totaltime )
208
+ {
209
+ InstrStopNode (queryDesc -> totaltime , 0 );
210
+ }
212
211
}
213
212
else
214
213
{
@@ -235,26 +234,25 @@ CitusExecutorRun(QueryDesc *queryDesc,
235
234
/* postgres will switch here again and will restore back on its own */
236
235
MemoryContextSwitchTo (oldcontext );
237
236
238
- #if PG_VERSION_NUM >= PG_VERSION_18
237
+ if (queryDesc -> totaltime )
238
+ {
239
+ InstrStopNode (queryDesc -> totaltime , 0 );
240
+ }
241
+
242
+ #if PG_VERSION_NUM >= PG_VERSION_18
239
243
240
244
/* PG18+ drops the “execute_once” argument */
241
245
standard_ExecutorRun (queryDesc ,
242
246
direction ,
243
247
count );
244
- #else
248
+ #else
245
249
246
250
/* PG17-: original four-arg signature */
247
251
standard_ExecutorRun (queryDesc ,
248
252
direction ,
249
253
count ,
250
254
execute_once );
251
- #endif
252
- }
253
-
254
- if (totalTime )
255
- {
256
- InstrStopNode (totalTime , queryDesc -> estate -> es_processed );
257
- queryDesc -> totaltime = totalTime ;
255
+ #endif
258
256
}
259
257
260
258
executorBoundParams = savedBoundParams ;
@@ -282,11 +280,6 @@ CitusExecutorRun(QueryDesc *queryDesc,
282
280
}
283
281
PG_CATCH ();
284
282
{
285
- if (totalTime )
286
- {
287
- queryDesc -> totaltime = totalTime ;
288
- }
289
-
290
283
executorBoundParams = savedBoundParams ;
291
284
ExecutorLevel -- ;
292
285
0 commit comments