From: | PG Bug reporting form <noreply(at)postgresql(dot)org> |
---|---|
To: | pgsql-bugs(at)lists(dot)postgresql(dot)org |
Cc: | james(dot)inform(at)pharmapp(dot)de |
Subject: | BUG #18060: Left joining rows using random() function in join condition doesn't work as expected. |
Date: | 2023-08-18 09:30:51 |
Message-ID: | 18060-e59408b5655979ed@postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
The following bug has been logged on the website:
Bug reference: 18060
Logged by: James Inform
Email address: james(dot)inform(at)pharmapp(dot)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?
*/
From | Date | Subject | |
---|---|---|---|
Next Message | yanliang lei | 2023-08-18 13:57:17 | Re:Re: BUG #18034: Accept the spelling "+infinity" in datetime input is not accurate |
Previous Message | torikoshia | 2023-08-18 06:40:57 | Re: pg_rewind WAL segments deletion pitfall |