Skip to content

Commit 19e14d1

Browse files
harinathharinath
authored andcommitted
Make extension-owner as the owner of schema repack,
and grant access to tables, functions in schema repack. This will ensure that the extension can be installed as trusted extension, and non-superusers can create and use the extension, without superuser/DBA help.
1 parent 9f36c65 commit 19e14d1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

lib/pg_repack.sql.in

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,3 +380,19 @@ LANGUAGE C STABLE STRICT;
380380
CREATE FUNCTION repack.get_table_and_inheritors(regclass) RETURNS regclass[] AS
381381
'MODULE_PATHNAME', 'repack_get_table_and_inheritors'
382382
LANGUAGE C STABLE STRICT;
383+
384+
DO $$
385+
DECLARE
386+
pg_version_num TEXT;
387+
major_version INT;
388+
BEGIN
389+
-- Get the pg version
390+
SELECT split_part(current_setting('server_version'), '.', 1) INTO pg_version_num;
391+
major_version := pg_version_num::INT;
392+
393+
IF major_version > 12 THEN
394+
ALTER SCHEMA repack OWNER TO @extowner@;
395+
GRANT ALL PRIVILEGES ON ALL FUNCTIONS IN SCHEMA repack TO @extowner@;
396+
GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA repack TO @extowner@;
397+
END IF;
398+
END $$;

0 commit comments

Comments
 (0)