classSelectFacts
final class SelectFacts
Derives the facts of a query block.
Rule: MYSQL-SELECT-FACTS-001. The FROM clause is derived in the enclosing environment (MYSQL-FROM-SCOPE-001). The select list sees the FROM tables and, beyond them, the enclosing queries; it does not see its own aliases. WHERE sees the FROM tables. GROUP BY, QUALIFY and ORDER BY also see the aliases of the select list (MYSQL-SORT-SCOPE-001); HAVING sees the GROUP BY columns and the select list first (MYSQL-HAVING-SCOPE-001). The named windows see the FROM tables. In a block that aggregates without GROUP BY (MYSQL-AGGREGATE-QUERY-001; HAVING alone filters rows like WHERE) or groups WITH ROLLUP, ROLLUP or CUBE, every column of the FROM tables read by the select list, HAVING, the windows, QUALIFY and ORDER BY can be NULL. LIMIT, PROCEDURE ANALYSE, INTO and the locking clauses follow MYSQL-TAIL-FACTS-001; a late ordering is derived like the ORDER BY and LIMIT of the block. A window name defined twice is reported, and so is a window name the block does not define (MYSQL-WINDOW-NAME-001). The output fields follow MYSQL-STAR-001. Terminates: every clause is a strict part of the block. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html, https://dev.mysql.com/doc/refman/8.4/en/group-by-modifiers.html ("the super-aggregate rows ... NULL"). Status: Implemented.
Methods§
public function derive(Select $select, Derivation $derivation, Environment $outer): QueryFactDerives every part of the block and answers its output.
Parameters
$select | Select | |
$derivation | Derivation | |
$outer | Environment |
Returns
Called from 1
Calls 35
- new JoinedInput line 61
- new RelationFact line 61
- new RowShape line 61
- method-call FromScope::open() line 61
- new FromScope line 61
- function-call
array_mapline 63 - method-call Aggregation::aggregates() line 65
- new Aggregation line 65
- function-call
array_valuesline 65 - function-call
array_filterline 65 - method-call Joining::extend() line 66
- new Joining line 66
- method-call Projection::items() line 67
- new Projection line 67
- new Environment line 67
- method-call SelectFacts::aliases() line 68
- method-call Operands::single() line 70
- new Operands line 70
- method-call Derivation::scalar() line 70
- method-call SortScopes::derive() line 72
- new SortScopes line 72
- new HavingScope line 75
- new GroupedRow line 76
- method-call HavingScope::grouping() line 76
- function-call
in_arrayline 76 - class-const SelectOption::Distinct() line 76
- method-call HavingScope::undecided() line 76
- method-call HavingScope::enter() line 77
- method-call SelectFacts::windows() line 79
- method-call WindowReferences::check() line 80
- new WindowReferences line 80
- method-call TailFacts::limit() line 85
- new TailFacts line 85
- new QueryFact line 90
- method-call TailFacts::derive() line 91
public function windows(Select $select, Derivation $derivation, Environment $environment): voidDerives the named windows and reports a name defined twice.
Parameters
$select | Select | |
$derivation | Derivation | |
$environment | Environment |
Called from 1
Calls 3
- method-call Derivation::report() line 106
- new Misuse line 106
- class-const MisuseRule::DuplicateWindow() line 106
public function aliases(
Select $select,
list<Field|OpenStar> $items,
LanguageProfile $profile,
): list<Field>Answers the output fields a name can refer to by their item name, in output order: aliased items and the items not named after a column.
The server finds an item of the select list by its name, alias or name given after its text alike, unless the item is a column reference, which is found as the column it reads.
Parameters
$select | Select | |
$items | list<Field|OpenStar> | |
$profile | LanguageProfile |
Returns
list<Field>Called from 1
Calls 3
- new ItemNaming line 125
- method-call ItemNaming::own() line 127
- function-call
spl_object_idline 128
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.