classLateralReach
final class LateralReach
Tells which FROM items a lateral item on the right of a join may reference.
Rule: PG-LATERAL-JOIN-001. A lateral item (a function call, XMLTABLE, JSON_TABLE or a LATERAL subquery) on the right of a join sees the items on the left of the join. When the join is RIGHT or FULL, those items are still visible, but referencing one of them is an error: transformFromClauseItem marks them p_lateral_ok = false and check_lateral_ref_ok reports "invalid reference to FROM-clause entry for table" as soon as a column, a qualifier or a whole row reaches one. Such a relation carries the BARRED entry in its hidden list for the lateral item only. The name reported is the alias, the relation name, unnamed_subquery or unnamed_join. Source: https://www.postgresql.org/docs/17/queries-table-expressions.html#QUERIES-LATERAL. Termination: one pass over the relations of each level. Status: Implemented.
Constants§
public const BARRED = -2The hidden-list entry that marks a relation a lateral item sees but must not reference.
Methods§
public function bar(list<VisibleRelation> $relations): list<VisibleRelation>Answers the relations as the right side of a RIGHT or FULL join sees them: visible, but barred.
Parameters
$relations | list<VisibleRelation> |
Returns
list<VisibleRelation>Test cases 4
Called from 1
Calls 3
- method-call LateralReach::barred() line 57
- new VisibleRelation line 57
- class-const LateralReach::BARRED() line 57
public function barred(VisibleRelation $relation): boolTells whether a relation must not be referenced at this position.
Parameters
$relation | VisibleRelation |
Returns
boolTest cases 1
Called from 4
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\WholeRows::row() packages/sql-semantics-postgres/src/Rules/Expression/WholeRows.php:84
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\LateralReach::bar() packages/sql-semantics-postgres/src/Rules/Resolution/LateralReach.php:57
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\LateralReach::reached() packages/sql-semantics-postgres/src/Rules/Resolution/LateralReach.php:78
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\LateralReach::reached() packages/sql-semantics-postgres/src/Rules/Resolution/LateralReach.php:96
Calls 2
- function-call
in_arrayline 68 - class-const LateralReach::BARRED() line 68
public function reached(
Environment $environment,
Resolution $resolution,
?QualifiedName $qualifier,
): ?VisibleRelationAnswers the barred relation a column resolution or a qualifier reaches, or null when it reaches none.
Parameters
$environment | Environment | |
$resolution | Resolution | |
$qualifier | ?QualifiedName |
Returns
Test cases 2
Called from 1
Calls 3
- method-call WholeRows::find() line 77
- new WholeRows line 77
- method-call LateralReach::barred() line 78
public function report(Derivation $derivation, VisibleRelation $relation): ScalarFactReports the reference to a barred relation and answers the fact of the reference.
Parameters
$derivation | Derivation | |
$relation | VisibleRelation |
Returns
Called from 2
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\WholeRows::row() packages/sql-semantics-postgres/src/Rules/Expression/WholeRows.php:85
Calls 7
- new Name line 110
- new QueryMisuse line 111
- class-const QueryMisuseRule::LateralJoinType() line 111
- method-call Derivation::report() line 112
- new ScalarFact line 114
- new Invalid line 114
- class-const Nullability::Dependent() line 114
Test cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Relations§
Instantiated in 3
- new SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:66
- new SqlSemantics\Platform\PostgreSql\Rules\Expression\WholeRows::row() packages/sql-semantics-postgres/src/Rules/Expression/WholeRows.php:83
- new SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:112
Method calls 5
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:67
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\ColumnFacts::derive() packages/sql-semantics-postgres/src/Rules/Expression/ColumnFacts.php:69
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\WholeRows::row() packages/sql-semantics-postgres/src/Rules/Expression/WholeRows.php:84
- method-call SqlSemantics\Platform\PostgreSql\Rules\Expression\WholeRows::row() packages/sql-semantics-postgres/src/Rules/Expression/WholeRows.php:85
- method-call SqlSemantics\Platform\PostgreSql\Rules\Resolution\FromScope::enter() packages/sql-semantics-postgres/src/Rules/Resolution/FromScope.php:112