mirror of https://github.com/citusdata/citus.git
pg16 update grant...inhereit,set and revoke
parent
1bfef9d5c5
commit
09a96e739d
|
@ -878,9 +878,19 @@ GenerateGrantRoleStmtsOfRole(Oid roleid)
|
||||||
if (membership->admin_option)
|
if (membership->admin_option)
|
||||||
{
|
{
|
||||||
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
DefElem *opt = makeDefElem("admin", (Node *) makeBoolean(true), -1);
|
||||||
DefElem *inherit_opt = makeDefElem("inherit", (Node *) makeBoolean(true), -1);
|
grantRoleStmt->opt = list_make1(opt);
|
||||||
DefElem *set_opt = makeDefElem("set", (Node *) makeBoolean(true), -1);
|
}
|
||||||
grantRoleStmt->opt = list_make3(opt, inherit_opt, set_opt);
|
|
||||||
|
if (membership->inherit_option)
|
||||||
|
{
|
||||||
|
DefElem *opt = makeDefElem("inherit", (Node *) makeBoolean(true), -1);
|
||||||
|
grantRoleStmt->opt = lappend(grantRoleStmt->opt, opt);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (membership->set_option)
|
||||||
|
{
|
||||||
|
DefElem *opt = makeDefElem("set", (Node *) makeBoolean(true), -1);
|
||||||
|
grantRoleStmt->opt = lappend(grantRoleStmt->opt, opt);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
grantRoleStmt->admin_opt = membership->admin_option;
|
grantRoleStmt->admin_opt = membership->admin_option;
|
||||||
|
|
|
@ -354,36 +354,26 @@ AppendGrantRoleStmt(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
if (!stmt->is_grant)
|
if (!stmt->is_grant)
|
||||||
{
|
{
|
||||||
DefElem *opt = NULL;
|
DefElem *opt = NULL;
|
||||||
int opt_count = 0 ;
|
|
||||||
foreach_ptr(opt, stmt->opt)
|
foreach_ptr(opt, stmt->opt)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch (opt->defname)
|
switch (opt->defname)
|
||||||
{
|
{
|
||||||
case "admin":
|
case "admin":
|
||||||
appendStringInfo(buf, "ADMIN OPTION FOR ");
|
appendStringInfo(buf, "ADMIN OPTION FOR ");
|
||||||
opt_count++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "inherit":
|
case "inherit":
|
||||||
if (opt_count > 0)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, ", ");
|
|
||||||
}
|
|
||||||
appendStringInfo(buf, "INHERIT OPTION FOR ");
|
appendStringInfo(buf, "INHERIT OPTION FOR ");
|
||||||
opt_count++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "set":
|
case "set":
|
||||||
if (opt_count > 0)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, ", ");
|
|
||||||
}
|
|
||||||
appendStringInfo(buf, "SET OPTION FOR ");
|
appendStringInfo(buf, "SET OPTION FOR ");
|
||||||
opt_count++;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (!stmt->is_grant && stmt->admin_opt)
|
if (!stmt->is_grant && stmt->admin_opt)
|
||||||
{
|
{
|
||||||
|
@ -412,22 +402,35 @@ AppendGrantRoleStmt(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "inherit":
|
case "inherit":
|
||||||
|
if (opt->arg && IsA(opt->arg, A_Const) && !((A_Const *) opt->arg)->val.val.ival)
|
||||||
|
{
|
||||||
|
appendStringInfo(buf, " INHERIT FALSE");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (opt_count > 0)
|
if (opt_count > 0)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, ", ");
|
appendStringInfo(buf, ", ");
|
||||||
}
|
}
|
||||||
appendStringInfo(buf, "INHERIT OPTION ");
|
appendStringInfo(buf, " INHERIT OPTION");
|
||||||
opt_count++;
|
opt_count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "set":
|
case "set":
|
||||||
|
if (opt->arg && IsA(opt->arg, A_Const) && !(( *) opt->arg)->val.val.ival)
|
||||||
|
{
|
||||||
|
appendStringInfo(buf, " SET FALSE");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if (opt_count > 0)
|
if (opt_count > 0)
|
||||||
{
|
{
|
||||||
appendStringInfo(buf, ", ");
|
appendStringInfo(buf, ", ");
|
||||||
}
|
}
|
||||||
appendStringInfo(buf, "SET OPTION ");
|
appendStringInfo(buf, " SET OPTION");
|
||||||
opt_count++;
|
opt_count++;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue