Skip to content

Commit 03f2d7d

Browse files
committed
fix: update pgbouncer.get_auth
1 parent a4828c2 commit 03f2d7d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
-- migrate:up
2+
3+
create or replace function pgbouncer.get_auth(p_usename text) returns table (username text, password text)
4+
language plpgsql security definer
5+
as $$
6+
begin
7+
raise debug 'PgBouncer auth request: %', p_usename;
8+
9+
return query
10+
select
11+
rolname::text,
12+
case when rolvaliduntil < now()
13+
then null
14+
else rolpassword::text
15+
end
16+
from pg_authid
17+
where rolname=$1 and rolcanlogin;
18+
end;
19+
$$;
20+
21+
-- from migrations/db/migrations/20250312095419_pgbouncer_ownership.sql
22+
grant execute on function pgbouncer.get_auth(p_usename text) to postgres;
23+
24+
-- migrate:down

0 commit comments

Comments
 (0)