Re: [SQL] could not devise a query plan

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Szűcs Gábor <surrano(at)gmail(dot)com>
Cc: "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: [SQL] could not devise a query plan
Date: 2005-05-24 18:12:25
Message-ID: 4474.1116958345@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-sql

=?ISO-8859-2?Q?Sz=FBcs_G=E1bor?= <surrano(at)gmail(dot)com> writes:
> ABSTRACT: The following query fails.

> SELECT * FROM
> (SELECT a,b FROM cdqp WHERE a=1 AND b=2) AS aa
> NATURAL FULL JOIN
> (SELECT a,b FROM cdqp WHERE a=1 and b=2) AS bb
> WHERE a+b = 3;

Thanks for the report! Seems I overlooked a case when fixing the
original report last year. Patch for 8.0 attached (it's the same in
7.4 too).

regards, tom lane

Index: joinpath.c
===================================================================
RCS file: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v
retrieving revision 1.91.4.1
diff -c -r1.91.4.1 joinpath.c
*** joinpath.c 23 Jan 2005 02:22:27 -0000 1.91.4.1
--- joinpath.c 24 May 2005 17:54:15 -0000
***************
*** 498,512 ****
* nestloop path, but since mergejoin is our only join type that
* supports FULL JOIN, it's necessary to generate a clauseless
* mergejoin path instead.
- *
- * Unfortunately this can't easily be extended to handle the case
- * where there are joinclauses but none of them use mergejoinable
- * operators; nodeMergejoin.c can only do a full join correctly if
- * all the joinclauses are mergeclauses.
*/
if (mergeclauses == NIL)
{
! if (jointype == JOIN_FULL && restrictlist == NIL)
/* okay to try for mergejoin */ ;
else
continue;
--- 498,507 ----
* nestloop path, but since mergejoin is our only join type that
* supports FULL JOIN, it's necessary to generate a clauseless
* mergejoin path instead.
*/
if (mergeclauses == NIL)
{
! if (jointype == JOIN_FULL)
/* okay to try for mergejoin */ ;
else
continue;

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Alain 2005-05-24 18:26:50 Tip ?
Previous Message Bruno Wolff III 2005-05-24 17:48:48 Re: Bulletin Board

Browse pgsql-sql by date

  From Date Subject
Next Message Tony Wasson 2005-05-24 18:15:12 Re: Help: Function for splitting VARCHAR column and migrating its data to 2 new tables
Previous Message CG 2005-05-24 17:44:54 DROP IF ...