final class ResultTyping
Restricted visibility: declared "@visibility SqlSemantics\Platform\MySql". Code outside that scope must not name this declaration.

The result facts of a built-in function from its result code and the facts of its arguments.

Rule: MYSQL-CALL-RESULT-001. A result code is two letters: the type and the NULL rule. Fixed types: I BIGINT, U BIGINT UNSIGNED, D DOUBLE, N DECIMAL, T a character string, B a binary string, J JSON, V VECTOR, G a geometry, A DATE, M TIME, E DATETIME. Derived types: S a string whose character set comes from the arguments (binary when one is binary); H the numeric type of the first argument and O that of all arguments (an exact integer stays BIGINT, DECIMAL stays DECIMAL, anything else is DOUBLE); C CEILING and FLOOR, whose DECIMAL argument gives BIGINT or DECIMAL by its size; 1 and 2 the type of the first or second argument; + the aggregated type of all arguments and Z of the arguments after the first (MYSQL-TYPE-AGGREGATION-001); X ADDTIME and SUBTIME, which keep a DATETIME or TIME first argument and give a string otherwise; K STR_TO_DATE, a DATE, TIME or DATETIME by the format; W UNIX_TIMESTAMP of a value, BIGINT or DECIMAL by its fractional seconds. NULL rules: P NULL exactly when an argument can be NULL, N never NULL, Y possibly NULL, C NULL only when every argument can be, F as the first argument, L as the last argument, R NULL when an argument after the first can be. The codes of the built-in functions are listed by MYSQL-NATIVE-FUNCTIONS-001 and the call classes. Terminates: one pass over the arguments. Source: https://dev.mysql.com/doc/refman/8.4/en/functions.html, https://dev.mysql.com/doc/refman/8.4/en/type-conversion.html. Status: Implemented.

Methods§

public function fact(string $code, list<ScalarFact> $arguments): ScalarFact

Answers the facts of a result.

Parameters

$codestringThe two-letter result code
$argumentslist<ScalarFact>The facts of the arguments in order

Returns

Test cases 2
Called from 8
Calls 5
public function string(list<TypeFact> $types): TypeFact

Answers the type of a string result whose character set comes from the arguments.

Parameters

$typeslist<TypeFact>

Returns

Test cases 1
Called from 1
Calls 8
public function numeric(list<TypeFact> $types, bool $integral): TypeFact

Answers the numeric type of the arguments of a numeric function.

An argument of an integer class, YEAR or BIT is an integer, DECIMAL is DECIMAL (or an integer for CEILING and FLOOR when it fits), a date or time is an integer or a DECIMAL by its fractional seconds, any other argument is DOUBLE; several arguments combine as numbers do.

Parameters

$typeslist<TypeFact>
$integralboolWhether a DECIMAL argument may give an integer, as for CEILING and FLOOR

Returns

Test cases 1
Called from 3
Calls 8
public function numbers(list<TypeClass> $classes, bool $integral): list<TypeClass>

Answers the numeric classes an argument of the given classes is converted to; no class is any number.

Parameters

$classeslist<TypeClass>
$integralbool

Returns

list<TypeClass>
Test cases 1
Called from 1
Calls 8
public function dateArithmetic(TypeFact $date, IntervalUnit $unit): TypeFact

Answers the type of a date plus or minus an interval: DATE_ADD, DATE_SUB, ADDDATE, SUBDATE and TIMESTAMPADD.

A DATE stays a DATE for a unit of days or larger and becomes a DATETIME otherwise; a TIME stays a TIME for a unit of hours or smaller; a DATETIME or TIMESTAMP gives a DATETIME; any other argument gives a string (https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_date-add).

Parameters

Returns

Test cases 1
Called from 3
Calls 34
public function coalesce(list<Nullability> $facts): Nullability

Combines NULL facts when the result is NULL only if every operand is.

Parameters

$factslist<Nullability>
Test cases 1
Called from 1
Calls 4

Private surface 1§

Implementation details, listed for orientation only.

private const FIXED = ['I' => \SqlSemantics\Platform\MySql\Rules\Call\TypeClass::Integer, 'U' => \Sql…

Test cases 13§

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

Dedicated tests 13

Relations§

Instantiated in 11
Method calls 13