classSubscripting
final class Subscripting
Types the steps of an indirection applied to a value.
Rule: PG-SUBSCRIPT-001. A run of subscripts on an array yields its element type, and the array type itself when a step of the run is a slice; a subscript of jsonb yields jsonb and of point a double precision coordinate; another catalog type has no subscripting. A field selection reads the field of a composite value; a field it lacks and a value that is not composite are reported. .* ends an indirection and stands for the whole value; written before another step it is improper, as it is after a dotted relation name. A value of a type that depends on declarations makes every step depend on them. A subscript can be out of range, so its result can be NULL; a field is NULL when its value or the composite is. Termination: one pass over the steps. Source: https://www.postgresql.org/docs/17/arrays.html#ARRAYS-ACCESSING, https://www.postgresql.org/docs/17/datatype-json.html#JSONB-SUBSCRIPTING, https://www.postgresql.org/docs/17/rowtypes.html#ROWTYPES-ACCESSING. Status: Implemented.
Methods§
public function apply(
Derivation $derivation,
ScalarFact $base,
non-empty-list<IndirectionStep> $steps,
bool $star,
): ScalarFactApplies the steps to the facts of the base value.
Parameters
$derivation | Derivation | |
$base | ScalarFact | |
$steps | non-empty-list<IndirectionStep> | |
$star | bool | Whether the base is a dotted name ending in `.*` |
Returns
Test cases 2
Called from 1
Calls 8
- function-call
countline 55 - method-call Subscripting::problem() line 58
- new ImproperStar line 58
- method-call Subscripting::field() line 69
- new ScalarFact line 71
- class-const Nullability::Dependent() line 71
- method-call Subscripting::subscript() line 81
- class-const Nullability::Nullable() line 82
public function subscript(
Derivation $derivation,
Known $type,
non-empty-list<IndirectionStep> $run,
): TypeFactTypes a run of subscripts and slices applied to a value of a known type.
Parameters
$derivation | Derivation | |
$type | Known | |
$run | non-empty-list<IndirectionStep> |
Returns
Test cases 1
Called from 1
Calls 10
- new Known line 100
- method-call Categories::builtin() line 102
- new Categories line 102
- class-const Builtin::Jsonb() line 103
- class-const Builtin::Point() line 106
- function-call
countline 106 - class-const Builtin::Float8() line 107
- new NotSubscriptable line 109
- method-call Derivation::report() line 110
- new Invalid line 112
public function field(
Derivation $derivation,
Known $type,
FieldSelection $step,
): array{TypeFact, Nullability}|InvalidReads a field of a value of a known type.
Parameters
$derivation | Derivation | |
$type | Known | |
$step | FieldSelection |
Returns
array{TypeFact, Nullability}|InvalidTest cases 1
Called from 1
Calls 4
- new NotComposite line 123
- method-call Derivation::report() line 124
- new Invalid line 126
- new MissingField line 133
public function problem(Derivation $derivation, Diagnostic $problem): ScalarFactReports a problem of the indirection and answers its invalid fact.
Parameters
$derivation | Derivation | |
$problem | Diagnostic |
Returns
Test cases 1
Called from 1
Calls 4
- method-call Derivation::report() line 144
- new ScalarFact line 146
- new Invalid line 146
- class-const Nullability::Dependent() line 146
Test cases 5§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.