New function normal_rand_array function to contrib/tablefunc.

2024-06-07 Thread Andy Fan
Here is a new function which could produce an array of numbers with a controllable array length and duplicated elements in these arrays. I used it when working with gin index, and I think it would be helpful for others as well, so here it is. select * from normal_rand_array(5, 10, 1.8::numeric, 3

Re: New function normal_rand_array function to contrib/tablefunc.

2024-06-24 Thread Stepan Neretin
It looks useful, for example, it can be used in sorting tests to make them more interesting. I just have one question. Why are you using SRF_IS_FIRST CALL and not _PG_init? Best regards, Stepan Neretin.

Re: New function normal_rand_array function to contrib/tablefunc.

2024-07-02 Thread Jim Jones
Hi Andy On 08.06.24 08:05, Andy Fan wrote: > Here is a new function which could produce an array of numbers with a > controllable array length and duplicated elements in these arrays. I > used it when working with gin index, and I think it would be helpful for > others as well, so here it is. > >

Re: New function normal_rand_array function to contrib/tablefunc.

2024-07-15 Thread Dean Rasheed
On Tue, 2 Jul 2024 at 11:18, Jim Jones wrote: > > When either minval or maxval exceeds int4 the function cannot be > executed/found > > SELECT * FROM normal_rand_array(5, 10, 8, 42::bigint); > > ERROR: function normal_rand_array(integer, integer, integer, bigint) > does not exist > LINE 1: SELECT

Re: New function normal_rand_array function to contrib/tablefunc.

2024-07-16 Thread Andy Fan
Dean Rasheed writes: > My suggestion would be to mirror the signatures of the core random() > functions more closely, and have this: > > 1). rand_array(numvals int, minlen int, maxlen int) > returns setof float8[] > > 2). rand_array(numvals int, minlen int, maxlen int, >minval

Re: New function normal_rand_array function to contrib/tablefunc.

2024-07-16 Thread Andy Fan
Andy Fan writes: (just noticed this reply is sent to Jim privately, re-sent it to public.) > Hi Jim, > >> >> When either minval or maxval exceeds int4 the function cannot be >> executed/found >> >> SELECT * FROM normal_rand_array(5, 10, 8, 42::bigint); >> >> ERROR:  function normal_rand_array(i

Re: New function normal_rand_array function to contrib/tablefunc.

2024-07-17 Thread Dean Rasheed
On Wed, 17 Jul 2024 at 07:29, Andy Fan wrote: > > It is just not clear to me how verbose the document should to be, and > where the document should be, tablefunc.sgml, the comment above the > function or the places just the code? In many cases you provides above > or below are just implementation

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-26 Thread Andy Fan
Dean Rasheed writes: Hello Dean, >> I did have some issue to run 'make html', but the >> error exists before my patch, so I change the document carefully without >> testing it. do you know how to fix the below error in 'make html'? >> >> $/usr/bin/xsltproc --nonet --path . --path . --stringpara

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-27 Thread Andy Fan
Andy Fan writes: >>> My suggestion would be to mirror the signatures of the core random() >>> functions more closely, and have this: >>> >>> 1). rand_array(numvals int, minlen int, maxlen int) >>> returns setof float8[] >>> > ..> >>> 4). rand_array(numvals int, minlen int, maxlen int, >>>

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-27 Thread Japin Li
On Tue, 27 Aug 2024 at 16:43, Andy Fan wrote: > Andy Fan writes: > My suggestion would be to mirror the signatures of the core random() functions more closely, and have this: 1). rand_array(numvals int, minlen int, maxlen int) returns setof float8[] >> ..> 4

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-27 Thread Andy Fan
Japin Li writes: > Thanks for updating the patch. Here are some comments. > > + if (minlen >= maxlen) > + ereport(ERROR, > + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), > + errmsg("minlen must be greater than > maxlen.")));

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-27 Thread Japin Li
On Wed, 28 Aug 2024 at 12:27, Andy Fan wrote: > Japin Li writes: > > >> Thanks for updating the patch. Here are some comments. >> >> +if (minlen >= maxlen) >> +ereport(ERROR, >> +(errcode(ERRCODE_INVALID_PARAMETER_VALUE), >> +

Re: New function normal_rand_array function to contrib/tablefunc.

2024-08-28 Thread Andy Fan
Japin Li writes: > On Wed, 28 Aug 2024 at 12:27, Andy Fan wrote: >> Japin Li writes: >> > Nitpick, the minlen is smaller than maxlen, so the maxlen cannot be zero. > > After giving it some more thought, it would also be helpful if maxlen is > equal to minlen. > > For example, I want have each r