Skip to content

Commit

Permalink
Fix pg_stat_kcache support when not all metrics are available.
Browse files Browse the repository at this point in the history
The plan_* fields can be NULL if pg_stat_kcache.track_planning isn't enable.
Most of the exec_* fields can also be NULL on system without getrusage()
support.
  • Loading branch information
rjuju committed May 4, 2023
1 parent 6c42d67 commit 17b7824
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 22 deletions.
23 changes: 23 additions & 0 deletions powa--4.1.4--4.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -309,3 +309,26 @@ BEGIN
DELETE FROM powa_statements_history_current_db WHERE srvid = _srvid;
END;
$PROC$ LANGUAGE plpgsql; /* end of powa_statements_aggregate */

ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_reads DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_writes DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_user_time DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_system_time DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_minflts DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_majflts DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_nswaps DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_msgsnds DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_msgrcvs DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_nsignals DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_nvcsws DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN plan_nivcsws DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_reads DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_writes DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_minflts DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_majflts DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_nswaps DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_msgsnds DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_msgrcvs DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_nsignals DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_nvcsws DROP NOT NULL;
ALTER TABLE public.powa_kcache_src_tmp ALTER COLUMN exec_nivcsws DROP NOT NULL;
44 changes: 22 additions & 22 deletions powa--4.2.0.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1385,30 +1385,30 @@ CREATE UNLOGGED TABLE public.powa_kcache_src_tmp(
top bool NOT NULL,
userid oid NOT NULL,
dbid oid NOT NULL,
plan_reads bigint NOT NULL,
plan_writes bigint NOT NULL,
plan_user_time double precision NOT NULL,
plan_system_time double precision NOT NULL,
plan_minflts bigint NOT NULL,
plan_majflts bigint NOT NULL,
plan_nswaps bigint NOT NULL,
plan_msgsnds bigint NOT NULL,
plan_msgrcvs bigint NOT NULL,
plan_nsignals bigint NOT NULL,
plan_nvcsws bigint NOT NULL,
plan_nivcsws bigint NOT NULL,
exec_reads bigint NOT NULL,
exec_writes bigint NOT NULL,
plan_reads bigint,
plan_writes bigint,
plan_user_time double precision,
plan_system_time double precision,
plan_minflts bigint,
plan_majflts bigint,
plan_nswaps bigint,
plan_msgsnds bigint,
plan_msgrcvs bigint,
plan_nsignals bigint,
plan_nvcsws bigint,
plan_nivcsws bigint,
exec_reads bigint,
exec_writes bigint,
exec_user_time double precision NOT NULL,
exec_system_time double precision NOT NULL,
exec_minflts bigint NOT NULL,
exec_majflts bigint NOT NULL,
exec_nswaps bigint NOT NULL,
exec_msgsnds bigint NOT NULL,
exec_msgrcvs bigint NOT NULL,
exec_nsignals bigint NOT NULL,
exec_nvcsws bigint NOT NULL,
exec_nivcsws bigint NOT NULL
exec_minflts bigint,
exec_majflts bigint,
exec_nswaps bigint,
exec_msgsnds bigint,
exec_msgrcvs bigint,
exec_nsignals bigint,
exec_nvcsws bigint,
exec_nivcsws bigint
);

CREATE TYPE public.powa_kcache_type AS (
Expand Down

0 comments on commit 17b7824

Please sign in to comment.