Skip to content

Commit ddc8656

Browse files
za-arthursteve-chavez
authored andcommitted
fix: make superuser option of AlterRoleStmt boolean
Postgres expect that the option is a boolean value. Otherwise it crashes on a development environment with enabled asserts.
1 parent d70da91 commit ddc8656

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/utils.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,17 @@ static void alter_role_super(const char* rolename, bool make_super){
9090
AlterRoleStmt *alter_stmt = makeNode(AlterRoleStmt);
9191
alter_stmt->role = rolespec;
9292

93+
#if PG15_GTE
9394
alter_stmt->options = list_make1(
94-
makeDefElem("superuser", (Node *) makeInteger(make_super), -1) // using makeInteger because makeBoolean is not available on pg <= 14
95+
makeDefElem("superuser", (Node *) makeBoolean(make_super), -1)
9596
);
9697

97-
#if PG15_GTE
9898
AlterRole(NULL, alter_stmt);
9999
#else
100+
alter_stmt->options = list_make1(
101+
makeDefElem("superuser", (Node *) makeInteger(make_super), -1)
102+
);
103+
100104
AlterRole(alter_stmt);
101105
#endif
102106

0 commit comments

Comments
 (0)