Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pg_show_plans.startup_enable guc #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ query |
- *plan*: the query plan of the running query.

## Configuration Parameters
- *pg_show_plans.startup_enable* : Boolean that defines if plans are enabled at startup, or not. Default is `true`.
- *pg_show_plans.plan_format* : It controls the output format of query plans. It can be selected either `text` or `json`. Default is `text`.
- *pg_show_plans.max_plan_length* : It sets the maximum length of query plans. Default is `8192` [byte]. Note that this parameter must be set to an integer.

Expand Down
16 changes: 14 additions & 2 deletions pg_show_plans.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ static int pgsp_max; /* max plans to show */
static int plan_format; /* output format */
#endif
static int max_plan_length; /* max length of query plan */
static bool startup_enable; /* startup value */

/*
* Function declarations
Expand Down Expand Up @@ -193,6 +194,17 @@ _PG_init(void)
NULL);
#endif

DefineCustomBoolVariable("pg_show_plans.startup_enable",
"Selects whether pg_show_plans is enabled at startup.",
NULL,
&startup_enable,
true,
PGC_POSTMASTER,
0,
NULL,
NULL,
NULL);

EmitWarningsOnPlaceholders("pg_show_plans");

RequestAddinShmemSpace(pgsp_memsize());
Expand Down Expand Up @@ -262,8 +274,8 @@ pgsp_shmem_startup(void)
SpinLockInit(&pgsp->elock);
}

/* Set the initial value to is_enable */
pgsp->is_enable = true;
/* Set the initial value based on startup_enable */
pgsp->is_enable = startup_enable;
#if PG_VERSION_NUM >= 90500
pgsp->plan_format = plan_format;
#endif
Expand Down