Skip to content

Commit

Permalink
update to support pgbouncer 1.18 (#12)
Browse files Browse the repository at this point in the history
* update to support pgbouncer 1.18

* adjust view formatting to reduce future changed lines in git
  • Loading branch information
keithf4 authored Mar 6, 2023
1 parent 160cf61 commit 27b3cab
Show file tree
Hide file tree
Showing 4 changed files with 262 additions and 15 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
v0.5
-- Update to support pgBouncer 1.18.0. Note that as of v0.5, this extension requires at least version 1.18.0 of pgBouncer. If you still need to support an older version, v0.4 works with pgBouncer 1.16 and v0.3 works with older versions of pgBouncer. There are no other changes in this version other than a compatibility update.
-- Several views are dropped and recreated as part of this update. Privileges should be preserved, but it is recommended to double-check them.


v0.4
-- Updated to support pgBouncer 1.16.0. Note that as of v0.4, this extension requires at least version 1.16.0 of pgBouncer. If you still need to support an older version, v0.3 still works and there are no other changes in this version other than a compatibility update.
-- All views are dropped and recreated as part of this update. Privileges should be preserved, but it is recommended to double-check them.
Expand All @@ -8,5 +13,4 @@ v0.3


v0.2

-- Add "pgbouncer_" prefix to all object names to help avoid naming collisions with commonly named objects. Now no longer generally necessary to install in dedicated schema, but still recommended if possible.
2 changes: 1 addition & 1 deletion pgbouncer_fdw.control
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
default_version = '0.4'
default_version = '0.5'
comment = 'Extension for querying pgbouncer stats from normal SQL views & running pgbouncer commands from normal SQL functions'
requires = dblink
relocatable = false
49 changes: 36 additions & 13 deletions sql/views/pgbouncer_fdw_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ CREATE VIEW @[email protected]_clients AS
, link
, remote_pid
, tls
, application_name
FROM dblink('pgbouncer', 'show clients') AS x
( type text
, "user" text
Expand All @@ -33,7 +34,9 @@ CREATE VIEW @[email protected]_clients AS
, ptr text
, link text
, remote_pid int
, tls text);
, tls text
, application_name text
);


CREATE VIEW @[email protected]_config AS
Expand All @@ -45,7 +48,8 @@ CREATE VIEW @[email protected]_config AS
( key text
, value text
, "default" text
, changeable boolean);
, changeable boolean
);


CREATE VIEW @[email protected]_databases AS
Expand Down Expand Up @@ -75,7 +79,8 @@ CREATE VIEW @[email protected]_databases AS
, max_connections int
, current_connections int
, paused int
, disabled int);
, disabled int
);


CREATE VIEW @[email protected]_dns_hosts AS
Expand All @@ -85,7 +90,8 @@ CREATE VIEW @[email protected]_dns_hosts AS
FROM dblink('pgbouncer', 'show dns_hosts') AS x
( hostname text
, ttl bigint
, addrs text);
, addrs text
);


CREATE VIEW @[email protected]_dns_zones AS
Expand All @@ -95,24 +101,29 @@ CREATE VIEW @[email protected]_dns_zones AS
FROM dblink('pgbouncer', 'show dns_zones') AS x
( zonename text
, serial text
, count int);
, count int
);


CREATE VIEW @[email protected]_lists AS
SELECT list
, items
FROM dblink('pgbouncer', 'show lists') AS x
( list text
, items int);
, items int
);


CREATE VIEW @[email protected]_pools AS
SELECT database
, "user"
, cl_active
, cl_waiting
, cl_cancel_req
, cl_active_cancel_req
, cl_waiting_cancel_req
, sv_active
, sv_active_cancel
, sv_being_canceled
, sv_idle
, sv_used
, sv_tested
Expand All @@ -125,15 +136,19 @@ CREATE VIEW @[email protected]_pools AS
, "user" text
, cl_active int
, cl_waiting int
, cl_cancel_req int
, cl_active_cancel_req int
, cl_waiting_cancel_req int
, sv_active int
, sv_active_cancel int
, sv_being_canceled int
, sv_idle int
, sv_used int
, sv_tested int
, sv_login int
, maxwait int
, maxwait_us int
, pool_mode text);
, pool_mode text
);


CREATE VIEW @[email protected]_servers AS
Expand All @@ -154,6 +169,7 @@ CREATE VIEW @[email protected]_servers AS
, link
, remote_pid
, tls
, application_name
FROM dblink('pgbouncer', 'show servers') AS x
( type text
, "user" text
Expand All @@ -171,7 +187,9 @@ CREATE VIEW @[email protected]_servers AS
, ptr text
, link text
, remote_pid int
, tls text);
, tls text
, application_name text
);


CREATE VIEW @[email protected]_sockets AS
Expand All @@ -192,6 +210,7 @@ CREATE VIEW @[email protected]_sockets AS
, link
, remote_pid
, tls
, application_name
, recv_pos
, pkt_pos
, pkt_remain
Expand All @@ -217,13 +236,15 @@ CREATE VIEW @[email protected]_sockets AS
, link text
, remote_pid int
, tls text
, application_name text
, recv_pos int
, pkt_pos int
, pkt_remain int
, send_pos int
, send_remain int
, pkt_avail int
, send_avail int);
, send_avail int
);


CREATE VIEW @[email protected]_stats AS
Expand Down Expand Up @@ -257,12 +278,14 @@ CREATE VIEW @[email protected]_stats AS
, avg_sent bigint
, avg_xact_time bigint
, avg_query_time bigint
, avg_wait_time bigint );
, avg_wait_time bigint
);


CREATE VIEW @[email protected]_users AS
SELECT name
, pool_mode
FROM dblink('pgbouncer', 'show users') AS x
( name text
, pool_mode text);
, pool_mode text
);
Loading

0 comments on commit 27b3cab

Please sign in to comment.