final class Unification
Restricted visibility: declared "@visibility SqlSemantics". Code outside that scope must not name this declaration.

Resolves the common type of values that UNION, CASE, ARRAY, VALUES, IN and the conditional functions combine.

Rule: PG-UNIFICATION-001. An invalid input makes the result invalid; an input of a type that depends on missing declarations makes it depend on them. Values of one type keep it, modifiers included. When every input is of the pseudo-type unknown (a string constant or NULL), the result is text. Otherwise unknown inputs are ignored; the other inputs must share a category (PG-TYPE-CATEGORY-001), else the types cannot be matched. The first input is the candidate; each later input replaces it when the candidate converts to it implicitly but not back, unless the candidate is the preferred type of the category. Every input must then convert to the candidate implicitly. A type outside the category tables matches only itself. Minimum precision: Known for the catalog types of the tables. Termination: one pass over the inputs. Source: https://www.postgresql.org/docs/17/typeconv-union-case.html. Status: Implemented.

Methods§

public function resolve(
    AnalysisContext $context,
    list<TypeFact> $types,
    string $construct = 'UNION',
): TypeFact

Answers the common type of the inputs; a conflict is an Invalid fact the caller reports.

Parameters

$contextAnalysisContext
$typeslist<TypeFact>The input types in order; at least one
$constructstringThe construct that combines them, for the conflict message

Returns

Test cases 3
Called from 8
Calls 7
public function candidate(non-empty-list<Known> $types, string $construct): TypeFact
public function distinct(non-empty-list<MissingInput> $missing): non-empty-list<MissingInput>

Test cases 6§

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

Dedicated tests 6

Relations§

Instantiated in 10
Method calls 12