final class HavingScope
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

Builds the environment of a HAVING clause, and the environment of the set functions written in it.

Rule: MYSQL-HAVING-SCOPE-001. The parser reads a column name written in HAVING outside the arguments of a set function as a reference to the grouped result row (Item_ref), and every other column name as a column (Item_field): PTI_simple_ident_ident, PTI_simple_ident_q_3d and PTI_simple_ident_nospvar_ident in parse_tree_items.cc, and the simple_ident actions of the 5.x grammars, test parsing_place != CTX_HAVING || in_sum_expr > 0; a set function written without OVER raises in_sum_expr while its arguments are read (Item_sum::itemize, PTI_in_sum_expr). The HAVING environment is the environment of the clause with a GroupedRow entry; a set function without OVER reads its arguments, its ORDER BY and its nested queries in the same environment without the entry. A nested query is a query block of its own and starts outside HAVING, but it sees the entry as part of its enclosing position. Terminates: one pass over the visible relations. Source: https://dev.mysql.com/doc/refman/8.4/en/select.html. Status: Implemented.

Methods§

public function grouping(
    list<ScalarFact> $items,
    list<VisibleRelation> $visible,
    list<VisibleRelation> $output,
): list<Field>

Answers the GROUP BY items that are columns, each with its column as the HAVING position sees it.

An item is a column when it is a column name, or an alias or a position of a select list item that is a column name (its value is then that column, real_item() in the server). The HAVING position of a block that aggregates or groups with a modifier sees the columns as they may be NULL there; the given lists hold each occurrence before and after that extension, in the same order.

Parameters

$itemslist<ScalarFact>The facts of the GROUP BY items, in order
$visiblelist<VisibleRelation>The occurrences of the FROM clause
$outputlist<VisibleRelation>The same occurrences as the HAVING position sees them

Returns

list<Field>
Called from 1
Calls 5
public function undecided(
    list<ScalarFact> $items,
    list<Field|OpenStar> $selected,
): list<ConditionalColumn>

Answers the GROUP BY items and the select list items that are columns no known occurrence decides.

Such a column belongs to an incompletely known occurrence, so the server may find a HAVING name among the GROUP BY columns or the select list items that this analysis cannot see.

Parameters

$itemslist<ScalarFact>The facts of the GROUP BY items, in order
$selectedlist<Field|OpenStar>The output fields of the select list, in order

Returns

Test cases 1
Called from 1

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 4

Relations§

Instantiated in 5
Method calls 7