classShowProfile
final class ShowProfile
implements Statement
uses Snapshot
@visibility public.SHOW PROFILE: the stages of one profiled statement of the session and their resource use.
Rule: MYSQL-SHOW-PROFILE-001. The rows always have Status and Duration; each section written adds its columns, in the fixed order of the layout of MYSQL-SHOW-ROWS-001 whatever order the sections are written in, and a section written twice adds its columns once. FOR QUERY selects a statement of SHOW PROFILES, by default the last one. LIMIT selects rows as in SELECT; its operands are derived at a position that sees no relation. Terminates: a fixed layout. Source: https://dev.mysql.com/doc/refman/8.4/en/show-profile.html. Status: Implemented.
$show = (new \SqlSemantics\Platform\MySql\Semantics())->analyze('SHOW PROFILE SWAPS, CPU FOR QUERY 2');
[array_map(static fn (\SqlSemantics\Platform\MySql\Model\Statement\Shape\Field $field): ?string => $field->name?->value, iterator_to_array($show->fields())), $show->toString()] // => [['Status', 'Duration', 'CPU_user', 'CPU_system', 'Swaps'], 'SHOW PROFILE SWAPS, CPU FOR QUERY 2']Properties§
public list<ProfileSection> $sectionspublic Numeral|null $query = nullpublic Limit|null $limit = nullMethods§
public function __construct(
list<ProfileSection> $sections = [],
public Numeral|null $query = null,
public Limit|null $limit = null,
)Parameters
$sections | list<ProfileSection> | The sections in the order written |
$query | Numeral|null | The number of the statement after FOR QUERY |
$limit | Limit|null | The LIMIT clause |
Calls 2
- static-call Check::listOf() line 52
- class-const ProfileSection::class() line 52
public function deriveStatement(Derivation $derivation): voidDerives the rows of the sections written and the LIMIT operands.
Parameters
$derivation | Derivation |
Calls 9
- new ShowFacts line 60
- method-call ShowFacts::limit() line 61
- method-call ShowFacts::shape() line 62
- class-const Report::Profile() line 62
- function-call
ksortline 69 - function-call
array_keysline 71 - method-call Derivation::output() line 74
- method-call ShowFacts::query() line 74
- new RowShape line 74
public function render(Output $out): voidWrites the statement.
Parameters
$out | Output |
Calls 4
- method-call Output::keyword() line 82
- method-call Output::symbol() line 85
- function-call
explodeline 87 - method-call Output::node() line 92
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 2
- new SqlSemantics\Platform\MySql\Lowering\Utility\Show\LegacyShowRule::session() packages/sql-semantics-mysql/src/Lowering/Utility/Show/LegacyShowRule.php:99
- new SqlSemantics\Platform\MySql\Lowering\Utility\Show\ShowRule::statement() packages/sql-semantics-mysql/src/Lowering/Utility/Show/ShowRule.php:70