Errors "failed to construct the join relation" and "failed to buildany 2-way joins" - Mailing list pgsql-hackers

From Will Leinweber
Subject Errors "failed to construct the join relation" and "failed to buildany 2-way joins"
Date
Msg-id CALLb-4xJMd4GZt2YCecMC95H-PafuWNKcmps4HLRx2NHNBfB4g@mail.gmail.com
Whole thread Raw
Responses Re: Errors "failed to construct the join relation" and "failed to build any 2-way joins"  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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



pgsql-hackers by date:

Previous
From: Tomas Vondra
Date:
Subject: Re: Corruption with duplicate primary key
Next
From: Thomas Munro
Date:
Subject: Re: shared tempfile was not removed on statement_timeout (unreproducible)