Skip to content

Commit 00b0098

Browse files
committed
Fix logic errors and improve code consistency
Code improvements: - Fix alter_user script to use 'raise info' instead of 'raise debug' for consistency with create_user script - Fix inverted logic in refresh_all.sql notice message: - Change TRUE to FALSE for correct instruction - Replace "w/o" with "without" for better readability - Remove duplicate 'sum(calls) as calls' in s1_pg_stat_statements_top_total.sql that was defined both globally and in the \else block These changes fix functional issues and improve code clarity.
1 parent d9389d3 commit 00b0098

File tree

3 files changed

+4
-5
lines changed

3 files changed

+4
-5
lines changed

matviews/refresh_all.sql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Use this to do the very 1st REFRESH for your matviews
22
-- In case when there are complex relations between matviews,
33
-- it might perform multiple iterations and eventually refreshes
4-
-- all matviews (either all w/o data or absolutely all -- it's up to you).
4+
-- all matviews (either all without data or absolutely all -- it's up to you).
55

66
-- set this to TRUE here if you need ALL matviews to be refreshed, not only those that already have been refreshed
77
set postgres_dba.refresh_matviews_with_data = FALSE;
@@ -22,7 +22,7 @@ begin
2222
set postgres_dba.refresh_matviews_with_data = true;
2323
end if;
2424
if current_setting('postgres_dba.refresh_matviews_with_data')::boolean then
25-
raise notice 'Refreshing ALL matviews (run ''set postgres_dba.refresh_matviews_with_data_forced = TRUE;'' to refresh only matviews w/o data).';
25+
raise notice 'Refreshing ALL matviews (run ''set postgres_dba.refresh_matviews_with_data_forced = FALSE;'' to refresh only matviews without data).';
2626
for matview in
2727
select format('"%s"."%s"', schemaname::text, matviewname::text)
2828
from pg_matviews
@@ -32,7 +32,7 @@ begin
3232
execute sql;
3333
end loop;
3434
else
35-
raise notice 'Refreshing only matviews w/o data (run ''set postgres_dba.refresh_matviews_with_data_forced = TRUE;'' to refresh all matviews).';
35+
raise notice 'Refreshing only matviews without data (run ''set postgres_dba.refresh_matviews_with_data_forced = TRUE;'' to refresh all matviews).';
3636
end if;
3737

3838
iter := 1;

roles/alter_user_with_random_password.psql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ begin
5656
(case when lower(current_setting('postgres_dba.login')::text) not in ('0', '', 'no', 'false', 'n', 'f') then ' login' else '' end));
5757
raise debug 'SQL: %', sql;
5858
execute sql;
59-
raise debug 'User % altered, password: %', current_setting('postgres_dba.username')::text, pwd;
59+
raise info 'User % altered, password: %', current_setting('postgres_dba.username')::text, pwd;
6060
end;
6161
$$ language plpgsql;
6262

sql/s1_pg_stat_statements_top_total.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ select
3030
round(max(max_plan_time)::numeric, 2)
3131
) as min_max_plan_t,
3232
\else
33-
sum(calls) as calls,
3433
round(sum(total_time)::numeric, 2) as total_time,
3534
round((sum(mean_time * calls) / sum(calls))::numeric, 2) as mean_time,
3635
format(

0 commit comments

Comments
 (0)