From: | Christian Rossow <christian(dot)rossow(at)gmail(dot)com> |
---|---|
To: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | bytea bitwise logical operations implementation (xor / and / or / not) |
Date: | 2018-01-11 19:02:17 |
Message-ID: | 74a3f8f0-d1d4-1d6e-dd81-fb2cf89ef88f@gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hackers,
Currently, `bytea` does not have any bitwise logical operations yet.
This issue came up in an old thread from 2006 [1], but nobody seemed to
have picked this issue so far.
Being in the need for this myself, I copied the bit vector's bitwise
logical operations and converted them to bytea. I'm using this as a
PostgreSQL extension right now, but would be very happy to see this
integrated into mainstream as default bytea operations in the future.
Find attached the implementation, plus a SQL file, for:
* bytea_xor
* bytea_and
* bytea_or
* bytea_not
* bytea_bitsset (returns number of set bits in a bytea; feel free to
drop this one if you don't see utility)
Tested on PG 9.6. I hope you find this useful.
Cheers,
Christian
[1]: https://www.postgresql.org/message-id/5171.1146927915%40sss.pgh.pa.us
Attachment | Content-Type | Size |
---|---|---|
bytea_bitops.sql | text/plain | 791 bytes |
bytea_bitops.c | text/plain | 4.0 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Robert Haas | 2018-01-11 19:05:15 | Re: [HACKERS] [PATCH] Generic type subscripting |
Previous Message | Alvaro Herrera | 2018-01-11 18:52:07 | Re: [HACKERS] Proposal: Local indexes for partitioned table |