classDrop
final class Drop
implements Statement
uses Snapshot
@visibility public.DROP kind [IF EXISTS] object, ... [CASCADE | RESTRICT]: removes catalog objects of one kind.
Mirrors PostgreSQL's DropStmt (removeType, objects, behavior, missing_ok, concurrent), which also represents DROP FUNCTION, AGGREGATE, OPERATOR, OPERATOR CLASS and FAMILY, CAST and TRANSFORM. How the objects are named depends on the kind exactly as the grammar writes it (PG-OBJECT-FORM-001). A dropped relation is resolved; dropping changes no declaration of the context. Source: https://www.postgresql.org/docs/17/sql-droptable.html, https://www.postgresql.org/docs/17/sql-dropfunction.html.
$operation = (new \SqlSemantics\Platform\PostgreSql\Semantics())->analyze('DROP TABLE IF EXISTS a, b CASCADE');
[$operation->statement->kind->value, count($operation->statement->objects), $operation->statement->ifExists] // => ['TABLE', 2, true]Properties§
public non-empty-list<ObjectReference> $objectspublic ObjectKind $kindpublic bool $ifExists = falsepublic DropBehavior|null $behavior = nullpublic bool $concurrently = falseMethods§
public function __construct(
public ObjectKind $kind,
list<ObjectReference> $objects,
public bool $ifExists = false,
public DropBehavior|null $behavior = null,
public bool $concurrently = false,
)Parameters
$kind | ObjectKind | The kind of the objects |
$objects | list<ObjectReference> | The objects, named as DROP names objects of the kind; one only for the kinds named within a table, operator classes and families, casts and transforms |
$ifExists | bool | Whether IF EXISTS is written |
$behavior | DropBehavior|null | CASCADE or RESTRICT, if written |
$concurrently | bool | Whether CONCURRENTLY is written; for indexes only |
Calls 10
- static-call Check::listOf() line 61
- class-const ObjectReference::class() line 61
- new ObjectForms line 62
- static-call Check::input() line 64
- function-call
in_arrayline 64 - method-call ObjectForms::form() line 64
- method-call ObjectForms::drop() line 64
- function-call
countline 66 - class-const ObjectForms::SINGLE_DROP() line 66
- class-const ObjectKind::Index() line 67
public function deriveStatement(Derivation $derivation): voidDerives the objects and reports concurrent drops the server rejects.
Parameters
$derivation | Derivation |
Calls 10
- method-call ObjectFacts::derive() line 75
- new ObjectFacts line 75
- method-call RelationKinds::named() line 76
- new RelationKinds line 76
- function-call
countline 77 - method-call Derivation::report() line 78
- new ObjectProblem line 78
- class-const ObjectProblemKind::ConcurrentMultiple() line 78
- class-const DropBehavior::Cascade() line 80
- class-const ObjectProblemKind::ConcurrentCascade() line 81
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 90
- method-call ObjectSpelling::kind() line 91
- new ObjectSpelling line 91
- method-call Output::list() line 98
Test cases 10§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 5
Other tests reaching this symbol 5
Relations§
Instantiated in 5
- new SqlSemantics\Platform\PostgreSql\Lowering\Catalog\CastRule::statement() packages/sql-semantics-postgres/src/Lowering/Catalog/CastRule.php:72
- new SqlSemantics\Platform\PostgreSql\Lowering\Catalog\CastRule::statement() packages/sql-semantics-postgres/src/Lowering/Catalog/CastRule.php:74
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\DropRule::drop() packages/sql-semantics-postgres/src/Lowering/Routine/DropRule.php:72
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\DropRule::drop() packages/sql-semantics-postgres/src/Lowering/Routine/DropRule.php:75
- new SqlSemantics\Platform\PostgreSql\Lowering\Routine\DropRule::generic() packages/sql-semantics-postgres/src/Lowering/Routine/DropRule.php:118