Skip to content

Commit 7be4a52

Browse files
committed
Allow publications FOR ALL TABLES to neon_superuser
1 parent 73eda3d commit 7be4a52

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backend/commands/publicationcmds.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,13 @@ CheckPubRelationColumnList(char *pubname, List *tables,
728728
}
729729
}
730730

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

757764
/* FOR ALL TABLES requires superuser */
758-
if (stmt->for_all_tables && !superuser())
765+
if (stmt->for_all_tables && !superuser() && !is_neon_superuser())
759766
ereport(ERROR,
760767
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
761768
errmsg("must be superuser to create FOR ALL TABLES publication")));
@@ -826,7 +833,7 @@ CreatePublication(ParseState *pstate, CreatePublicationStmt *stmt)
826833
&schemaidlist);
827834

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

0 commit comments

Comments
 (0)