classFromScope
final class FromScope
Derives the FROM items of a query and the relations they make visible to names.
Rule: PG-FROM-SCOPE-001. A table, a subquery, a function call, XMLTABLE and JSON_TABLE are each one visible relation under their alias, or without one under their table name, function name, xmltable or json_table; a subquery without alias can only be read through * and unqualified names. A function call, XMLTABLE, JSON_TABLE and a LATERAL subquery see the FROM items before them (at the top level and on the left of the joins they are on the right of; the left side of a RIGHT or FULL join is visible but must not be referenced, PG-LATERAL-JOIN-001); any other item sees only the enclosing query. A join follows PG-JOIN-001; its ON condition sees its two sides and the enclosing query only. A join in parentheses with an alias hides the items inside and is one relation under the alias; without an alias the parentheses change nothing. The items of a comma list follow each other. Terminates: lists are walked in loops; recursion follows the nesting of joins. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-FROM, https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-LATERAL. Status: Implemented.
Methods§
public function open(
Relation $item,
Derivation $derivation,
Environment $outer,
list<VisibleRelation> $left,
): JoinedInputDerives one FROM item, records its facts and answers what it makes visible.
Parameters
$item | Relation | |
$derivation | Derivation | |
$outer | Environment | |
$left | list<VisibleRelation> | The relations of the FROM items before the item, which lateral items see |
Returns
Called from 8
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ModificationScope::inputs() packages/sql-semantics-postgres/src/Rules/Manipulation/ModificationScope.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:61
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::table() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:107
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:97
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:103
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:111
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:113
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\StatisticsScope::derive() packages/sql-semantics-postgres/src/Rules/Table/Command/StatisticsScope.php:36
Calls 6
- method-call FromScope::enter() line 56
- method-call Derivation::target() line 57
- method-call Derivation::relation() line 62
- new Environment line 62
- new JoinedInput line 64
- method-call FromScope::visible() line 64
public function visible(Relation $item, RelationFact $fact): VisibleRelationAnswers the relation one FROM item that is not a join makes visible.
Parameters
$item | Relation | |
$fact | RelationFact |
Returns
Called from 1
Calls 6
- new VisibleRelation line 73
- method-call TableShapes::implicit() line 73
- new TableShapes line 73
- method-call Relation::name() line 78
- new Name line 79
- new QualifiedName line 84
public function enter(
Join|ParenthesizedJoin|RelationList $node,
Derivation $derivation,
Environment $outer,
list<VisibleRelation> $left,
): JoinedInputDerives the items of a join, of parentheses or of a comma list, without recording the facts of the node itself.
Parameters
$node | Join|ParenthesizedJoin|RelationList | |
$derivation | Derivation | |
$outer | Environment | |
$left | list<VisibleRelation> | The relations of the FROM items before the node, which lateral items see |
Returns
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::open() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:56
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\Join::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/Join.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\ParenthesizedJoin::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/ParenthesizedJoin.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\RelationList::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/RelationList.php:56
Calls 17
- function-call
array_pushline 97 - method-call FromScope::open() line 97
- new JoinedInput line 100
- new RelationFact line 100
- method-call Visibility::star() line 100
- new Visibility line 100
- method-call ColumnAliases::apply() line 107
- new ColumnAliases line 107
- new VisibleRelation line 109
- class-const JoinKind::Right() line 112
- class-const JoinKind::Full() line 112
- method-call LateralReach::bar() line 112
- new LateralReach line 112
- method-call Derivation::scalar() line 115
- new Environment line 115
- method-call Joining::join() line 118
- new Joining line 118
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
FromScopeTestcalls
Relations§
Instantiated in 7
- new SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ModificationScope::inputs() packages/sql-semantics-postgres/src/Rules/Manipulation/ModificationScope.php:66
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:61
- new SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::table() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:107
- new SqlSemantics\Platform\PostgreSql\Rules\Table\Command\StatisticsScope::derive() packages/sql-semantics-postgres/src/Rules/Table/Command/StatisticsScope.php:34
- new SqlSemantics\Platform\PostgreSql\Statement\Relation\Join::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/Join.php:65
- new SqlSemantics\Platform\PostgreSql\Statement\Relation\ParenthesizedJoin::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/ParenthesizedJoin.php:57
- new SqlSemantics\Platform\PostgreSql\Statement\Relation\RelationList::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/RelationList.php:56
Method calls 7
- method-call SqlSemantics\Platform\PostgreSql\Rules\Manipulation\ModificationScope::inputs() packages/sql-semantics-postgres/src/Rules/Manipulation/ModificationScope.php:66
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::derive() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:61
- method-call SqlSemantics\Platform\PostgreSql\Rules\Query\Facts\SelectFacts::table() packages/sql-semantics-postgres/src/Rules/Query/Facts/SelectFacts.php:107
- method-call SqlSemantics\Platform\PostgreSql\Rules\Table\Command\StatisticsScope::derive() packages/sql-semantics-postgres/src/Rules/Table/Command/StatisticsScope.php:36
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\Join::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/Join.php:65
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\ParenthesizedJoin::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/ParenthesizedJoin.php:57
- method-call SqlSemantics\Platform\PostgreSql\Statement\Relation\RelationList::deriveRelation() packages/sql-semantics-postgres/src/Statement/Relation/RelationList.php:56