classMergeFacts
final class MergeFacts
Derives the facts of MERGE.
Rule: PG-MERGE-001. The common tables, the target and the source follow PG-MODIFICATION-SCOPE-001. The join condition sees the target and the source. A WHEN MATCHED clause sees both; a WHEN NOT MATCHED BY SOURCE clause sees the target only; a WHEN NOT MATCHED [BY TARGET] clause sees the source only. UPDATE SET follows PG-ASSIGNMENT-001; INSERT follows the column and value rules of PG-INSERT-001 for one VALUES row; both write a generated column with DEFAULT only (PG-GENERATED-WRITE-001). A WHEN clause after a clause of the same kind without condition can never apply and is reported. RETURNING (PostgreSQL 17) sees the target and the source; with a WHEN NOT MATCHED BY SOURCE clause the source columns can be NULL. MERGE_ACTION() is admitted in RETURNING only (PG-PLACEMENT-001). Source: https://www.postgresql.org/docs/17/sql-merge.html, https://www.postgresql.org/docs/17/functions-merge-support.html. Status: Implemented.
Methods§
public function derive(Merge $merge, Derivation $derivation, Environment $outer): QueryFactDerives a MERGE and answers its rows.
Parameters
$merge | Merge | |
$derivation | Derivation | |
$outer | Environment |
Returns
Called from 1
Calls 18
- new ModificationScope line 49
- method-call ModificationScope::open() line 50
- method-call ModificationScope::inputs() line 51
- method-call Derivation::scalar() line 52
- new Environment line 52
- method-call Derivation::report() line 57
- new ManipulationMisuse line 57
- class-const ManipulationMisuseRule::UnreachableWhen() line 57
- class-const MergeMatch::Matched() line 63
- class-const MergeMatch::NotMatchedBySource() line 64
- class-const MergeMatch::NotMatched() line 65
- function-call
array_pushline 67 - method-call MergeFacts::clause() line 67
- method-call MergeFacts::bySource() line 69
- method-call MergeFacts::nullable() line 70
- method-call Placement::values() line 72
- new Placement line 72
- method-call ModificationScope::returning() line 74
public function clause(
MergeWhen $clause,
VisibleRelation $target,
Derivation $derivation,
Environment $environment,
): list<DefaultRequest>Derives one WHEN clause and answers the DEFAULT values it admits.
Parameters
$clause | MergeWhen | |
$target | VisibleRelation | |
$derivation | Derivation | |
$environment | Environment |
Returns
list<DefaultRequest>Called from 1
Calls 12
- method-call Derivation::scalar() line 85
- new Assignments line 88
- method-call Assignments::assign() line 90
- method-call Assignments::defaults() line 92
- new InsertFacts line 97
- method-call InsertFacts::columns() line 98
- method-call Assignments::value() line 101
- method-call Assignments::requested() line 102
- method-call InsertFacts::arity() line 107
- function-call
countline 107 - method-call GeneratedWrites::inserted() line 108
- new GeneratedWrites line 108
public function bySource(Merge $merge): boolTells whether a MERGE has a WHEN NOT MATCHED BY SOURCE clause.
Parameters
$merge | Merge |
Returns
boolCalled from 1
Calls 1
- class-const MergeMatch::NotMatchedBySource() line 119
public function nullable(list<VisibleRelation> $relations): list<VisibleRelation>Answers the relations with every column able to be NULL.
Parameters
$relations | list<VisibleRelation> |
Returns
list<VisibleRelation>Called from 1
Calls 4
- new OutputSlot line 140
- class-const Nullability::Nullable() line 140
- new VisibleRelation line 142
- new RowShape line 142
Test cases 1§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.
Dedicated tests 1
MergeFactsTestcalls