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: Michael Paquier <michael@paquier.xyz>, Peter Eisentraut <peter@eisentraut.org>
Date: 2025-01-13T17:35:59Z
Lists: pgsql-hackers

Attachments

Hi Michael,

> v5-0001 includes the following output:
>
> --- a/src/test/regress/expected/opr_sanity.out
> +++ b/src/test/regress/expected/opr_sanity.out
> @@ -126,9 +126,12 @@ WHERE p1.oid < p2.oid AND
>       p1.proretset != p2.proretset OR
>       p1.provolatile != p2.provolatile OR
>       p1.pronargs != p2.pronargs);
> - oid | proname | oid | proname
> ------+---------+-----+---------
> -(0 rows)
> + oid  | proname  | oid  | proname
> +------+----------+------+---------
> + 2405 | int2send | 8577 | bytea
> + 2407 | int4send | 8578 | bytea
> + 2409 | int8send | 8579 | bytea
> +(3 rows)
>
> This should not happen, as you are using multiple times the same
> function.

Thanks. Here is the corrected patch.

Besides fixing opr_sanity test I corrected error messages:

-ERROR:  bytea size 3 out of valid range, 0..2
+ERROR:  bytea out of valid range, ''..'\xFFFF'

... and also included tests for min/max integer values.

I discarded the 0002 patch that implemented get_bytes() / set_bytes().
This part doesn't seem to get much support, so let's focus on casting.

--
Best regards,
Aleksander Alekseev

Commits

  1. Allow casting between bytea and integer types.