BUG #18060: Left joining rows using random() function in join condition doesn't work as expected.

Поиск
Список
Период
Сортировка
От PG Bug reporting form
Тема BUG #18060: Left joining rows using random() function in join condition doesn't work as expected.
Дата
Msg-id 18060-e59408b5655979ed@postgresql.org
обсуждение исходный текст
Ответы Re: BUG #18060: Left joining rows using random() function in join condition doesn't work as expected.  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
The following bug has been logged on the website:

Bug reference:      18060
Logged by:          James Inform
Email address:      james.inform@pharmapp.de
PostgreSQL version: 15.4
Operating system:   Linux and Mac
Description:

/*
    PostgreSQL 14.9 / 15.4 on Linux and Mac
    
    Left joining rows using random() function in join condition
    doesn't work as expected.
   
   
    I have encountered this while I was trying randomly left join a record
of a source table
    with exactly with one record of a link table.
    
    Just execute the create statements under 1.
    
    Then execute the select under 2. multiple times and watch thee
results.
 */

-- 1. Generate two tables (source and link) with 1000 rows having gapless
ids
create temp table source as
select source_id, 'source' as source_name from generate_series(1,1000) as
source_id
;

create temp table link as
select link_id, 'link' as link_name from generate_series(1,1000) as
link_id
;

-- 2. Execute this query multiple time and you will see results where:
-- * no rows from link are joined
-- * extactly one row is joined
-- * multiple rows are joined

select * from source left join link on link_id = 1 + (random()*500)::int8
order by 1

/*
I would expect always exactly one row to be joined. 
Instead I get 1, none or multiple.

Is this an error or am I doing something wrong?
*/


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

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #18057: unaccent removes intentional spaces
Следующее
От: "yanliang lei"
Дата:
Сообщение: Re:Re: BUG #18034: Accept the spelling "+infinity" in datetime input is not accurate