mirror of
https://github.com/postgres/postgres.git
synced 2025-11-10 17:42:29 +03:00
Make inet/cidr << and <<= operators indexable. From Alex Pilosov <alex@pilosoft.com>.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* is for IP V4 CIDR notation, but prepared for V6: just
|
||||
* add the necessary bits where the comments indicate.
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.31 2001/06/13 21:08:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/network.c,v 1.32 2001/06/17 02:05:20 tgl Exp $
|
||||
*
|
||||
* Jon Postel RIP 16 Oct 1998
|
||||
*/
|
||||
@@ -707,3 +707,31 @@ v4addressOK(unsigned long a1, int bits)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* These functions are used by planner to generate indexscan limits
|
||||
* for clauses a << b and a <<= b
|
||||
*/
|
||||
|
||||
/* return the minimal value for an IP on a given network */
|
||||
Datum
|
||||
network_scan_first(Datum in)
|
||||
{
|
||||
return DirectFunctionCall1(network_network, in);
|
||||
}
|
||||
|
||||
/*
|
||||
* return "last" IP on a given network. It's the broadcast address,
|
||||
* however, masklen has to be set to 32, since
|
||||
* 192.168.0.255/24 is considered less than 192.168.0.255/32
|
||||
*
|
||||
* NB: this is not IPv6 ready ...
|
||||
*/
|
||||
Datum
|
||||
network_scan_last(Datum in)
|
||||
{
|
||||
return DirectFunctionCall2(inet_set_masklen,
|
||||
DirectFunctionCall1(network_broadcast, in),
|
||||
Int32GetDatum(32));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user