-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
default_version = '1.0.0' | ||
default_version = '1.0.1' | ||
comment = 'Extension for querying PgBouncer stats from normal SQL views & running pgbouncer commands from normal SQL functions' | ||
requires = dblink | ||
relocatable = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ CREATE VIEW @[email protected]_dns_hosts AS | |
|
||
CREATE VIEW @[email protected]_dns_zones AS | ||
SELECT pgbouncer_target_host | ||
zonename | ||
, zonename | ||
, serial | ||
, count | ||
FROM @[email protected]_dns_zones_func(); | ||
|
@@ -102,7 +102,7 @@ CREATE VIEW @[email protected]_pools AS | |
|
||
CREATE VIEW @[email protected]_servers AS | ||
SELECT pgbouncer_target_host | ||
"type" | ||
, "type" | ||
, "user" | ||
, database | ||
, state | ||
|
@@ -178,5 +178,3 @@ CREATE VIEW @[email protected]_users AS | |
, name | ||
, pool_mode | ||
FROM @[email protected]_users_func(); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
-- Fix missing comma that caused missing column "pgbouncer_target_host" in "pgbouncer_servers" and "pgbouncer_dns_zones" views | ||
|
||
CREATE TEMP TABLE pgbouncer_fdw_preserve_privs_temp (statement text); | ||
|
||
INSERT INTO pgbouncer_fdw_preserve_privs_temp | ||
SELECT 'GRANT '||string_agg(privilege_type, ',')||' ON @[email protected]_servers TO '||grantee::text||';' | ||
FROM information_schema.table_privileges | ||
WHERE table_schema = '@extschema@' | ||
AND table_name = 'pgbouncer_servers' | ||
GROUP BY grantee; | ||
|
||
INSERT INTO pgbouncer_fdw_preserve_privs_temp | ||
SELECT 'GRANT '||string_agg(privilege_type, ',')||' ON @[email protected]_dns_zones TO '||grantee::text||';' | ||
FROM information_schema.table_privileges | ||
WHERE table_schema = '@extschema@' | ||
AND table_name = 'pgbouncer_dns_zones' | ||
GROUP BY grantee; | ||
|
||
DROP VIEW @[email protected]_servers; | ||
DROP VIEW @[email protected]_dns_zones; | ||
|
||
CREATE OR REPLACE VIEW @[email protected]_servers AS | ||
SELECT pgbouncer_target_host | ||
, "type" | ||
, "user" | ||
, database | ||
, state | ||
, addr | ||
, port | ||
, local_addr | ||
, local_port | ||
, connect_time | ||
, request_time | ||
, wait | ||
, wait_us | ||
, close_needed | ||
, ptr | ||
, link | ||
, remote_pid | ||
, tls | ||
, application_name | ||
FROM @[email protected]_servers_func(); | ||
|
||
|
||
CREATE VIEW @[email protected]_dns_zones AS | ||
SELECT pgbouncer_target_host | ||
, zonename | ||
, serial | ||
, count | ||
FROM @[email protected]_dns_zones_func(); | ||
|
||
-- Restore dropped object privileges | ||
DO $$ | ||
DECLARE | ||
v_row record; | ||
BEGIN | ||
FOR v_row IN SELECT statement FROM pgbouncer_fdw_preserve_privs_temp LOOP | ||
IF v_row.statement IS NOT NULL THEN | ||
EXECUTE v_row.statement; | ||
END IF; | ||
END LOOP; | ||
END | ||
$$; | ||
|
||
DROP TABLE IF EXISTS pgbouncer_fdw_preserve_privs_temp; |