classShowKeys
final class ShowKeys
implements Statement, Relation
uses Snapshot
@visibility public.SHOW INDEX (SHOW INDEXES, SHOW KEYS): the index parts of a table.
Rule: MYSQL-SHOW-KEYS-001. The table resolves by MYSQL-SHOW-TARGET-001; a database written after it replaces the one written with the table name. EXTENDED, from MySQL 8.0 on, also lists hidden index parts. INDEX, INDEXES and KEYS are the same keyword (LeafNoise); the writer emits INDEXES. Only WHERE filters the rows. The rows and the WHERE condition are derived by MYSQL-SHOW-FACTS-001 from the layout of MYSQL-SHOW-ROWS-001. Terminates: a fixed layout. Source: https://dev.mysql.com/doc/refman/8.4/en/show-index.html. Status: Implemented.
$show = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SHOW KEYS FROM t WHERE Key_name = 'PRIMARY'");
[$show->facts->scalar($show->statement->filter->condition->left)->resolution->slot->name?->value, $show->toString()] // => ['Key_name', "SHOW INDEXES FROM t WHERE Key_name = 'PRIMARY'"]Properties§
public InspectedTable $tablepublic bool $extended = falsepublic ?Name $database = nullpublic ?ShowWhere $filter = nullMethods§
public function __construct(
public InspectedTable $table,
public bool $extended = false,
public ?Name $database = null,
public ?ShowWhere $filter = null,
)Parameters
$table | InspectedTable | The table |
$extended | bool | Whether EXTENDED is written |
$database | ?Name | The database written after FROM or IN; null for the current database |
$filter | ?ShowWhere | The WHERE clause |
public function deriveStatement(Derivation $derivation): voidDerives the rows and the filter.
Parameters
$derivation | Derivation |
Calls 4
- method-call ShowTargets::derive() line 59
- new ShowTargets line 59
- method-call ShowFacts::derive() line 60
- new ShowFacts line 60
public function deriveRelation(Derivation $derivation, Environment $environment): RelationFactDerives the result columns.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 3
- method-call ShowFacts::fact() line 68
- new ShowFacts line 68
- class-const Report::Keys() line 68
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 3
- method-call Output::keyword() line 76
- class-const NameUse::Qualifier() line 82
- method-call Output::node() line 84
Test cases 2§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 2
- new SqlSemantics\Platform\MySql\Lowering\Utility\Show\LegacyObjectRule::keys() packages/sql-semantics-mysql/src/Lowering/Utility/Show/LegacyObjectRule.php:169
- new SqlSemantics\Platform\MySql\Lowering\Utility\Show\ObjectRule::statement() packages/sql-semantics-mysql/src/Lowering/Utility/Show/ObjectRule.php:84