| From: | Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com> |
|---|---|
| To: | Sehrope Sarkuni <sehrope(at)jackdb(dot)com> |
| Cc: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] set_byte() with a count argument |
| Date: | 2026-09-21 12:44:49 |
| Message-ID: | CAEze2Wi8Xz3BLW1uwL3UvU08tTAO8Y3y8xvkj6TN3hM63OX4Wg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On Mon, 21 Sept 2026 at 14:23, Sehrope Sarkuni <sehrope(at)jackdb(dot)com> wrote:
>
> Hi hackers,
>
> 0002 adds a four-argument set_byte():
>
> set_byte(bytes bytea, n integer, newvalue integer, count integer)
>
> setting count consecutive bytes from byte n to newvalue:
>
> SELECT set_byte('\x0000000000'::bytea, 1, 255, 3);
> => \x00ffffff00
>
> 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.
Kind regards,
Matthias van de Meent
Databricks (https://www.databricks.com)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Ilia Evdokimov | 2026-09-21 13:03:44 | Re: Optimize MCV stats for sortable types and utilize sorted-order properties |
| Previous Message | Aleksander Alekseev | 2026-09-21 12:41:54 | Re: Write skew observed under serializable isolation |