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

Fix config reload crash for <=14 #47

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
57 changes: 57 additions & 0 deletions expected/formats_2.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
-- explain output on PG12/13 is missing "Async Capable"
select setting::int < 140000 as pg12_13 from pg_settings where name = 'server_version_num';
pg12_13
---------
f
(1 row)

-- json output
set pg_show_plans.plan_format = 'json';
ERROR: parameter "pg_show_plans.plan_format" cannot be changed without restarting the server
show pg_show_plans.plan_format;
pg_show_plans.plan_format
---------------------------
text
(1 row)

select * from nest();
level | plan
-------+------
(0 rows)

-- yaml output
set pg_show_plans.plan_format = 'yaml';
ERROR: parameter "pg_show_plans.plan_format" cannot be changed without restarting the server
show pg_show_plans.plan_format;
pg_show_plans.plan_format
---------------------------
text
(1 row)

select * from nest();
level | plan
-------+------
(0 rows)

-- xml output
set pg_show_plans.plan_format = 'xml';
ERROR: parameter "pg_show_plans.plan_format" cannot be changed without restarting the server
show pg_show_plans.plan_format;
pg_show_plans.plan_format
---------------------------
text
(1 row)

select * from nest();
level | plan
-------+------
(0 rows)

-- check plan format after reconnect
\c
show pg_show_plans.plan_format;
pg_show_plans.plan_format
---------------------------
text
(1 row)

42 changes: 42 additions & 0 deletions expected/pg_show_plans_1.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
create extension pg_show_plans;
show pg_show_plans.is_enabled;
pg_show_plans.is_enabled
--------------------------
off
(1 row)

show pg_show_plans.max_plan_length;
pg_show_plans.max_plan_length
-------------------------------
16384
(1 row)

create function nest()
returns table (level int, plan text)
language plpgsql
as $$
begin
return query
select pg_show_plans.level, pg_show_plans.plan from pg_show_plans
where pg_show_plans.level >= 0;
end;
$$;
-- text output
set pg_show_plans.plan_format = 'text';
ERROR: parameter "pg_show_plans.plan_format" cannot be changed without restarting the server
show pg_show_plans.plan_format;
pg_show_plans.plan_format
---------------------------
text
(1 row)

select level, plan from pg_show_plans;
level | plan
-------+------
(0 rows)

select * from nest();
level | plan
-------+------
(0 rows)

8 changes: 8 additions & 0 deletions pg_show_plans.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,11 @@ _PG_init(void)
NULL,
&start_enabled,
true,
#if PG_VERSION_NUM >= 150000
PGC_USERSET,
#else
PGC_POSTMASTER,
#endif
0,
NULL, set_state, show_state);
DefineCustomIntVariable("pg_show_plans.max_plan_length",
Expand All @@ -183,7 +187,11 @@ _PG_init(void)
&plan_format,
EXPLAIN_FORMAT_TEXT,
plan_formats,
#if PG_VERSION_NUM >= 150000
PGC_USERSET,
#else
PGC_POSTMASTER,
#endif
0,
NULL, prop_format_to_shmem, show_format);

Expand Down
Loading