Skip to content

Commit c1c2272

Browse files
committed
Allow publications FOR ALL TABLES to neon_superuser
1 parent d1d3c6a commit c1c2272

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backend/commands/publicationcmds.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -727,6 +727,13 @@ CheckPubRelationColumnList(char *pubname, List *tables,
727727
}
728728
}
729729

730+
static bool
731+
is_neon_superuser(void)
732+
{
733+
Oid neon_superuser_oid = get_role_oid("neon_superuser", true /*missing_ok*/);
734+
return neon_superuser_oid != InvalidOid && has_privs_of_role(GetCurrentRoleId(), neon_superuser_oid);
735+
}
736+
730737
/*
731738
* Create new publication.
732739
*/
@@ -754,7 +761,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
754761
get_database_name(MyDatabaseId));
755762

756763
/* FOR ALL TABLES requires superuser */
757-
if (stmt->for_all_tables && !superuser())
764+
if (stmt->for_all_tables && !superuser() && !is_neon_superuser())
758765
ereport(ERROR,
759766
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
760767
errmsg("must be superuser to create FOR ALL TABLES publication")));
@@ -825,7 +832,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
825832
&schemaidlist);
826833

827834
/* FOR TABLES IN SCHEMA requires superuser */
828-
if (schemaidlist != NIL && !superuser())
835+
if (schemaidlist != NIL && !superuser() && !is_neon_superuser())
829836
ereport(ERROR,
830837
errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
831838
errmsg("must be superuser to create FOR TABLES IN SCHEMA publication"));

0 commit comments

Comments
 (0)