From 445e89576b90e32aab086b16968961079d0c343a Mon Sep 17 00:00:00 2001 From: Pravesh Sharma Date: Fri, 30 Aug 2024 12:13:47 +0530 Subject: [PATCH] Fixed an issue where users could not use pgAdmin if they did not have access to the management database. #7571 --- .../functions/templates/functions/pg/sql/default/variables.sql | 2 +- .../templates/functions/ppas/sql/default/variables.sql | 2 +- .../templates/procedures/pg/sql/11_plus/variables.sql | 2 +- .../templates/procedures/ppas/sql/default/variables.sql | 2 +- .../templates/trigger_functions/pg/sql/default/variables.sql | 2 +- .../templates/trigger_functions/ppas/sql/default/variables.sql | 2 +- .../tables/templates/partitions/sql/pg/12_plus/properties.sql | 2 +- .../templates/partitions/sql/ppas/12_plus/properties.sql | 2 +- .../schemas/tables/templates/tables/sql/12_plus/properties.sql | 2 +- .../schemas/templates/vacuum_settings/sql/vacuum_defaults.sql | 2 +- .../views/templates/mviews/pg/12_plus/sql/properties.sql | 2 +- .../views/templates/mviews/ppas/12_plus/sql/properties.sql | 2 +- .../databases/templates/databases/sql/default/variables.sql | 2 +- web/pgadmin/browser/server_groups/servers/roles/__init__.py | 2 +- .../templates/tablespaces/sql/default/variables.sql | 2 +- .../dashboard/templates/dashboard/sql/default/config.sql | 2 +- web/pgadmin/utils/driver/psycopg3/connection.py | 3 ++- 17 files changed, 18 insertions(+), 17 deletions(-) diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/pg/sql/default/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/functions/ppas/sql/default/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/pg/sql/11_plus/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/procedures/ppas/sql/default/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/pg/sql/default/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/variables.sql index c75e5b47f..0f777b0c0 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/functions/templates/trigger_functions/ppas/sql/default/variables.sql @@ -1,6 +1,6 @@ SELECT name, vartype, min_val, max_val, enumvals FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser'); diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql index b4c1b907d..c46854f11 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/pg/12_plus/properties.sql @@ -49,7 +49,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, typ.typname, typ.typrelid AS typoid, am.amname, - (SELECT st.setting from pg_catalog.pg_settings st WHERE st.name = 'default_table_access_method') as default_amname, + (SELECT st.setting from pg_catalog.pg_show_all_settings() st WHERE st.name = 'default_table_access_method') as default_amname, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql index db03b0310..e7ec8e3b2 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/partitions/sql/ppas/12_plus/properties.sql @@ -49,7 +49,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age, rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, rel.reloftype, typ.typname, typ.typrelid AS typoid, am.amname, - (SELECT st.setting from pg_catalog.pg_settings st WHERE st.name = 'default_table_access_method') as default_amname, + (SELECT st.setting from pg_catalog.pg_show_all_settings() st WHERE st.name = 'default_table_access_method') as default_amname, (CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable, (SELECT pg_catalog.array_agg(provider || '=' || label) FROM pg_catalog.pg_seclabels sl1 WHERE sl1.objoid=rel.oid AND sl1.objsubid=0) AS seclabels, (CASE WHEN rel.oid <= {{ datlastsysoid}}::oid THEN true ElSE false END) AS is_sys_table, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/properties.sql index ea420a44f..99a4b51b5 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/tables/templates/tables/sql/12_plus/properties.sql @@ -32,7 +32,7 @@ SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS r JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt, (CASE WHEN rel.relpersistence = 'u' THEN true ELSE false END) AS relpersistence, - (SELECT st.setting from pg_catalog.pg_settings st WHERE st.name = 'default_table_access_method') as default_amname, + (SELECT st.setting from pg_catalog.pg_show_all_settings() st WHERE st.name = 'default_table_access_method') as default_amname, substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor, substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'parallel_workers=([0-9]*)') AS parallel_workers, substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'toast_tuple_target=([0-9]*)') AS toast_tuple_target, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/vacuum_settings/sql/vacuum_defaults.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/vacuum_settings/sql/vacuum_defaults.sql index 67e768abc..7993fe697 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/vacuum_settings/sql/vacuum_defaults.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/templates/vacuum_settings/sql/vacuum_defaults.sql @@ -1,2 +1,2 @@ {# ============= Fetch list of default values for autovacuum parameters =============== #} -SELECT name, setting::numeric AS setting FROM pg_catalog.pg_settings WHERE name IN({{ columns }}) ORDER BY name +SELECT name, setting::numeric AS setting FROM pg_catalog.pg_show_all_settings() WHERE name IN({{ columns }}) ORDER BY name diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/12_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/12_plus/sql/properties.sql index 96f4fda4a..03472ec88 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/12_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/pg/12_plus/sql/properties.sql @@ -11,7 +11,7 @@ SELECT JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid WHERE dtb.oid = {{ did }}::oid) END as spcname, - (SELECT st.setting from pg_catalog.pg_settings st + (SELECT st.setting from pg_catalog.pg_show_all_settings() st WHERE st.name = 'default_table_access_method') as default_amname, c.relacl, nsp.nspname as schema, diff --git a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/12_plus/sql/properties.sql b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/12_plus/sql/properties.sql index c69930da1..ae8df20fa 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/12_plus/sql/properties.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/schemas/views/templates/mviews/ppas/12_plus/sql/properties.sql @@ -11,7 +11,7 @@ SELECT JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid WHERE dtb.oid = {{ did }}::oid) END as spcname, - (SELECT st.setting from pg_catalog.pg_settings st + (SELECT st.setting from pg_catalog.pg_show_all_settings() st WHERE st.name = 'default_table_access_method') as default_amname, c.relacl, nsp.nspname as schema, diff --git a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/variables.sql index ff30cb705..696d9139f 100644 --- a/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/databases/templates/databases/sql/default/variables.sql @@ -1,2 +1,2 @@ SELECT name, vartype, min_val, max_val, enumvals -FROM pg_catalog.pg_settings WHERE context in ('user', 'superuser') +FROM pg_catalog.pg_show_all_settings() WHERE context in ('user', 'superuser') diff --git a/web/pgadmin/browser/server_groups/servers/roles/__init__.py b/web/pgadmin/browser/server_groups/servers/roles/__init__.py index 98554b33e..b2ef88389 100644 --- a/web/pgadmin/browser/server_groups/servers/roles/__init__.py +++ b/web/pgadmin/browser/server_groups/servers/roles/__init__.py @@ -1261,7 +1261,7 @@ SELECT name, vartype, min_val::numeric AS min_val, max_val::numeric AS max_val, enumvals FROM - pg_settings + pg_show_all_settings() WHERE context in ('user', 'superuser') ) a""") diff --git a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql index 72fd0bf07..cd05afb20 100644 --- a/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql +++ b/web/pgadmin/browser/server_groups/servers/tablespaces/templates/tablespaces/sql/default/variables.sql @@ -1,4 +1,4 @@ {### SQL to fetch tablespace object options ###} SELECT name, vartype, min_val, max_val, enumvals -FROM pg_catalog.pg_settings +FROM pg_catalog.pg_show_all_settings() WHERE name IN ('seq_page_cost', 'random_page_cost', 'effective_io_concurrency'); diff --git a/web/pgadmin/dashboard/templates/dashboard/sql/default/config.sql b/web/pgadmin/dashboard/templates/dashboard/sql/default/config.sql index 68bdfab3a..6310921bf 100644 --- a/web/pgadmin/dashboard/templates/dashboard/sql/default/config.sql +++ b/web/pgadmin/dashboard/templates/dashboard/sql/default/config.sql @@ -6,6 +6,6 @@ SELECT unit, short_desc FROM - pg_catalog.pg_settings + pg_catalog.pg_show_all_settings() ORDER BY category diff --git a/web/pgadmin/utils/driver/psycopg3/connection.py b/web/pgadmin/utils/driver/psycopg3/connection.py index a81c277b3..2e66b6039 100644 --- a/web/pgadmin/utils/driver/psycopg3/connection.py +++ b/web/pgadmin/utils/driver/psycopg3/connection.py @@ -515,7 +515,8 @@ class Connection(BaseConnection): cur, "SET DateStyle=ISO; " "SET client_min_messages=notice; " - "SELECT set_config('bytea_output','hex',false) FROM pg_settings" + "SELECT set_config('bytea_output','hex',false)" + " FROM pg_show_all_settings()" " WHERE name = 'bytea_output'; " "SET client_encoding='{0}';".format(postgres_encoding) )