Re: New function normal_rand_array function to contrib/tablefunc.

From: Japin Li <japinli(at)hotmail(dot)com>
To: Andy Fan <zhihuifan1213(at)163(dot)com>
Cc: Dean Rasheed <dean(dot)a(dot)rasheed(at)gmail(dot)com>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, Postgres hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: New function normal_rand_array function to contrib/tablefunc.
Date: 2024-08-28 05:22:42
Message-ID: ME0P300MB044589098B6FB20AA771C97DB6952@ME0P300MB0445.AUSP300.PROD.OUTLOOK.COM
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 28 Aug 2024 at 12:27, Andy Fan <zhihuifan1213(at)163(dot)com> wrote:
> Japin Li <japinli(at)hotmail(dot)com> 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.")));
>>
>> There error message should be "minlen must be smaller than maxlen", right?
>>
>> + if (minlen < 0)
>> + ereport(ERROR,
>> + (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
>> + errmsg("minlen and maxlen must be greater than zero.")));
>>
>> Here the minlen might be zero, so the error message is incorrect.
>> How about use "minlen must be greater than or equal to zero"?
>
> Yes, you are right. A new version is attached, thanks for checking!
>

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 row has four items, I can use the following

SELECT rand_array(10, 4, 4, 50::int, 80::int);

OTOH, I find the range bound uses "less than or equal to", how about
replacing "smaller" with "less"?

--
Regrads,
Japin Li

Attachment Content-Type Size
less.patch text/x-diff 637 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message shveta malik 2024-08-28 05:28:22 Re: Conflict Detection and Resolution
Previous Message Ajin Cherian 2024-08-28 05:00:08 Re: Conflict Detection and Resolution