classGrantRole
final class GrantRole
implements Statement
uses Snapshot
Public API: explicitly declared with
@visibility public.A request to make roles members of other roles.
Rule: PG-GRANT-ROLE-001. Mirrors GrantRoleStmt with is_grant: the granted roles, the member roles, the membership options of WITH and GRANTED BY. The grammar reads the granted roles as a privilege list, so a granted role may carry a column list or be spelled with a privilege keyword; a column list is reported, as are an option name the server does not recognize and PUBLIC as a granted role, member or grantor (PG-MEMBERSHIP-CHECK-001). Source: https://www.postgresql.org/docs/17/sql-grant.html#SQL-GRANT-DESCRIPTION-ROLES. Status: Implemented.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('GRANT staff TO joe WITH ADMIN OPTION GRANTED BY boss');
[$operation->statement->roles[0]->privilege(), $operation->statement->options[0]->setting->value, $operation->statement->grantor?->name?->value] // => ['staff', 'OPTION', 'boss']Properties§
public non-empty-list<Privilege> $rolespublic non-empty-list<RoleSpec> $memberspublic list<MembershipOption> $optionspublic RoleSpec|null $grantor = nullMethods§
public function __construct(
list<Privilege> $roles,
list<RoleSpec> $members,
list<MembershipOption> $options = [],
public RoleSpec|null $grantor = null,
)Parameters
$roles | list<Privilege> | The granted roles in the order written, at least one |
$members | list<RoleSpec> | The roles that become members, at least one |
$options | list<MembershipOption> | The options of WITH in the order written |
$grantor | RoleSpec|null | The role of GRANTED BY, when written |
Calls 5
- method-call PrivilegeLists::roles() line 60
- new PrivilegeLists line 60
- static-call Check::listOf() line 61
- class-const RoleSpec::class() line 61
- class-const MembershipOption::class() line 62
public function deriveStatement(Derivation $derivation): voidReports the problems of the roles and of the options.
Parameters
$derivation | Derivation |
Calls 3
- new MembershipChecks line 70
- method-call MembershipChecks::roles() line 71
- method-call MembershipChecks::option() line 74
public function render(Output $out): voidTest cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 3
Other tests reaching this symbol 1
Relations§
Instantiated in 2
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\MembershipRule::statement() packages/sql-semantics-postgres/src/Lowering/Access/MembershipRule.php:60
- new SqlSemantics\Platform\PostgreSql\Lowering\Access\MembershipRule::statement() packages/sql-semantics-postgres/src/Lowering/Access/MembershipRule.php:61