bytea bitwise logical operations implementation (xor / and / or /not)

Поиск
Список
Период
Сортировка
От Christian Rossow
Тема bytea bitwise logical operations implementation (xor / and / or /not)
Дата
Msg-id 74a3f8f0-d1d4-1d6e-dd81-fb2cf89ef88f@gmail.com
обсуждение исходный текст
Ответы Re: bytea bitwise logical operations implementation (xor / and / or/ not)
Список 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

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: [HACKERS] Proposal: Local indexes for partitioned table
Следующее
От: Robert Haas
Дата:
Сообщение: Re: [HACKERS] [PATCH] Generic type subscripting