MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / Append

Method Append

pkg/sql/sem/tree/datum.go:3488–3518  ·  view source on GitHub ↗

Append appends a Datum to the array, whose parameterized type must be consistent with the type of the Datum.

(v Datum)

Source from the content-addressed store, hash-verified

3486// Append appends a Datum to the array, whose parameterized type must be
3487// consistent with the type of the Datum.
3488func (d *DArray) Append(v Datum) error {
3489 if v != DNull && !d.ParamTyp.Equivalent(v.ResolvedType()) {
3490 return errors.AssertionFailedf("cannot append %s to array containing %s", d.ParamTyp,
3491 v.ResolvedType())
3492 }
3493 if d.Len() >= maxArrayLength {
3494 return errors.WithStack(errArrayTooLongError)
3495 }
3496 if d.ParamTyp.Family() == types.ArrayFamily {
3497 if v == DNull {
3498 return errNonHomogeneousArray
3499 }
3500 if d.Len() > 0 {
3501 prevItem := d.Array[d.Len()-1]
3502 if prevItem == DNull {
3503 return errNonHomogeneousArray
3504 }
3505 expectedLen := MustBeDArray(prevItem).Len()
3506 if MustBeDArray(v).Len() != expectedLen {
3507 return errNonHomogeneousArray
3508 }
3509 }
3510 }
3511 if v == DNull {
3512 d.HasNulls = true
3513 } else {
3514 d.HasNonNulls = true
3515 }
3516 d.Array = append(d.Array, v)
3517 return d.Validate()
3518}
3519
3520// DOid is the Postgres OID datum. It can represent either an OID type or any
3521// of the reg* types, such as regproc or regclass.

Callers 7

AppendToMaybeNullArrayFunction · 0.95
PrependToMaybeNullArrayFunction · 0.95
ConcatArraysFunction · 0.95
PerformCastFunction · 0.95
parseElementMethod · 0.80
EvalMethod · 0.80
decimalEandMFunction · 0.80

Calls 7

LenMethod · 0.95
ValidateMethod · 0.95
MustBeDArrayFunction · 0.85
EquivalentMethod · 0.80
FamilyMethod · 0.80
ResolvedTypeMethod · 0.65
LenMethod · 0.65

Tested by

no test coverage detected