Re: Arithmetic operators for macaddr type - Mailing list pgsql-hackers

From Brendan Jurd
Subject Re: Arithmetic operators for macaddr type
Date
Msg-id CADxJZo3ZoGFAMph6DV3eehqh6r0aarHYaLo64vGpnGDxvgcJFw@mail.gmail.com
Whole thread Raw
In response to Re: Arithmetic operators for macaddr type  (Pavel Stehule <pavel.stehule@gmail.com>)
Responses Re: Arithmetic operators for macaddr type  (Fujii Masao <masao.fujii@gmail.com>)
List pgsql-hackers
On 12 December 2011 15:59, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> 2011/12/12 Brendan Jurd <direvus@gmail.com>:
>> I just bumped into a situation where I wanted to do a little macaddr
>> arithmetic in postgres.  I note that the inet type has support for
>> bitwise AND, OR and NOT, as well as subtraction, but macaddr has none
>> of the above.
>
> +1
>

Here is a patch for $SUBJECT.  I merely added support for ~, & and |
operators for the macaddr type.  The patch itself is rather trivial,
and includes regression tests and a doc update.

For the documentation, I did think about adding a new table for the
macaddr operators, but in the end decided it would probably be an
overkill.  If others think a table would be better, I'm happy to
revise it.

I also considered adding a function which would return the numeric
value of the MAC as a bigint, but figured I might save that for a
separate patch.

Cheers,
BJ

Attachment

pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: JSON for PG 9.2
Next
From: Tom Lane
Date:
Subject: Re: JSON for PG 9.2