In order to make it easier to work with data stored as binary
strings (BINARY/VARBINARY) we are considering extending the
&,|,^,~,> operators, to accept any-size binary strings and
return binary string data as response. This can be useful for
several complex data types not covered by the basic SQL data
types (e.g. working with IPV6 addresses, manipulating UUID, etc).
Motivation
Let’s say we’re interested in getting all the networks that
contain the given IP address. With ipv4 the common practice is to
store the IP addresses as INT and execute:
SELECT inet_ntoa(network) AS network, inet_ntoa(netmask) AS
netmask FROM network_table WHERE (inet_aton('192.168.0.30') &
netmask) = network;
At the moment you are not able to do the same with ipv6 because
inet6_aton('2001:0db8:85a3:0000:0000:8a2e:0370:7334') &
netmask converts both operands from VARBINARY to BIGINT resulting
in data …
[Read more]