Re: [PATCH] Add get_bytes() and set_bytes() functions

Aleksander Alekseev <aleksander@timescale.com>

From: Aleksander Alekseev <aleksander@timescale.com>
To: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Peter Eisentraut <peter@eisentraut.org>
Date: 2024-10-08T13:41:51Z
Lists: pgsql-hackers

Attachments

Hi,

> I guess there are in fact two problems, not one.
>
> 1. Converting between bytea and integer types
> 2. Multibyte versions of get_byte() / set_byte()
>
> As you rightly pointed out, for (1) we just need to add missing casts.
> Here is the corresponding patch, v3-0001. Note that I couldn't re-use
> int{2,4,8}recv because its first argument is StringInfo, so I ended up
> implementing my own bytea->int{2,4,8} functions.
>
> I think there may be value in (2) as well. It's implemented in v3-0002
> and I did my best to clarify the commit message. On the flip side the
> situation when one wants something like extracting int4 from a
> bytea(or vice versa) and is not happy with convenience and/or
> performance of substr()+casts is arguably rare. I'll be fine with
> whatever consensus the community reaches about this patch.

PFA the rebased patch set v4.

-- 
Best regards,
Aleksander Alekseev

Commits

  1. Allow casting between bytea and integer types.