Re: array_random

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: array_random
Date: 2025-07-05 03:35:28
Message-ID: CACJufxH89EiwapAfOQOqMMQWw11RYb=N68N=BF17KJ7x=O9dFQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 30, 2025 at 11:04 PM jian he <jian(dot)universality(at)gmail(dot)com> wrote:
>
> demo:
> SELECT array_random(1, 6, array[2,5], array[2,4]);
> array_random
> --------------------------------------
> [2:3][4:8]={{6,2,2,5,4},{4,5,6,4,6}}
>
> reasons for adding array_random is:
> 1. This is better than array_fill. This can fill random and constant
> values (random, min and max the same).
> 2. Building a multi-dimensional PL/pgSQL function equivalent to
> array_random is not efficient and is also not easier.
>
> [1] https://www.postgresql.org/message-id/CACJufxGRCP19Rm66%3DTSBwmEuVr92FwL_e6YFjmCpJrgu6Km9hQ%40mail.gmail.com

i didn't use ./src/include/catalog/duplicate_oids
then there is some duplicated oid issue.
the attached patch fixes this issue.

Attachment Content-Type Size
v2-0001-array_random.patch text/x-patch 21.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-07-05 04:15:59 Re: Get rid of WALBufMappingLock
Previous Message Noah Misch 2025-07-05 03:01:07 Re: Non-blocking archiver process