File tree Expand file tree Collapse file tree 5 files changed +66
-26
lines changed
files/postgresql_extension_custom_scripts/postgres_fdw Expand file tree Collapse file tree 5 files changed +66
-26
lines changed Original file line number Diff line number Diff line change 1- do $$
2- declare
3- is_super boolean ;
4- begin
5- is_super = (
6- select usesuper
7- from pg_user
8- where usename = ' postgres'
9- );
10-
11- -- Need to be superuser to own FDWs, so we temporarily make postgres superuser.
12- if not is_super then
13- alter role postgres superuser;
14- end if;
15-
16- alter foreign data wrapper postgres_fdw owner to postgres;
17-
18- if not is_super then
19- alter role postgres nosuperuser;
20- end if;
21- end $$;
1+ grant usage on foreign data wrapper postgres_fdw to postgres with grant option;
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ postgres_major:
1010
1111# Full version strings for each major version
1212postgres_release :
13- postgresorioledb-17 : " 17.5.1.043 -orioledb"
14- postgres17 : " 17.6.1.022 "
15- postgres15 : " 15.14.1.022 "
13+ postgresorioledb-17 : " 17.5.1.044 -orioledb"
14+ postgres17 : " 17.6.1.023 "
15+ postgres15 : " 15.14.1.023 "
1616
1717# Non Postgres Extensions
1818pgbouncer_release : 1.24.1
Original file line number Diff line number Diff line change 77
88stdenv . mkDerivation rec {
99 pname = "supautils" ;
10- version = "2.9.4 " ;
10+ version = "3.0.0 " ;
1111
1212 buildInputs = [ postgresql ] ;
1313
1414 src = fetchFromGitHub {
1515 owner = "supabase" ;
1616 repo = pname ;
1717 rev = "refs/tags/v${ version } " ;
18- hash = "sha256-qP9fOEWXw+wY49GopTizwxSBEGS0UoseJHVBtKS/BdI =" ;
18+ hash = "sha256-EKKjNZQf7HwP/MxpHoPtbEtwXk+wO241GoXVcXpDMFs =" ;
1919 } ;
2020
2121 installPhase = ''
Original file line number Diff line number Diff line change 1+ /*
2+
3+ Test to verify supautils (v3.0.0+) allows non-superuser postgres role to use postgres_fdw.
4+
5+ This test ensures that the supautils extension properly handles FDW usage
6+ for the privileged postgres role without requiring temporary superuser privileges.
7+
8+ This verifies the fix that eliminated the need for:
9+ https://github.com/supabase/postgres/blob/a638c6fce0baf90b654e762eddcdac1bc8df01ee/ansible/files/postgresql_extension_custom_scripts/postgres_fdw/after-create.sql (removed)
10+
11+ */
12+ begin;
13+ -- Switch to the postgres role (non-superuser) to test supautils behavior
14+ set role postgres;
15+ -- postgres_fdw should be owned by the superuser
16+ select fdwowner::regrole from pg_foreign_data_wrapper where fdwname = 'postgres_fdw';
17+ fdwowner
18+ ----------------
19+ supabase_admin
20+ (1 row)
21+
22+ -- Verify that `postgres` can use the FDW despite not owning it
23+ create server s
24+ foreign data wrapper postgres_fdw
25+ options (
26+ host '127.0.0.1',
27+ port '5432',
28+ dbname 'postgres'
29+ );
30+ rollback;
Original file line number Diff line number Diff line change 1+ /*
2+
3+ Test to verify supautils (v3.0.0+) allows non-superuser postgres role to use postgres_fdw.
4+
5+ This test ensures that the supautils extension properly handles FDW usage
6+ for the privileged postgres role without requiring temporary superuser privileges.
7+
8+ This verifies the fix that eliminated the need for:
9+ https://github.com/supabase/postgres/blob/a638c6fce0baf90b654e762eddcdac1bc8df01ee/ansible/files/postgresql_extension_custom_scripts/postgres_fdw/after-create.sql (removed)
10+
11+ */
12+
13+ begin ;
14+
15+ -- Switch to the postgres role (non-superuser) to test supautils behavior
16+ set role postgres;
17+
18+ -- postgres_fdw should be owned by the superuser
19+ select fdwowner::regrole from pg_foreign_data_wrapper where fdwname = ' postgres_fdw' ;
20+
21+ -- Verify that `postgres` can use the FDW despite not owning it
22+ create server s
23+ foreign data wrapper postgres_fdw
24+ options (
25+ host ' 127.0.0.1' ,
26+ port ' 5432' ,
27+ dbname ' postgres'
28+ );
29+
30+ rollback ;
You can’t perform that action at this time.
0 commit comments