final class AlterPolicy
    implements Statement, Relation
    uses Snapshot
Public API: explicitly declared with @visibility public.

A request to change the roles or conditions of a row security policy.

Mirrors PostgreSQL's AlterPolicyStmt. The table is resolved and is the relation fact of the statement; the conditions are derived as in CREATE POLICY (PG-POLICY-001). Source: https://www.postgresql.org/docs/17/sql-alterpolicy.html.

Changing a policydoctest
$statement = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('ALTER POLICY p ON t TO PUBLIC USING (true)');
    $statement->toString() // => 'ALTER POLICY p ON t TO public USING (TRUE)'

Properties§

public list<RoleSpec> $roles
public Name $name
public QualifiedName $table
public Scalar|null $using = null
public Scalar|null $check = null

Methods§

public function __construct(
    public Name $name,
    public QualifiedName $table,
    list<RoleSpec> $roles = [],
    public Scalar|null $using = null,
    public Scalar|null $check = null,
)

Parameters

$nameNameThe policy name
$tableQualifiedNameThe table
$roleslist<RoleSpec>The new roles; none keeps them
$usingScalar|nullThe new USING condition
$checkScalar|nullThe new WITH CHECK condition
Calls 2
public function deriveStatement(Derivation $derivation): void

Resolves the table and derives the conditions.

Parameters

$derivationDerivation
Calls 2
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFact

Resolves the table and answers its facts.

Parameters

$derivationDerivation
$environmentEnvironment
Calls 2
public function render(Output $out): void

Writes the statement.

Parameters

$outOutput
Calls 5

Test cases 1§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 1

Relations§

Instantiated in 1
Type declarations 1