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