Re: `order by random()` makes select-list `random()` invocations deterministic

Поиск
Список
Период
Сортировка
От Dian Fay
Тема Re: `order by random()` makes select-list `random()` invocations deterministic
Дата
Msg-id CZI1U3NKCZDT.31UY6DAFGVXC5@nmfay.com
обсуждение исходный текст
Ответ на Re: `order by random()` makes select-list `random()` invocations deterministic  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: `order by random()` makes select-list `random()` invocations deterministic  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Thu Feb 29, 2024 at 12:53 AM EST, David G. Johnston wrote:
> On Wednesday, February 28, 2024, Dian Fay <di@nmfay.com> wrote:
> >
> >
> > Every `random()` invocation in the select list uses a single consistent
> > value within each returned row. Remove the `order by random()` and
> > values become randomized as expected, but it gets a bit stranger:
> >
> >
> This seems to be one of those “won’t fix” bugs that stems from the parser
> being a bit too liberal in what it accepts as valid SQL.
>
>
> https://www.postgresql.org/message-id/CAKFQuwZ3-XGfcS%2BCLTAYvPx3ARYjUxv%2B%3DYL8sOicV0nda%3DT5cA%40mail.gmail.com
>
> The fact that the gs involving expression is seen differently than the ones
> not involving gs doesn’t surprise me.
>
> David J.

Thanks, that makes sense! Any thoughts on whether it's worth a
cautionary note in the `order by` and/or random function docs since
`order by random()` is a fairly well attested solution and I'm not the
first person to run into this quirk?



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

Предыдущее
От: Thomas Munro
Дата:
Сообщение: Re: BUG #18362: unaccent rules and Old Greek text
Следующее
От: Tom Lane
Дата:
Сообщение: Re: `order by random()` makes select-list `random()` invocations deterministic