@@ -50,7 +50,6 @@ bool pg_qs_buffers = false;
50
50
static ExecutorStart_hook_type prev_ExecutorStart = NULL ;
51
51
static ExecutorRun_hook_type prev_ExecutorRun = NULL ;
52
52
static ExecutorFinish_hook_type prev_ExecutorFinish = NULL ;
53
- static ExecutorEnd_hook_type prev_ExecutorEnd = NULL ;
54
53
static shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
55
54
56
55
void _PG_init (void );
@@ -65,7 +64,6 @@ static void qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction,
65
64
uint64 count , bool execute_once );
66
65
#endif
67
66
static void qs_ExecutorFinish (QueryDesc * queryDesc );
68
- static void qs_ExecutorEnd (QueryDesc * queryDesc );
69
67
70
68
/* Global variables */
71
69
List * QueryDescStack = NIL ;
@@ -249,8 +247,6 @@ _PG_init(void)
249
247
ExecutorRun_hook = qs_ExecutorRun ;
250
248
prev_ExecutorFinish = ExecutorFinish_hook ;
251
249
ExecutorFinish_hook = qs_ExecutorFinish ;
252
- prev_ExecutorEnd = ExecutorEnd_hook ;
253
- ExecutorEnd_hook = qs_ExecutorEnd ;
254
250
prev_shmem_startup_hook = shmem_startup_hook ;
255
251
shmem_startup_hook = pg_qs_shmem_startup ;
256
252
}
@@ -271,7 +267,6 @@ _PG_fini(void)
271
267
ExecutorStart_hook = prev_ExecutorStart ;
272
268
ExecutorRun_hook = prev_ExecutorRun ;
273
269
ExecutorFinish_hook = prev_ExecutorFinish ;
274
- ExecutorEnd_hook = prev_ExecutorEnd ;
275
270
shmem_startup_hook = prev_shmem_startup_hook ;
276
271
}
277
272
@@ -283,32 +278,20 @@ _PG_fini(void)
283
278
static void
284
279
qs_ExecutorStart (QueryDesc * queryDesc , int eflags )
285
280
{
286
- PG_TRY ();
281
+ /* Enable per-node instrumentation */
282
+ if (pg_qs_enable && ((eflags & EXEC_FLAG_EXPLAIN_ONLY ) == 0 ))
287
283
{
288
- /* Enable per-node instrumentation */
289
- if (pg_qs_enable && ((eflags & EXEC_FLAG_EXPLAIN_ONLY ) == 0 ))
290
- {
291
- queryDesc -> instrument_options |= INSTRUMENT_ROWS ;
292
- if (pg_qs_timing )
293
- queryDesc -> instrument_options |= INSTRUMENT_TIMER ;
294
- if (pg_qs_buffers )
295
- queryDesc -> instrument_options |= INSTRUMENT_BUFFERS ;
296
- }
297
-
298
- if (prev_ExecutorStart )
299
- prev_ExecutorStart (queryDesc , eflags );
300
- else
301
- standard_ExecutorStart (queryDesc , eflags );
302
-
303
- /* push structure about current query in global stack */
304
- QueryDescStack = lcons (queryDesc , QueryDescStack );
284
+ queryDesc -> instrument_options |= INSTRUMENT_ROWS ;
285
+ if (pg_qs_timing )
286
+ queryDesc -> instrument_options |= INSTRUMENT_TIMER ;
287
+ if (pg_qs_buffers )
288
+ queryDesc -> instrument_options |= INSTRUMENT_BUFFERS ;
305
289
}
306
- PG_CATCH ();
307
- {
308
- QueryDescStack = NIL ;
309
- PG_RE_THROW ();
310
- }
311
- PG_END_TRY ();
290
+
291
+ if (prev_ExecutorStart )
292
+ prev_ExecutorStart (queryDesc , eflags );
293
+ else
294
+ standard_ExecutorStart (queryDesc , eflags );
312
295
}
313
296
314
297
/*
@@ -323,6 +306,8 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
323
306
bool execute_once )
324
307
#endif
325
308
{
309
+ QueryDescStack = lcons (queryDesc , QueryDescStack );
310
+
326
311
PG_TRY ();
327
312
{
328
313
if (prev_ExecutorRun )
@@ -335,10 +320,11 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
335
320
else
336
321
standard_ExecutorRun (queryDesc , direction , count , execute_once );
337
322
#endif
323
+ QueryDescStack = list_delete_first (QueryDescStack );
338
324
}
339
325
PG_CATCH ();
340
326
{
341
- QueryDescStack = NIL ;
327
+ QueryDescStack = list_delete_first ( QueryDescStack ) ;
342
328
PG_RE_THROW ();
343
329
}
344
330
PG_END_TRY ();
@@ -351,40 +337,19 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
351
337
static void
352
338
qs_ExecutorFinish (QueryDesc * queryDesc )
353
339
{
340
+ QueryDescStack = lcons (queryDesc , QueryDescStack );
341
+
354
342
PG_TRY ();
355
343
{
356
344
if (prev_ExecutorFinish )
357
345
prev_ExecutorFinish (queryDesc );
358
346
else
359
347
standard_ExecutorFinish (queryDesc );
360
- }
361
- PG_CATCH ();
362
- {
363
- QueryDescStack = NIL ;
364
- PG_RE_THROW ();
365
- }
366
- PG_END_TRY ();
367
- }
368
-
369
- /*
370
- * ExecutorEnd hook:
371
- * pop current query description from global stack
372
- */
373
- static void
374
- qs_ExecutorEnd (QueryDesc * queryDesc )
375
- {
376
- PG_TRY ();
377
- {
378
348
QueryDescStack = list_delete_first (QueryDescStack );
379
-
380
- if (prev_ExecutorEnd )
381
- prev_ExecutorEnd (queryDesc );
382
- else
383
- standard_ExecutorEnd (queryDesc );
384
349
}
385
350
PG_CATCH ();
386
351
{
387
- QueryDescStack = NIL ;
352
+ QueryDescStack = list_delete_first ( QueryDescStack ) ;
388
353
PG_RE_THROW ();
389
354
}
390
355
PG_END_TRY ();
0 commit comments