|
| 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 @extschema@.pgbouncer_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 @extschema@.pgbouncer_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 @extschema@.pgbouncer_servers; |
| 20 | +DROP VIEW @extschema@.pgbouncer_dns_zones; |
| 21 | + |
| 22 | +CREATE OR REPLACE VIEW @extschema@.pgbouncer_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 @extschema@.pgbouncer_servers_func(); |
| 43 | + |
| 44 | + |
| 45 | +CREATE VIEW @extschema@.pgbouncer_dns_zones AS |
| 46 | + SELECT pgbouncer_target_host |
| 47 | + , zonename |
| 48 | + , serial |
| 49 | + , count |
| 50 | + FROM @extschema@.pgbouncer_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