Errors "failed to construct the join relation" and "failed to build any 2-way joins"

From: Will Leinweber <will(at)bitfission(dot)com>
To: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Errors "failed to construct the join relation" and "failed to build any 2-way joins"
Date: 2019-12-12 23:32:05
Message-ID: CALLb-4xJMd4GZt2YCecMC95H-PafuWNKcmps4HLRx2NHNBfB4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 12.1, fresh initdb the following query gives me the error
"ERROR: failed to construct the join relation"

SELECT FROM (
SELECT FROM pg_catalog.pg_stat_bgwriter AS ref_0
LEFT JOIN pg_catalog.pg_stat_bgwriter AS ref_1 ON (true), LATERAL (
SELECT FROM pg_catalog.pg_publication AS ref_2, LATERAL (
SELECT FROM pg_catalog.pg_class
WHERE ref_1.buffers_alloc IS NOT NULL
) AS subq_0
WHERE true
LIMIT 1
) AS subq_1
WHERE true
) AS subq_2

If you move the limit up into subq_0, then the error changes to
"ERROR: failed to build any 2-way joins"

SELECT FROM (
SELECT FROM pg_catalog.pg_stat_bgwriter AS ref_0
LEFT JOIN pg_catalog.pg_stat_bgwriter AS ref_1 ON (true), LATERAL (
SELECT FROM pg_catalog.pg_publication AS ref_2, LATERAL (
SELECT FROM pg_catalog.pg_class
WHERE ref_1.buffers_alloc IS NOT NULL
LIMIT 1
) AS subq_0
WHERE true
) AS subq_1
WHERE true
) AS subq_2

I'm unable to reproduce either of the errors on 11.6 or 11.4. I haven't tried
any other versions. The actual value of the limit doesn't appear to matter,
just if it's present or not.

— Will

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2019-12-13 02:03:47 Re: shared tempfile was not removed on statement_timeout (unreproducible)
Previous Message Tomas Vondra 2019-12-12 23:25:26 Re: Corruption with duplicate primary key