|
14 | 14 | #include "postgres.h" |
15 | 15 | /* Comments just indicate which includes are still in use. */ |
16 | 16 | #include "commands/explain.h" /* To explain statements. */ |
| 17 | +#include "fmgr.h" /* PG_RETURN_VOID() */ |
17 | 18 | #include "funcapi.h" /* To return sets in SQL funcs. */ |
18 | 19 | #include "lib/stringinfo.h" /* StringInfo */ |
19 | 20 | #include "miscadmin.h" /* process_shared_preload_libraries_in_progress */ |
@@ -94,10 +95,16 @@ static void pgsp_ExecutorStart(QueryDesc *queryDesc, int eflags); |
94 | 95 | static void pgsp_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, |
95 | 96 | uint64 count, bool execute_once); |
96 | 97 |
|
| 98 | +/* Enables the extension. */ |
| 99 | +Datum pg_show_plans_enable(PG_FUNCTION_ARGS); |
| 100 | +/* Disables the extension. */ |
| 101 | +Datum pg_show_plans_disable(PG_FUNCTION_ARGS); |
97 | 102 | /* Show query plans of all the currently running statements. */ |
98 | 103 | Datum pg_show_plans(PG_FUNCTION_ARGS); |
99 | 104 |
|
100 | 105 | PG_FUNCTION_INFO_V1(pg_show_plans); |
| 106 | +PG_FUNCTION_INFO_V1(pg_show_plans_enable); |
| 107 | +PG_FUNCTION_INFO_V1(pg_show_plans_disable); |
101 | 108 |
|
102 | 109 | /* Global Variables */ |
103 | 110 | /* Shared extension state. */ |
@@ -413,6 +420,19 @@ pgsp_ExecutorRun(QueryDesc *queryDesc, ScanDirection direction, |
413 | 420 | PG_END_TRY(); |
414 | 421 | } |
415 | 422 |
|
| 423 | +Datum |
| 424 | +pg_show_plans_enable(PG_FUNCTION_ARGS) |
| 425 | +{ |
| 426 | + pgsp->is_enabled = true; |
| 427 | + PG_RETURN_VOID(); |
| 428 | +} |
| 429 | + |
| 430 | +Datum |
| 431 | +pg_show_plans_disable(PG_FUNCTION_ARGS) |
| 432 | +{ |
| 433 | + pgsp->is_enabled = false; |
| 434 | + PG_RETURN_VOID(); |
| 435 | +} |
416 | 436 | Datum |
417 | 437 | pg_show_plans(PG_FUNCTION_ARGS) |
418 | 438 | { |
|
0 commit comments