classRelationKinds
final class RelationKinds
Decides what a statement does with a name by the kind of relation its declaration is.
Rule: MYSQL-RELATION-KIND-001. A CREATE VIEW declares a view; every other declaration MySQL provides is a base table. Where a statement needs a base table (ALTER TABLE, CREATE INDEX, CREATE TRIGGER, CREATE TABLE ... LIKE, HANDLER ... OPEN) a declared view is refused with ER_WRONG_OBJECT ("is
- not BASE TABLE"); where it needs a view (ALTER VIEW, CREATE OR REPLACE
VIEW, SHOW CREATE VIEW, DROP VIEW) a declared base table is refused with ER_WRONG_OBJECT ("is not VIEW"). DROP TABLE does not find a view (ER_BAD_TABLE_ERROR, a note under IF EXISTS), nor does TRUNCATE TABLE (ER_NO_SUCH_TABLE). DROP VIEW IF EXISTS of a base table is refused in 8.1, 8.2, 8.3, 9.0 and 9.1 and only noted in the other releases. A declaration of a kind MySQL does not have (a materialized view, a foreign table, a sequence) decides nothing. Verified on live servers of each release. Source: https://dev.mysql.com/doc/refman/8.4/en/drop-view.html, https://dev.mysql.com/doc/refman/8.4/en/drop-table.html, https://dev.mysql.com/doc/refman/8.4/en/create-view.html, https://dev.mysql.com/doc/refman/8.4/en/show-create-table.html, https://dev.mysql.com/doc/mysql-errors/8.4/en/server-error-reference.html. Status: Implemented.
Methods§
public function kind(?TableResolution $resolution): ?RelationKindAnswers the kind a resolution decides: BaseTable or View for a declaration of that kind, else null.
Parameters
$resolution | ?TableResolution |
Returns
Test cases 1
Called from 3
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\RelationKinds::require() packages/sql-semantics-mysql/src/Rules/TableDefinition/RelationKinds.php:60
- method-call SqlSemantics\Platform\MySql\Rules\TableDefinition\RelationKinds::refuseView() packages/sql-semantics-mysql/src/Rules/TableDefinition/RelationKinds.php:71
- method-call SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateTable.php:58
Calls 3
- function-call
in_arrayline 50 - class-const RelationKind::BaseTable() line 50
- class-const RelationKind::View() line 50
public function require(
Derivation $derivation,
QualifiedName $name,
?TableResolution $resolution,
RelationKind $needed,
): voidReports a refusal when a name the statement needs as one kind resolves to a declaration of the other.
Parameters
$derivation | Derivation | |
$name | QualifiedName | |
$resolution | ?TableResolution | |
$needed | RelationKind | BaseTable or View |
Test cases 1
Called from 9
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:94
- method-call SqlSemantics\Platform\MySql\Statement\Alter\AlterTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/AlterTable.php:88
- method-call SqlSemantics\Platform\MySql\Statement\Dml\Handler\HandlerOpen::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Handler/HandlerOpen.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateIndex::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateIndex.php:102
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateTableLike::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTableLike.php:65
- method-call SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateView.php:48
- method-call SqlSemantics\Platform\MySql\Statement\View\AlterView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/AlterView.php:48
- method-call SqlSemantics\Platform\MySql\Statement\View\CreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/CreateView.php:51
- method-call SqlSemantics\Platform\MySql\Statement\View\DropView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/DropView.php:74
Calls 6
- method-call RelationKinds::kind() line 60
- method-call Derivation::report() line 62
- new WrongRelationKind line 62
- class-const RelationKind::View() line 62
- class-const KindRefusal::NotView() line 62
- class-const KindRefusal::NotBaseTable() line 62
public function refuseView(
Derivation $derivation,
QualifiedName $name,
?TableResolution $resolution,
KindRefusal $refusal,
): voidReports a refusal when a name resolves to a declared view, with what the statement reports.
Parameters
$derivation | Derivation | |
$name | QualifiedName | |
$resolution | ?TableResolution | |
$refusal | KindRefusal |
Test cases 1
Called from 2
- method-call SqlSemantics\Platform\MySql\Statement\Alter\DropTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/DropTable.php:68
- method-call SqlSemantics\Platform\MySql\Statement\Alter\TruncateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/TruncateTable.php:52
Calls 4
- method-call RelationKinds::kind() line 71
- class-const RelationKind::View() line 71
- method-call Derivation::report() line 72
- new WrongRelationKind line 72
Test cases 3§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 12
- new SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:94
- new SqlSemantics\Platform\MySql\Statement\Alter\AlterTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/AlterTable.php:88
- new SqlSemantics\Platform\MySql\Statement\Alter\DropTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/DropTable.php:68
- new SqlSemantics\Platform\MySql\Statement\Alter\TruncateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/TruncateTable.php:52
- new SqlSemantics\Platform\MySql\Statement\Dml\Handler\HandlerOpen::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Handler/HandlerOpen.php:55
- new SqlSemantics\Platform\MySql\Statement\Table\CreateIndex::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateIndex.php:102
- new SqlSemantics\Platform\MySql\Statement\Table\CreateTableLike::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTableLike.php:65
- new SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateTable.php:58
- new SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateView.php:48
- new SqlSemantics\Platform\MySql\Statement\View\AlterView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/AlterView.php:48
- new SqlSemantics\Platform\MySql\Statement\View\CreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/CreateView.php:51
- new SqlSemantics\Platform\MySql\Statement\View\DropView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/DropView.php:66
Method calls 12
- method-call SqlSemantics\Platform\MySql\Rules\Routine\ProgramFacts::trigger() packages/sql-semantics-mysql/src/Rules/Routine/ProgramFacts.php:94
- method-call SqlSemantics\Platform\MySql\Statement\Alter\AlterTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/AlterTable.php:88
- method-call SqlSemantics\Platform\MySql\Statement\Alter\DropTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/DropTable.php:68
- method-call SqlSemantics\Platform\MySql\Statement\Alter\TruncateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Alter/TruncateTable.php:52
- method-call SqlSemantics\Platform\MySql\Statement\Dml\Handler\HandlerOpen::deriveStatement() packages/sql-semantics-mysql/src/Statement/Dml/Handler/HandlerOpen.php:55
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateIndex::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateIndex.php:102
- method-call SqlSemantics\Platform\MySql\Statement\Table\CreateTableLike::deriveStatement() packages/sql-semantics-mysql/src/Statement/Table/CreateTableLike.php:65
- method-call SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateTable::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateTable.php:58
- method-call SqlSemantics\Platform\MySql\Statement\Utility\Show\Schema\ShowCreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/Utility/Show/Schema/ShowCreateView.php:48
- method-call SqlSemantics\Platform\MySql\Statement\View\AlterView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/AlterView.php:48
- method-call SqlSemantics\Platform\MySql\Statement\View\CreateView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/CreateView.php:51
- method-call SqlSemantics\Platform\MySql\Statement\View\DropView::deriveStatement() packages/sql-semantics-mysql/src/Statement/View/DropView.php:74