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

Method Next

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

Next implements the Datum interface.

(_ *EvalContext)

Source from the content-addressed store, hash-verified

1646
1647// Next implements the Datum interface.
1648func (d *DIPAddr) Next(_ *EvalContext) (Datum, bool) {
1649 // We will do one of a few things to get the Next IP address:
1650 // - Increment IP address if we won't overflow the IP.
1651 // - Increment mask and set the IP to min in family if we will overflow.
1652 // - Jump up from IPv4 to IPv6 if we will overflow both IP and mask.
1653 if d.Family == ipaddr.IPv4family && d.Addr.Equal(dIPv4max) {
1654 if d.Mask == 32 {
1655 // Jump up IP family.
1656 return dMinIPv6Addr, true
1657 }
1658 // Increase mask size, wrap IPv4 IP address.
1659 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv4family, Addr: dIPv4min, Mask: d.Mask + 1}}), true
1660 } else if d.Family == ipaddr.IPv6family && d.Addr.Equal(dIPv6max) {
1661 // Increase mask size, wrap IPv6 IP address.
1662 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv6family, Addr: dIPv6min, Mask: d.Mask + 1}}), true
1663 }
1664 // Increment IP address.
1665 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: d.Family, Addr: d.Addr.Add(1), Mask: d.Mask}}), true
1666}
1667
1668// IsMax implements the Datum interface.
1669func (d *DIPAddr) IsMax(_ *EvalContext) bool {

Callers

nothing calls this directly

Calls 3

NewDIPAddrFunction · 0.85
AddMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected