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

Types operator applications over catalog types.

Rule: PG-OPERATOR-TYPING-001. An operator is looked up by name and operand types along the search path; a context declares no operators, so a result is known only when pg_catalog is searched before any other schema (or the operator is qualified with it) and the operand types select one of the catalog operators below; every other combination depends on the operator's declaration. An invalid operand makes the result invalid, a dependent operand makes it depend on the same inputs. An operand of the pseudo-type unknown (a string constant or NULL) takes the type of the other operand. The table: the six comparisons are boolean for operands of one category among numbers, strings, date and timestamp types, and for the self-comparable types of PG-OPERATOR-COMPARISON-001, rows and arrays; + - * / over numbers give the wider of two integer types, numeric with an integer and numeric, double precision once a floating-point type and another type meet, and the type itself for two equal types; % is defined for integers and numeric; ^ for double precision and numeric, integers reaching it as double precision; date/time arithmetic follows the table of functions-datetime.html; || gives text when a side is a string, the array type for arrays, and the type itself for bytea, bit strings, jsonb, tsvector and tsquery; the bitwise operators keep the integer or bit-string type; the JSON operators follow functions-json.html; prefix - and + keep a number or interval type, and - before a numeric constant is that negative constant, typed by its value. Comparisons and arithmetic are strict: the result can be NULL when an operand can. Termination: constant work. Source: https://www.postgresql.org/docs/17/typeconv-oper.html, https://www.postgresql.org/docs/17/functions-comparison.html, https://www.postgresql.org/docs/17/functions-math.html, https://www.postgresql.org/docs/17/functions-datetime.html, https://www.postgresql.org/docs/17/functions-string.html, https://www.postgresql.org/docs/17/functions-json.html, https://www.postgresql.org/docs/17/functions-array.html, https://www.postgresql.org/docs/17/functions-bitstring.html. Status: Implemented.

Methods§

public function named(
    AnalysisContext $context,
    OperatorName|string $operator,
    TypeFact $left,
    TypeFact $right,
): TypeFact

Types an application of a binary operator given by name or as an operator name.

Parameters

$contextAnalysisContext
$operatorOperatorName|string
$leftTypeFact
$rightTypeFact

Returns

Test cases 1
Called from 11
Calls 8
public function structured(
    string $operator,
    TypeFact $left,
    TypeFact $right,
): Builtin|ArrayOf|null
public function arrays(
    string $operator,
    TypeDescriptor $left,
    TypeDescriptor $right,
): Builtin|ArrayOf|null

Types an operator over arrays: comparison and containment of equal array types, and || with arrays or elements.

Parameters

$operatorstring
$leftTypeDescriptor
$rightTypeDescriptor

Returns

Test cases 1
Called from 1
Calls 4
public function comparable(Builtin $left, Builtin $right): bool

Private surface 2§

Implementation details, listed for orientation only.

private const EXACT = ['+ date int4' => 'date', '+ int4 date' => 'date', '- date int4' => 'date', '- …
private const COMPARISONS = ['=', '<>', '<', '>', '<=', '>=']

Test cases 9§

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

Dedicated tests 9

Relations§

Instantiated in 13
Method calls 19