On Mon, Sep 21, 2026 at 8:45 AM Matthias van de Meent
<[email protected]> wrote:
> On Mon, 21 Sept 2026 at 14:23, Sehrope Sarkuni <[email protected]> wrote:
> > Today this needs nested set_byte() calls, each copying the whole
> > value.  The new form does one copy and one memset().
>
> Doesn't the `overlay(bytea, ...)` function already provide the feature
> you're looking for (possibly combined with repeat() for ease of use)?
> See 
> https://www.postgresql.org/docs/current/functions-binarystring.html#id-1.5.8.11.5.2.2.6.1.1.1
> and/or the ISO SQL spec for its specification.

Yes, it's possible, but seems clunky and has the extra intermediate
alloc for the repeat and decode:

SELECT overlay('\xaabbccddeeff'::bytea
               placing decode(repeat('00', 3), 'hex')
               from 3 for 3);

v.s.

SELECT set_byte('\xaabbccddeeff'::bytea, 2, 0, 3);


Regards,
-- Sehrope Sarkuni
Founder & CEO | JackDB, Inc. | https://www.jackdb.com/


Reply via email to