MCPcopy Create free account
hub / github.com/dolthub/doltgresql / Append

Method Append

postgres/parser/sem/tree/datum.go:1754–1784  ·  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

1752// Append appends a Datum to the array, whose parameterized type must be
1753// consistent with the type of the Datum.
1754func (d *DArray) Append(v Datum) error {
1755 if v != DNull && !d.ParamTyp.Equivalent(v.ResolvedType()) {
1756 return errors.AssertionFailedf("cannot append %s to array containing %s", d.ParamTyp,
1757 v.ResolvedType())
1758 }
1759 if d.Len() >= maxArrayLength {
1760 return errors.WithStack(errArrayTooLongError)
1761 }
1762 if d.ParamTyp.Family() == types.ArrayFamily {
1763 if v == DNull {
1764 return errNonHomogeneousArray
1765 }
1766 if d.Len() > 0 {
1767 prevItem := d.Array[d.Len()-1]
1768 if prevItem == DNull {
1769 return errNonHomogeneousArray
1770 }
1771 expectedLen := MustBeDArray(prevItem).Len()
1772 if MustBeDArray(v).Len() != expectedLen {
1773 return errNonHomogeneousArray
1774 }
1775 }
1776 }
1777 if v == DNull {
1778 d.HasNulls = true
1779 } else {
1780 d.HasNonNulls = true
1781 }
1782 d.Array = append(d.Array, v)
1783 return d.Validate()
1784}
1785
1786// DEnum represents an ENUM value.
1787type DEnum struct {

Callers 2

decimalEandMFunction · 0.45
parseElementMethod · 0.45

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