Re: Functions to return random numbers in a given range

Поиск
Список
Период
Сортировка
От Dean Rasheed
Тема Re: Functions to return random numbers in a given range
Дата
Msg-id CAEZATCUTFWY5-DXXHSoWVTjNeuG+5SUrhMQ9PDJvVPza5op4Tg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Functions to return random numbers in a given range  (jian he <jian.universality@gmail.com>)
Список pgsql-hackers
On Thu, 28 Dec 2023 at 07:34, jian he <jian.universality@gmail.com> wrote:
>
> Your patch works.
> performance is the best amount for other options in [0].
> I don't have deep knowledge about which one is more random.
>

Thanks for testing.

> Currently we have to explicitly mention the lower and upper bound.
> but can we do this:
> just give me an int, int means the int data type can be represented.
> or just give me a random bigint.
> but for numeric, the full numeric values that can be represented are very big.
>
> Maybe we can use the special value null to achieve this
> like use
> select random(NULL::int,null)
> to represent a random int in the full range of integers values can be
> represented.
>

Hmm, I don't particularly like that idea. It seems pretty ugly. Now
that we support literal integers in hex, with underscores, it's
relatively easy to pass INT_MIN/MAX as arguments to these functions,
if that's what you need. I think if we were going to have a shorthand
for getting full-range random integers, it would probably be better to
introduce separate no-arg functions for that. I'm not really sure if
that's a sufficiently common use case to justify the effort though.

Regards,
Dean



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Jelte Fennema-Nio
Дата:
Сообщение: Re: [EXTERNAL] Re: Add non-blocking version of PQcancel
Следующее
От: Alexander Kuzmenkov
Дата:
Сообщение: Incorrect cost for MergeAppend