classSetOperationFacts
final class SetOperationFacts
Derives the facts of UNION, INTERSECT and EXCEPT.
Rule: PG-SET-OPERATION-001. Both operands are derived in the enclosing environment. The output has the names of the first operand; the type of a column is the common type of the operand columns (PG-UNIFICATION-001, untyped literals as unknown, PG-UNKNOWN-OUTPUT-001), and a column can be NULL when it can in an operand. Operands of different widths and types that cannot be matched are reported. When the set operation is the query of a recursive common table or view (RecursiveDefinition) that refers to itself, the second operand sees that table with the columns of the first operand, renamed by the column list of the table, each able to be NULL because later rounds of the recursion feed back their own rows. An operand whose columns are not all known leaves the output open. Terminates: two operands; no fixpoint is computed. Source: https://www.postgresql.org/docs/17/queries-union.html, https://www.postgresql.org/docs/17/queries-with.html#QUERIES-WITH-RECURSIVE. Status: Implemented.
Methods§
public function derive(
SetOperation $operation,
Derivation $derivation,
Environment $outer,
): QueryFactDerives both operands and answers the combined output.
Parameters
$operation | SetOperation | |
$derivation | Derivation | |
$outer | Environment |
Returns
Called from 1
Calls 4
- method-call Derivation::query() line 53
- method-call SetOperationFacts::rebound() line 54
- new QueryFact line 56
- method-call SetOperationFacts::combined() line 56
public function combined(
SetOperation $operation,
QueryFact $left,
QueryFact $right,
Derivation $derivation,
): list<Field|OpenStar>Combines the outputs of the operands.
Parameters
$operation | SetOperation | |
$left | QueryFact | |
$right | QueryFact | |
$derivation | Derivation |
Called from 1
Calls 13
- method-call QueryFact::fields() line 66
- new OpenStar line 69
- function-call
countline 71 - method-call Derivation::report() line 72
- new ArityMismatch line 72
- class-const ArityRule::SetOperation() line 72
- new UnknownOutputs line 74
- new Unification line 75
- method-call Unification::resolve() line 79
- method-call UnknownOutputs::raw() line 79
- method-call Unification::nullability() line 83
- new Field line 84
- new OutputSlot line 84
public function rebound(
SetOperation $operation,
QueryFact $anchor,
Environment $outer,
): EnvironmentAnswers the environment of the second operand: the enclosing one, with the recursive common table this operation computes bound to the first operand.
Parameters
$operation | SetOperation | |
$anchor | QueryFact | |
$outer | Environment |
Returns
Called from 1
Calls 8
- method-call Carriers::core() line 99
- new Carriers line 99
- method-call QueryFact::fields() line 101
- new OutputSlot line 102
- class-const Nullability::Nullable() line 102
- new CommonBinding line 104
- new RowShape line 104
- new Environment line 110
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
SetOperationFactsTestcalls