@@ -350,31 +350,41 @@ qs_postExecProcNode(PlanState *planstate, TupleTableSlot *result)
350350static void
351351qs_ExecutorStart (QueryDesc * queryDesc ,int eflags )
352352{
353- /* Enable per-node instrumentation */
354- if (pg_qs_enable && ((eflags & EXEC_FLAG_EXPLAIN_ONLY )== 0 ))
353+ PG_TRY ();
355354{
356- queryDesc -> instrument_options |=INSTRUMENT_ROWS ;
357- if (pg_qs_timing )
358- queryDesc -> instrument_options |=INSTRUMENT_TIMER ;
359- if (pg_qs_buffers )
360- queryDesc -> instrument_options |=INSTRUMENT_BUFFERS ;
361- }
355+ /* Enable per-node instrumentation */
356+ if (pg_qs_enable && ((eflags & EXEC_FLAG_EXPLAIN_ONLY )== 0 ))
357+ {
358+ queryDesc -> instrument_options |=INSTRUMENT_ROWS ;
359+ if (pg_qs_timing )
360+ queryDesc -> instrument_options |=INSTRUMENT_TIMER ;
361+ if (pg_qs_buffers )
362+ queryDesc -> instrument_options |=INSTRUMENT_BUFFERS ;
363+ }
362364
363- if (prev_ExecutorStart )
364- prev_ExecutorStart (queryDesc ,eflags );
365- else
366- standard_ExecutorStart (queryDesc ,eflags );
365+ if (prev_ExecutorStart )
366+ prev_ExecutorStart (queryDesc ,eflags );
367+ else
368+ standard_ExecutorStart (queryDesc ,eflags );
367369
368- /* push structure about current query in global stack */
369- QueryDescStack = lcons (queryDesc ,QueryDescStack );
370+ /* push structure about current query in global stack */
371+ QueryDescStack = lcons (queryDesc ,QueryDescStack );
370372
371- /* set/reset hook for trace mode before start of upper level query */
372- if (list_length (QueryDescStack )== 1 )
373- postExecProcNode_hook = (pg_qs_trace ) ?qs_postExecProcNode :prev_postExecProcNode ;
373+ /* set/reset hook for trace mode before start of upper level query */
374+ if (list_length (QueryDescStack )== 1 )
375+ postExecProcNode_hook = (pg_qs_enable && pg_qs_trace ) ?
376+ qs_postExecProcNode :prev_postExecProcNode ;
374377
375- /* suspend traceable query if it is not continued (hook is not thrown off) */
376- if (postExecProcNode_hook == qs_postExecProcNode )
377- suspend_traceable_query ();
378+ /* suspend traceable query if it is not traceable or continued (hook is not thrown off) */
379+ if (postExecProcNode_hook == qs_postExecProcNode )
380+ suspend_traceable_query ();
381+ }
382+ PG_CATCH ();
383+ {
384+ QueryDescStack = NIL ;
385+ PG_RE_THROW ();
386+ }
387+ PG_END_TRY ();
378388}
379389
380390/*
@@ -428,12 +438,21 @@ qs_ExecutorFinish(QueryDesc *queryDesc)
428438static void
429439qs_ExecutorEnd (QueryDesc * queryDesc )
430440{
431- QueryDescStack = list_delete_first (QueryDescStack );
441+ PG_TRY ();
442+ {
443+ QueryDescStack = list_delete_first (QueryDescStack );
432444
433- if (prev_ExecutorEnd )
434- prev_ExecutorEnd (queryDesc );
435- else
436- standard_ExecutorEnd (queryDesc );
445+ if (prev_ExecutorEnd )
446+ prev_ExecutorEnd (queryDesc );
447+ else
448+ standard_ExecutorEnd (queryDesc );
449+ }
450+ PG_CATCH ();
451+ {
452+ QueryDescStack = NIL ;
453+ PG_RE_THROW ();
454+ }
455+ PG_END_TRY ();
437456}
438457
439458/*