@@ -50,7 +50,6 @@ bool pg_qs_buffers = false;
5050static ExecutorStart_hook_type prev_ExecutorStart = NULL ;
5151static ExecutorRun_hook_type prev_ExecutorRun = NULL ;
5252static ExecutorFinish_hook_type prev_ExecutorFinish = NULL ;
53- static ExecutorEnd_hook_type prev_ExecutorEnd = NULL ;
5453static shmem_startup_hook_type prev_shmem_startup_hook = NULL ;
5554
5655void _PG_init (void );
@@ -65,7 +64,6 @@ static void qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction,
6564uint64 count ,bool execute_once );
6665#endif
6766static void qs_ExecutorFinish (QueryDesc * queryDesc );
68- static void qs_ExecutorEnd (QueryDesc * queryDesc );
6967
7068/* Global variables */
7169List * QueryDescStack = NIL ;
@@ -249,8 +247,6 @@ _PG_init(void)
249247ExecutorRun_hook = qs_ExecutorRun ;
250248prev_ExecutorFinish = ExecutorFinish_hook ;
251249ExecutorFinish_hook = qs_ExecutorFinish ;
252- prev_ExecutorEnd = ExecutorEnd_hook ;
253- ExecutorEnd_hook = qs_ExecutorEnd ;
254250prev_shmem_startup_hook = shmem_startup_hook ;
255251shmem_startup_hook = pg_qs_shmem_startup ;
256252}
@@ -271,7 +267,6 @@ _PG_fini(void)
271267ExecutorStart_hook = prev_ExecutorStart ;
272268ExecutorRun_hook = prev_ExecutorRun ;
273269ExecutorFinish_hook = prev_ExecutorFinish ;
274- ExecutorEnd_hook = prev_ExecutorEnd ;
275270shmem_startup_hook = prev_shmem_startup_hook ;
276271}
277272
@@ -283,32 +278,20 @@ _PG_fini(void)
283278static void
284279qs_ExecutorStart (QueryDesc * queryDesc ,int eflags )
285280{
286- PG_TRY ();
281+ /* Enable per-node instrumentation */
282+ if (pg_qs_enable && ((eflags & EXEC_FLAG_EXPLAIN_ONLY )== 0 ))
287283{
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 ;
305289}
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 );
312295}
313296
314297/*
@@ -323,6 +306,8 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
323306bool execute_once )
324307#endif
325308{
309+ QueryDescStack = lcons (queryDesc ,QueryDescStack );
310+
326311PG_TRY ();
327312{
328313if (prev_ExecutorRun )
@@ -335,10 +320,11 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
335320else
336321standard_ExecutorRun (queryDesc ,direction ,count ,execute_once );
337322#endif
323+ QueryDescStack = list_delete_first (QueryDescStack );
338324}
339325PG_CATCH ();
340326{
341- QueryDescStack = NIL ;
327+ QueryDescStack = list_delete_first ( QueryDescStack ) ;
342328PG_RE_THROW ();
343329}
344330PG_END_TRY ();
@@ -351,40 +337,19 @@ qs_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, uint64 count,
351337static void
352338qs_ExecutorFinish (QueryDesc * queryDesc )
353339{
340+ QueryDescStack = lcons (queryDesc ,QueryDescStack );
341+
354342PG_TRY ();
355343{
356344if (prev_ExecutorFinish )
357345prev_ExecutorFinish (queryDesc );
358346else
359347standard_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- {
378348QueryDescStack = list_delete_first (QueryDescStack );
379-
380- if (prev_ExecutorEnd )
381- prev_ExecutorEnd (queryDesc );
382- else
383- standard_ExecutorEnd (queryDesc );
384349}
385350PG_CATCH ();
386351{
387- QueryDescStack = NIL ;
352+ QueryDescStack = list_delete_first ( QueryDescStack ) ;
388353PG_RE_THROW ();
389354}
390355PG_END_TRY ();