pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
ERROR:  could not devise a query plan for the given query (UNIONS and LATERAL)
2+ messages / 2 participants
[nested] [flat]

* ERROR:  could not devise a query plan for the given query (UNIONS and LATERAL)
@ 2018-01-23 18:10  Elvis Pranskevichus <elprans@gmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Elvis Pranskevichus @ 2018-01-23 18:10 UTC (permalink / raw)
  To: pgsql-bugs

Hi,

The following (admittedly bizzare) query causes the error in the subject 
on all recent versions of Postgres:

SELECT
        "q2"."v"
    FROM
        LATERAL
        (SELECT
                "q11"."v"
            FROM
                (
                    (SELECT 2::bigint AS "v") UNION ALL
                    (SELECT 3::bigint AS "v")
                ) AS "q11"
        ) AS "q1"
        CROSS JOIN LATERAL
        (
            (SELECT
                "q3"."v"
             FROM
                (
                    (SELECT 4::bigint AS "v") UNION ALL
                    (SELECT 5::bigint AS "v")
                ) AS "q3"
            )
            UNION ALL
            (SELECT "q1"."v")
        ) AS "q2"
    ORDER BY
        "q2"."v"; 


Interestingly, removing UNION from either "q3" or "q11", as well as 
removing the ::bigint casts makes it work.


                            Elvis






^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: ERROR: could not devise a query plan for the given query (UNIONS and LATERAL)
@ 2018-01-23 20:19  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Elvis Pranskevichus <elprans@gmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2018-01-23 20:19 UTC (permalink / raw)
  To: Elvis Pranskevichus <elprans@gmail.com>; +Cc: pgsql-bugs

Elvis Pranskevichus <elprans@gmail.com> writes:
> The following (admittedly bizzare) query causes the error in the subject 
> on all recent versions of Postgres:

Interesting.  What this shows is that reparameterize_path has to be able
to work on an AppendPath, because if you've got nested appendrels that's
the only sort of path there will be for that particular child of the
outer appendrel.

I'm a little worried about whether this doesn't mean that
reparameterize_path needs to be able to work on any kind of path.
However, given that it's been there quite some time without previous
reports of trouble, jumping to that conclusion may be premature.

I'm also wondering where reparameterize_path_by_child came from and
why it's so enormously more ambitious than reparameterize_path
in terms of its path-type coverage.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2018-01-23 20:19 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23 18:10 ERROR:  could not devise a query plan for the given query (UNIONS and LATERAL) Elvis Pranskevichus <elprans@gmail.com>
2018-01-23 20:19 ` Re: ERROR: could not devise a query plan for the given query (UNIONS and LATERAL) Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox