Skip to content

Commit 965a549

Browse files
authored
fix: fix pgbouncer_server view missing column (#16)
* fix: fix pgbouncer_server view missing column * chore: update changelog * fix: fix pgbouncer_dns_zones view missing column
1 parent a39b774 commit 965a549

File tree

4 files changed

+72
-5
lines changed

4 files changed

+72
-5
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v1.0.1
2+
-- Fix missing comma that caused missing column "pgbouncer_target_host" in "pgbouncer_servers" and "pgbouncer_dns_zones" views
3+
4+
15
v1.0.0
26
-- IMPORTANT NOTE: All objects in this extension are dropped and recreated as part of this update. Privileges ARE NOT preserved as part of this update, so please ensure privileges you have on these objects are preserved before upgrading so that they can be reapplied. Note that execution by PUBLIC on the admin functions is once again revoked by this update.
37

pgbouncer_fdw.control

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
default_version = '1.0.0'
1+
default_version = '1.0.1'
22
comment = 'Extension for querying PgBouncer stats from normal SQL views & running pgbouncer commands from normal SQL functions'
33
requires = dblink
44
relocatable = false

sql/views/pgbouncer_fdw_views.sql

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ CREATE VIEW @[email protected]_dns_hosts AS
6666

6767
CREATE VIEW @[email protected]_dns_zones AS
6868
SELECT pgbouncer_target_host
69-
zonename
69+
, zonename
7070
, serial
7171
, count
7272
FROM @[email protected]_dns_zones_func();
@@ -102,7 +102,7 @@ CREATE VIEW @[email protected]_pools AS
102102

103103
CREATE VIEW @[email protected]_servers AS
104104
SELECT pgbouncer_target_host
105-
"type"
105+
, "type"
106106
, "user"
107107
, database
108108
, state
@@ -178,5 +178,3 @@ CREATE VIEW @[email protected]_users AS
178178
, name
179179
, pool_mode
180180
FROM @[email protected]_users_func();
181-
182-
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
-- Fix missing comma that caused missing column "pgbouncer_target_host" in "pgbouncer_servers" and "pgbouncer_dns_zones" views
2+
3+
CREATE TEMP TABLE pgbouncer_fdw_preserve_privs_temp (statement text);
4+
5+
INSERT INTO pgbouncer_fdw_preserve_privs_temp
6+
SELECT 'GRANT '||string_agg(privilege_type, ',')||' ON @[email protected]_servers TO '||grantee::text||';'
7+
FROM information_schema.table_privileges
8+
WHERE table_schema = '@extschema@'
9+
AND table_name = 'pgbouncer_servers'
10+
GROUP BY grantee;
11+
12+
INSERT INTO pgbouncer_fdw_preserve_privs_temp
13+
SELECT 'GRANT '||string_agg(privilege_type, ',')||' ON @[email protected]_dns_zones TO '||grantee::text||';'
14+
FROM information_schema.table_privileges
15+
WHERE table_schema = '@extschema@'
16+
AND table_name = 'pgbouncer_dns_zones'
17+
GROUP BY grantee;
18+
19+
DROP VIEW @[email protected]_servers;
20+
DROP VIEW @[email protected]_dns_zones;
21+
22+
CREATE OR REPLACE VIEW @[email protected]_servers AS
23+
SELECT pgbouncer_target_host
24+
, "type"
25+
, "user"
26+
, database
27+
, state
28+
, addr
29+
, port
30+
, local_addr
31+
, local_port
32+
, connect_time
33+
, request_time
34+
, wait
35+
, wait_us
36+
, close_needed
37+
, ptr
38+
, link
39+
, remote_pid
40+
, tls
41+
, application_name
42+
FROM @[email protected]_servers_func();
43+
44+
45+
CREATE VIEW @[email protected]_dns_zones AS
46+
SELECT pgbouncer_target_host
47+
, zonename
48+
, serial
49+
, count
50+
FROM @[email protected]_dns_zones_func();
51+
52+
-- Restore dropped object privileges
53+
DO $$
54+
DECLARE
55+
v_row record;
56+
BEGIN
57+
FOR v_row IN SELECT statement FROM pgbouncer_fdw_preserve_privs_temp LOOP
58+
IF v_row.statement IS NOT NULL THEN
59+
EXECUTE v_row.statement;
60+
END IF;
61+
END LOOP;
62+
END
63+
$$;
64+
65+
DROP TABLE IF EXISTS pgbouncer_fdw_preserve_privs_temp;

0 commit comments

Comments
 (0)