mirror of https://github.com/citusdata/citus.git
Fix WITH ADMIN FALSE propagation (#7191)
parent
0fb471e7c5
commit
30b397840b
|
@ -453,34 +453,16 @@ AppendGrantWithAdminOption(StringInfo buf, GrantRoleStmt *stmt)
|
||||||
int opt_count = 0;
|
int opt_count = 0;
|
||||||
foreach_ptr(opt, stmt->opt)
|
foreach_ptr(opt, stmt->opt)
|
||||||
{
|
{
|
||||||
switch (opt->defname)
|
bool admin_option = false;
|
||||||
{
|
char *optval = defGetString(opt);
|
||||||
case "admin":
|
if (strcmp(opt->defname, "admin") == 0 &&
|
||||||
appendStringInfo(buf, " WITH ADMIN OPTION");
|
parse_bool(optval, &admin_option) && admin_option)
|
||||||
opt_count++;
|
{
|
||||||
break;
|
appendStringInfo(buf, " WITH ADMIN OPTION");
|
||||||
|
|
||||||
case "inherit":
|
|
||||||
if (opt_count > 0)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, ", ");
|
|
||||||
}
|
|
||||||
appendStringInfo(buf, "INHERIT OPTION ");
|
|
||||||
opt_count++;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case "set":
|
|
||||||
if (opt_count > 0)
|
|
||||||
{
|
|
||||||
appendStringInfo(buf, ", ");
|
|
||||||
}
|
|
||||||
appendStringInfo(buf, "SET OPTION ");
|
|
||||||
opt_count++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (stmt->admin_opt)
|
if (stmt->admin_opt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -732,6 +732,32 @@ SELECT roleid::regrole::text AS role, member::regrole::text, admin_option, inher
|
||||||
|
|
||||||
DROP ROLE role3, role4, role5;
|
DROP ROLE role3, role4, role5;
|
||||||
|
|
||||||
|
--
|
||||||
|
-- PG16 added WITH ADMIN FALSE option to GRANT ROLE
|
||||||
|
-- WITH ADMIN FALSE is the default, make sure we propagate correctly in Citus
|
||||||
|
-- Relevant PG commit: https://github.com/postgres/postgres/commit/e3ce2de
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE ROLE role1;
|
||||||
|
CREATE ROLE role2;
|
||||||
|
|
||||||
|
SET citus.log_remote_commands TO on;
|
||||||
|
SET citus.grep_remote_commands = '%GRANT%';
|
||||||
|
-- default admin option is false
|
||||||
|
GRANT role1 TO role2;
|
||||||
|
REVOKE role1 FROM role2;
|
||||||
|
-- should behave same as default
|
||||||
|
GRANT role1 TO role2 WITH ADMIN FALSE;
|
||||||
|
REVOKE role1 FROM role2;
|
||||||
|
-- with admin option and with admin true are the same
|
||||||
|
GRANT role1 TO role2 WITH ADMIN OPTION;
|
||||||
|
REVOKE role1 FROM role2;
|
||||||
|
GRANT role1 TO role2 WITH ADMIN TRUE;
|
||||||
|
REVOKE role1 FROM role2;
|
||||||
|
|
||||||
|
RESET citus.log_remote_commands;
|
||||||
|
RESET citus.grep_remote_commands;
|
||||||
|
|
||||||
\set VERBOSITY terse
|
\set VERBOSITY terse
|
||||||
SET client_min_messages TO ERROR;
|
SET client_min_messages TO ERROR;
|
||||||
DROP EXTENSION postgres_fdw CASCADE;
|
DROP EXTENSION postgres_fdw CASCADE;
|
||||||
|
|
Loading…
Reference in New Issue