Re: bytea bitwise logical operations implementation (xor / and / or / not) - Mailing list pgsql-hackers

From Darafei "Komяpa" Praliaskouski
Subject Re: bytea bitwise logical operations implementation (xor / and / or / not)
Date
Msg-id CAC8Q8tKn0M5D5pRiJA8fguzfXnvEoiAm0e4qzjqHbTqAOTK8RA@mail.gmail.com
Whole thread Raw
In response to Re: bytea bitwise logical operations implementation (xor / and / or/ not)  (Fabien COELHO <coelho@cri.ensmp.fr>)
List pgsql-hackers
Hello,

working with binary is certainly lacked in Postgres.

I would be happy if these can be pulled in to Postgres, as there's not always a possibility to install a C based extension, and bit tricks are needed for efficient SQL-level implementations of custom datatypes.

Another bitwise thing,  when I was implementing a custom interval type, I lacked a way to set bits from i to j in bit vector. It's probably doable with clever and-or-xor tricks, but that would imply a lot of allocations of temporary bit vectors.

For reference, it was subset of OpenStreetMap opening_hours spec implementation.
Implementation I came up with:

pgsql-hackers by date:

Previous
From: Amit Khandekar
Date:
Subject: Re: [HACKERS] UPDATE of partition key
Next
From: Ildar Musin
Date:
Subject: Minor fix for pgbench documentation