From: | Brendan Jurd <direvus(at)gmail(dot)com> |
---|---|
To: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: Arithmetic operators for macaddr type |
Date: | 2011-12-13 05:16:14 |
Message-ID: | CADxJZo3ZoGFAMph6DV3eehqh6r0aarHYaLo64vGpnGDxvgcJFw@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 12 December 2011 15:59, Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> wrote:
> 2011/12/12 Brendan Jurd <direvus(at)gmail(dot)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 | Content-Type | Size |
---|---|---|
macaddr-bitwise-ops.diff | text/x-patch | 6.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2011-12-13 05:22:29 | Re: JSON for PG 9.2 |
Previous Message | Alvaro Herrera | 2011-12-13 03:42:24 | Re: JSON for PG 9.2 |