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 CAJ7c6TOhwhK1=s9mwaSQy2jWvban1OZ4rz7_pLCvb+NbdiQ6Wg@mail.gmail.com
Whole thread Raw
In response to Re: New function normal_rand_array function to contrib/tablefunc.  (Dean Rasheed <dean.a.rasheed@gmail.com>)
Responses Re: New function normal_rand_array function to contrib/tablefunc.
List pgsql-hackers
Hi Dean,

Thanks for your input.

> > Any reason not to have an interface as simple and straightforward as
> > this:
> >
> > =# SELECT array_random(1, 10, random(0, 3)) FROM generate_series( ... )
> > {5}
> > {1, 3, 8}
> > {7, 6}
> > ...
> >
>
> Yeah, that looks like a neater API.
>
> Something that bothers me somewhat is that it's completely trivial for
> the user to write such a function for themselves, so is it really
> useful enough to include in core?

I think it would be useful. Many users don't bother writing C
extensions for tasks like this. So at least our implementation is
going to be faster.

> The other question is whether it's an array function or a random
> function. I.e., should it be listed in "Table 9.55. Array Functions",
> in which case the name array_random() makes sense, or should it be
> listed in "Table 9.6. Random Functions", in which case it should
> probably be called random_array(). I think the latter makes more
> sense, since it's a function that generates random values, more
> similar to the random(min, max) functions. Also I think it's more
> useful if it shares the same PRNG, controlled by setseed(), and it
> makes sense to group all such functions together.

Good point. Personally I don't have a strong opinion on whether
random_array() or array_random() is preferable, for me either option
is OK. Perhaps we should cross-reference the function between two
sections of the documentation to make it easier to find.

-- 
Best regards,
Aleksander Alekseev



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: doc: pgevent.dll location
Next
From: Dave Page
Date:
Subject: Re: doc: pgevent.dll location