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

Method Prev

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

Prev implements the Datum interface.

(_ *EvalContext)

Source from the content-addressed store, hash-verified

1625
1626// Prev implements the Datum interface.
1627func (d *DIPAddr) Prev(_ *EvalContext) (Datum, bool) {
1628 // We will do one of the following to get the Prev IPAddr:
1629 // - Decrement IP address if we won't underflow the IP.
1630 // - Decrement mask and set the IP to max in family if we will underflow.
1631 // - Jump down from IPv6 to IPv4 if we will underflow both IP and mask.
1632 if d.Family == ipaddr.IPv6family && d.Addr.Equal(dIPv6min) {
1633 if d.Mask == 0 {
1634 // Jump down IP family.
1635 return dMaxIPv4Addr, true
1636 }
1637 // Decrease mask size, wrap IPv6 IP address.
1638 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv6family, Addr: dIPv6max, Mask: d.Mask - 1}}), true
1639 } else if d.Family == ipaddr.IPv4family && d.Addr.Equal(dIPv4min) {
1640 // Decrease mask size, wrap IPv4 IP address.
1641 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: ipaddr.IPv4family, Addr: dIPv4max, Mask: d.Mask - 1}}), true
1642 }
1643 // Decrement IP address.
1644 return NewDIPAddr(DIPAddr{ipaddr.IPAddr{Family: d.Family, Addr: d.Addr.Sub(1), Mask: d.Mask}}), true
1645}
1646
1647// Next implements the Datum interface.
1648func (d *DIPAddr) Next(_ *EvalContext) (Datum, bool) {

Callers

nothing calls this directly

Calls 3

NewDIPAddrFunction · 0.85
EqualMethod · 0.45
SubMethod · 0.45

Tested by

no test coverage detected