Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0330284

Browse files
author
Maksim Milyutin
committed
Fix problem with interrupt before execution query under trace mode
1 parent4f5645c commit0330284

File tree

3 files changed

+46
-32
lines changed

3 files changed

+46
-32
lines changed

‎README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,7 @@ CREATE EXTENSION pg_query_state;
3030
Done!
3131

3232
##Tests
33-
Testing of`pg_query_state` is carried out in module's directory and has two phases:
34-
1. Isolation tests for corner cases
35-
```
36-
make check
37-
```
38-
2. Tests using parallel sessions using python 2.7 script:
33+
Tests using parallel sessions using python 2.7 script:
3934
```
4035
python tests/pg_qs_test_runner.py [OPTION]...
4136
```

‎pg_query_state.c

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -350,31 +350,41 @@ qs_postExecProcNode(PlanState *planstate, TupleTableSlot *result)
350350
staticvoid
351351
qs_ExecutorStart(QueryDesc*queryDesc,inteflags)
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)
428438
staticvoid
429439
qs_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
/*

‎signal_handler.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct
2727
/*
2828
*Get List of stack_frames as a stack of function calls starting from outermost call.
2929
*Each entry contains query text and query state in form of EXPLAIN ANALYZE output.
30-
*Assume QueryDescStack is not empty
30+
*Assumeextension is enabled andQueryDescStack is not empty
3131
*/
3232
staticList*
3333
runtime_explain()

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp