| From: | Sehrope Sarkuni <sehrope(at)jackdb(dot)com> |
|---|---|
| To: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] set_byte() with a count argument |
| Date: | 2026-09-21 13:17:39 |
| Message-ID: | CAH7T-aoxvJy8FfXXdjL3_J_kcjV=GAn=9Pkq7VxGASV-cQeMfw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, Sep 21, 2026 at 8:45 AM Matthias van de Meent
<boekewurm+postgres(at)gmail(dot)com> wrote:
> On Mon, 21 Sept 2026 at 14:23, Sehrope Sarkuni <sehrope(at)jackdb(dot)com> 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/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Jingtang Zhang | 2026-09-21 13:34:16 | Re: [PATCH] Use bounded GIN pending-list cleanup in parallel autovacuum |
| Previous Message | Ilia Evdokimov | 2026-09-21 13:03:44 | Re: Optimize MCV stats for sortable types and utilize sorted-order properties |