mirror of https://github.com/citusdata/citus.git
Fix with admin option in grants
grantstmt->admin_opt no longer exists in PG16
instead, grantstmt has a list of options, one of them is admin option.
Relevant PG commit:
e3ce2de09d
e3ce2de09d814f8770b2e3b3c152b7671bcdb83f
onder_pg16_outer_crash
parent
4ac02d0fbd
commit
e71d642965
|
@ -819,12 +819,15 @@ GenerateGrantRoleStmtsFromOptions(RoleSpec *roleSpec, List *options)
|
|||
grantRoleStmt->grantee_roles = list_make1(roleSpec);
|
||||
}
|
||||
|
||||
#if PG_VERSION_NUM < PG_VERSION_16
|
||||
if (strcmp(option->defname, "adminmembers") == 0)
|
||||
{
|
||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
||||
grantRoleStmt->opt = list_make1(opt);
|
||||
#else
|
||||
grantRoleStmt->admin_opt = true;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
stmts = lappend(stmts, grantRoleStmt);
|
||||
}
|
||||
|
@ -871,7 +874,13 @@ GenerateGrantRoleStmtsOfRole(Oid roleid)
|
|||
|
||||
grantRoleStmt->grantor = NULL;
|
||||
|
||||
#if PG_VERSION_NUM < PG_VERSION_16
|
||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||
if (membership->admin_option)
|
||||
{
|
||||
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
||||
grantRoleStmt->opt = list_make1(opt);
|
||||
}
|
||||
#else
|
||||
grantRoleStmt->admin_opt = membership->admin_option;
|
||||
#endif
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include "distributed/citus_ruleutils.h"
|
||||
#include "distributed/deparser.h"
|
||||
#include "distributed/listutils.h"
|
||||
#include "lib/stringinfo.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "utils/builtins.h"
|
||||
|
@ -349,7 +350,20 @@ AppendGrantRoleStmt(StringInfo buf, GrantRoleStmt *stmt)
|
|||
{
|
||||
appendStringInfo(buf, "%s ", stmt->is_grant ? "GRANT" : "REVOKE");
|
||||
|
||||
#if PG_VERSION_NUM < PG_VERSION_16
|
||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||
if (!stmt->is_grant)
|
||||
{
|
||||
DefElem *opt = NULL;
|
||||
foreach_ptr(opt, stmt->opt)
|
||||
{
|
||||
if (strcmp(opt->defname, "admin") == 0)
|
||||
{
|
||||
appendStringInfo(buf, "ADMIN OPTION FOR ");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (!stmt->is_grant && stmt->admin_opt)
|
||||
{
|
||||
appendStringInfo(buf, "ADMIN OPTION FOR ");
|
||||
|
@ -364,7 +378,17 @@ AppendGrantRoleStmt(StringInfo buf, GrantRoleStmt *stmt)
|
|||
|
||||
if (stmt->is_grant)
|
||||
{
|
||||
#if PG_VERSION_NUM < PG_VERSION_16
|
||||
#if PG_VERSION_NUM >= PG_VERSION_16
|
||||
DefElem *opt = NULL;
|
||||
foreach_ptr(opt, stmt->opt)
|
||||
{
|
||||
if (strcmp(opt->defname, "admin") == 0)
|
||||
{
|
||||
appendStringInfo(buf, " WITH ADMIN OPTION");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (stmt->admin_opt)
|
||||
{
|
||||
appendStringInfo(buf, " WITH ADMIN OPTION");
|
||||
|
|
Loading…
Reference in New Issue