Fixes and formatting

pull/463/head
Artem Gavrilov 2024-06-06 15:57:47 +02:00
parent fd8864dba3
commit 122a30c82b
3 changed files with 113 additions and 112 deletions

View File

@ -105,35 +105,35 @@ $$
BEGIN BEGIN
CREATE VIEW pg_stat_monitor AS SELECT CREATE VIEW pg_stat_monitor AS SELECT
bucket, bucket,
bucket_start_time AS bucket_start_time, bucket_start_time AS bucket_start_time,
userid, userid,
username, username,
dbid, dbid,
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id, pgsm_query_id,
queryid, queryid,
top_queryid, top_queryid,
query, query,
comments, comments,
planid, planid,
query_plan, query_plan,
top_query, top_query,
application_name, application_name,
string_to_array(relations, ',') AS relations, string_to_array(relations, ',') AS relations,
cmd_type, cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text, get_cmd_type(cmd_type) AS cmd_type_text,
elevel, elevel,
sqlcode, sqlcode,
message, message,
calls, calls,
total_exec_time AS total_time, total_exec_time AS total_time,
min_exec_time AS min_time, min_exec_time AS min_time,
max_exec_time AS max_time, max_exec_time AS max_time,
mean_exec_time AS mean_time, mean_exec_time AS mean_time,
stddev_exec_time AS stddev_time, stddev_exec_time AS stddev_time,
rows, rows,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
shared_blks_dirtied, shared_blks_dirtied,
shared_blks_written, shared_blks_written,
@ -145,10 +145,10 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written, temp_blks_written,
shared_blk_read_time AS blk_read_time, shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time, shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls, (string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time, cpu_user_time,
cpu_sys_time, cpu_sys_time,
bucket_done bucket_done
FROM pg_stat_monitor_internal(TRUE) FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time; ORDER BY bucket_start_time;
RETURN 0; RETURN 0;
@ -161,36 +161,36 @@ $$
BEGIN BEGIN
CREATE VIEW pg_stat_monitor AS SELECT CREATE VIEW pg_stat_monitor AS SELECT
bucket, bucket,
bucket_start_time AS bucket_start_time, bucket_start_time AS bucket_start_time,
userid, userid,
username, username,
dbid, dbid,
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id, pgsm_query_id,
queryid, queryid,
toplevel, toplevel,
top_queryid, top_queryid,
query, query,
comments, comments,
planid, planid,
query_plan, query_plan,
top_query, top_query,
application_name, application_name,
string_to_array(relations, ',') AS relations, string_to_array(relations, ',') AS relations,
cmd_type, cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text, get_cmd_type(cmd_type) AS cmd_type_text,
elevel, elevel,
sqlcode, sqlcode,
message, message,
calls, calls,
total_exec_time, total_exec_time,
min_exec_time, min_exec_time,
max_exec_time, max_exec_time,
mean_exec_time, mean_exec_time,
stddev_exec_time, stddev_exec_time,
rows, rows,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
shared_blks_dirtied, shared_blks_dirtied,
shared_blks_written, shared_blks_written,
@ -202,19 +202,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written, temp_blks_written,
shared_blk_read_time AS blk_read_time, shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time, shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls, (string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time, cpu_user_time,
cpu_sys_time, cpu_sys_time,
wal_records, wal_records,
wal_fpi, wal_fpi,
wal_bytes, wal_bytes,
bucket_done, bucket_done,
-- PostgreSQL-13 Specific Coulumns -- PostgreSQL-13 Specific Coulumns
plans, plans,
total_plan_time, total_plan_time,
min_plan_time, min_plan_time,
max_plan_time, max_plan_time,
mean_plan_time, mean_plan_time,
stddev_plan_time stddev_plan_time
FROM pg_stat_monitor_internal(TRUE) FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time; ORDER BY bucket_start_time;
@ -227,36 +227,36 @@ $$
BEGIN BEGIN
CREATE VIEW pg_stat_monitor AS SELECT CREATE VIEW pg_stat_monitor AS SELECT
bucket, bucket,
bucket_start_time AS bucket_start_time, bucket_start_time AS bucket_start_time,
userid, userid,
username, username,
dbid, dbid,
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id, pgsm_query_id,
queryid, queryid,
toplevel, toplevel,
top_queryid, top_queryid,
query, query,
comments, comments,
planid, planid,
query_plan, query_plan,
top_query, top_query,
application_name, application_name,
string_to_array(relations, ',') AS relations, string_to_array(relations, ',') AS relations,
cmd_type, cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text, get_cmd_type(cmd_type) AS cmd_type_text,
elevel, elevel,
sqlcode, sqlcode,
message, message,
calls, calls,
total_exec_time, total_exec_time,
min_exec_time, min_exec_time,
max_exec_time, max_exec_time,
mean_exec_time, mean_exec_time,
stddev_exec_time, stddev_exec_time,
rows, rows,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
shared_blks_dirtied, shared_blks_dirtied,
shared_blks_written, shared_blks_written,
@ -268,19 +268,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blks_written, temp_blks_written,
shared_blk_read_time AS blk_read_time, shared_blk_read_time AS blk_read_time,
shared_blk_write_time AS blk_write_time, shared_blk_write_time AS blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls, (string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time, cpu_user_time,
cpu_sys_time, cpu_sys_time,
wal_records, wal_records,
wal_fpi, wal_fpi,
wal_bytes, wal_bytes,
bucket_done, bucket_done,
plans, plans,
total_plan_time, total_plan_time,
min_plan_time, min_plan_time,
max_plan_time, max_plan_time,
mean_plan_time, mean_plan_time,
stddev_plan_time stddev_plan_time
FROM pg_stat_monitor_internal(TRUE) FROM pg_stat_monitor_internal(TRUE)
ORDER BY bucket_start_time; ORDER BY bucket_start_time;
@ -293,36 +293,36 @@ $$
BEGIN BEGIN
CREATE VIEW pg_stat_monitor AS SELECT CREATE VIEW pg_stat_monitor AS SELECT
bucket, bucket,
bucket_start_time AS bucket_start_time, bucket_start_time AS bucket_start_time,
userid, userid,
username, username,
dbid, dbid,
datname, datname,
'0.0.0.0'::inet + client_ip AS client_ip, '0.0.0.0'::inet + client_ip AS client_ip,
pgsm_query_id, pgsm_query_id,
queryid, queryid,
toplevel, toplevel,
top_queryid, top_queryid,
query, query,
comments, comments,
planid, planid,
query_plan, query_plan,
top_query, top_query,
application_name, application_name,
string_to_array(relations, ',') AS relations, string_to_array(relations, ',') AS relations,
cmd_type, cmd_type,
get_cmd_type(cmd_type) AS cmd_type_text, get_cmd_type(cmd_type) AS cmd_type_text,
elevel, elevel,
sqlcode, sqlcode,
message, message,
calls, calls,
total_exec_time, total_exec_time,
min_exec_time, min_exec_time,
max_exec_time, max_exec_time,
mean_exec_time, mean_exec_time,
stddev_exec_time, stddev_exec_time,
rows, rows,
shared_blks_hit, shared_blks_hit,
shared_blks_read, shared_blks_read,
shared_blks_dirtied, shared_blks_dirtied,
shared_blks_written, shared_blks_written,
@ -337,19 +337,19 @@ CREATE VIEW pg_stat_monitor AS SELECT
temp_blk_read_time, temp_blk_read_time,
temp_blk_write_time, temp_blk_write_time,
(string_to_array(resp_calls, ',')) resp_calls, (string_to_array(resp_calls, ',')) resp_calls,
cpu_user_time, cpu_user_time,
cpu_sys_time, cpu_sys_time,
wal_records, wal_records,
wal_fpi, wal_fpi,
wal_bytes, wal_bytes,
bucket_done, bucket_done,
plans, plans,
total_plan_time, total_plan_time,
min_plan_time, min_plan_time,
max_plan_time, max_plan_time,
mean_plan_time, mean_plan_time,
stddev_plan_time, stddev_plan_time,
jit_functions, jit_functions,

View File

@ -2082,8 +2082,9 @@ pg_stat_monitor_internal(FunctionCallInfo fcinfo,
expected_columns = PG_STAT_MONITOR_COLS_V2_1; expected_columns = PG_STAT_MONITOR_COLS_V2_1;
break; break;
default: default:
// TODO error? ereport(ERROR,
break; (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("[pg_stat_monitor] pg_stat_monitor_internal: Unknown API version")));
} }
/* Disallow old api usage */ /* Disallow old api usage */

View File

@ -83,7 +83,7 @@ if ($PGSM::PG_MAJOR_VERSION >= 17)
trim($stdout); trim($stdout);
is($stdout,'t',"Check: local_blks_hit should not be 0."); 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) # 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']); # ($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']);