Skip to content

Commit

Permalink
Fixes and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
artemgavrilov committed Jun 6, 2024
1 parent fd8864d commit 122a30c
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 112 deletions.
218 changes: 109 additions & 109 deletions pg_stat_monitor--2.0--2.1.sql
Original file line number Diff line number Diff line change
Expand Up @@ -105,35 +105,35 @@ $$
BEGIN
CREATE VIEW pg_stat_monitor AS SELECT
bucket,
bucket_start_time AS bucket_start_time,
bucket_start_time AS bucket_start_time,
userid,
username,
dbid,
datname,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
queryid,
top_queryid,
query,
comments,
planid,
query_plan,
comments,
planid,
query_plan,
top_query,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
calls,
total_exec_time AS total_time,
min_exec_time AS min_time,
max_exec_time AS max_time,
mean_exec_time AS mean_time,
stddev_exec_time AS stddev_time,
rows,
shared_blks_hit,
total_exec_time AS total_time,
min_exec_time AS min_time,
max_exec_time AS max_time,
mean_exec_time AS mean_time,
stddev_exec_time AS stddev_time,
rows,
shared_blks_hit,
shared_blks_read,
shared_blks_dirtied,
shared_blks_written,
Expand All @@ -145,10 +145,10 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written,
shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
bucket_done
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
bucket_done
FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time;
RETURN 0;
Expand All @@ -161,36 +161,36 @@ $$
BEGIN
CREATE VIEW pg_stat_monitor AS SELECT
bucket,
bucket_start_time AS bucket_start_time,
bucket_start_time AS bucket_start_time,
userid,
username,
dbid,
datname,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
queryid,
toplevel,
top_queryid,
query,
comments,
planid,
query_plan,
comments,
planid,
query_plan,
top_query,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
calls,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
shared_blks_read,
shared_blks_dirtied,
shared_blks_written,
Expand All @@ -202,19 +202,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written,
shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
wal_records,
wal_fpi,
wal_bytes,
bucket_done,
bucket_done,
-- PostgreSQL-13 Specific Coulumns
plans,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
plans,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
stddev_plan_time
FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time;
Expand All @@ -227,36 +227,36 @@ $$
BEGIN
CREATE VIEW pg_stat_monitor AS SELECT
bucket,
bucket_start_time AS bucket_start_time,
bucket_start_time AS bucket_start_time,
userid,
username,
dbid,
datname,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
queryid,
toplevel,
top_queryid,
query,
comments,
planid,
query_plan,
comments,
planid,
query_plan,
top_query,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
calls,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
shared_blks_read,
shared_blks_dirtied,
shared_blks_written,
Expand All @@ -268,19 +268,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written,
shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
wal_records,
wal_fpi,
wal_bytes,
bucket_done,
bucket_done,

plans,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
stddev_plan_time
FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time;
Expand All @@ -293,36 +293,36 @@ $$
BEGIN
CREATE VIEW pg_stat_monitor AS SELECT
bucket,
bucket_start_time AS bucket_start_time,
bucket_start_time AS bucket_start_time,
userid,
username,
dbid,
datname,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
'0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id,
queryid,
toplevel,
top_queryid,
query,
comments,
planid,
query_plan,
comments,
planid,
query_plan,
top_query,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
application_name,
string_to_array(relations, ',') AS relations,
cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text,
elevel,
sqlcode,
message,
calls,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
total_exec_time,
min_exec_time,
max_exec_time,
mean_exec_time,
stddev_exec_time,
rows,
shared_blks_hit,
shared_blks_read,
shared_blks_dirtied,
shared_blks_written,
Expand All @@ -337,19 +337,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blk_read_time,
temp_blk_write_time,

(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
(string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time,
cpu_sys_time,
wal_records,
wal_fpi,
wal_bytes,
bucket_done,
bucket_done,

plans,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
total_plan_time,
min_plan_time,
max_plan_time,
mean_plan_time,
stddev_plan_time,

jit_functions,
Expand Down
5 changes: 3 additions & 2 deletions pg_stat_monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -2082,8 +2082,9 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
expected_columns = PG_STAT_MONITOR_COLS_V2_1;
break;
default:
// TODO error?
break;
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
}

/* Disallow old api usage */
Expand Down
2 changes: 1 addition & 1 deletion t/027_local_blocks.pl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
trim($stdout);
is($stdout,'t',"Check: local_blks_hit should not be 0.");

# TODO: Find a way how to bypass cache and ger real block reads
# TODO: Find a way how to bypass cache and get real block reads
# if ($PGSM::PG_MAJOR_VERSION >= 17)
# {
# ($cmdret, $stdout, $stderr) = $node->psql('postgres', 'SELECT SUM(PGSM.local_blk_read_time) != 0 FROM pg_stat_monitor AS PGSM WHERE PGSM.query LIKE \'%FROM t1%\';', extra_params => ['-Pformat=unaligned','-Ptuples_only=on']);
Expand Down

0 comments on commit 122a30c

Please sign in to comment.