Re: New function normal_rand_array function to contrib/tablefunc. - Mailing list pgsql-hackers

From Aleksander Alekseev
Subject Re: New function normal_rand_array function to contrib/tablefunc.
Date
Msg-id CAJ7c6TNO_a0RZdV68TzaxRur1=Hcuxo7zyYGnxCMUnbfChyAZA@mail.gmail.com
Whole thread Raw
In response to Re: New function normal_rand_array function to contrib/tablefunc.  (Andy Fan <zhihuifan1213@163.com>)
Responses Re: New function normal_rand_array function to contrib/tablefunc.
List pgsql-hackers
Hi everyone,

> >>  Thanks for the detailed feedback! Here is the rebased version.
> >>
> >
> > I took another look at this and I think it's in reasonable shape.
> >
> > I'm attaching an update, rebasing it on top of 9be4e5d293.
>
> Thank you Dean.
>
> > Also it was missing a required update to the meson.build file --
> > that's the immediate cause of the other cfbot failures.
>
> OK, great to know this one, I should have paid more attention to cfbot.
>
> > The rest is just cosmetic tidying up, fixing indentation, tweaking
> > comments, and the like. I also hacked on the docs a bit -- the
> > synopsis only listed one of the new function signatures for some
> > reason. After fixing that, I think it's sufficient to just list one
> > usage example.
>
> That looks better now, more concise and expressive sentences.

I played with patch v3. All in all it seems to be in good shape.

I wonder though whether tablefunc extension is the right place for the
function. To me it seems to be as useful as array_shuffle().

Personally I would name the function array_rand() in order to be
consistent with the rest of array_* functions [1].

I would also replace `minlen` and `maxlen` arguments with a single
`len` argument because the same result (although more slowly) can be
achieved like this:

SELECT trim_array(arr, random(0,3)) FROM rand_array(10, 3, 3, 50::int,
80::int) as arr;

This could be just a bike-shedding though. Does anyone feel necessary
to second any of these nitpicks?

[1]: https://www.postgresql.org/docs/current/functions-array.html

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: pgsql: Implement pg_wal_replay_wait() stored procedure
Next
From: Bruce Momjian
Date:
Subject: pg_dump --no-comments confusion