Received: from sss.pgh.pa.us (sss.pgh.pa.us [209.114.132.154] (may be forged)) by hub.org (8.10.1/8.10.1) with ESMTP id e8KGESs96307 for ; Wed, 20 Sep 2000 12:14:28 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.0/8.11.0) with ESMTP id e8KGDCB23702; Wed, 20 Sep 2000 12:13:13 -0400 (EDT) To: ldm@apartia.ch cc: PGSQL-SQL Subject: Re: ERROR: replace_vars_with_subplan_refs (!?) In-reply-to: <20000920171335.A679@styx> References: <39C69B97.58B353A9@ec.gc.ca> <20000920152552.A3958@styx> <19704.969461039@sss.pgh.pa.us> <20000920171335.A679@styx> Comments: In-reply-to Louis-David Mitterrand message dated "Wed, 20 Sep 2000 17:13:35 +0200" Date: Wed, 20 Sep 2000 12:13:12 -0400 Message-ID: <23699.969466392@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200009/152 Louis-David Mitterrand writes: > On Wed, Sep 20, 2000 at 10:43:59AM -0400, Tom Lane wrote: >> Louis-David Mitterrand writes: >>>> How should I interpret that error? >>>> ERROR: replace_vars_with_subplan_refs: variable not in subplan target list >> >> Looks like a bug to me. I think this may already be fixed in current >> sources, but not sure. Could I trouble you for the relevant table >> declarations, so I can try the example without a lot of guessing? > Please find attached the full dump. OK, this is indeed fixed in current sources. I think you are running into the same problem you reported in June, namely that subselects appearing in the targetlist of an Append plan are misprocessed in 7.0.*. Append is mainly used for handling inherited queries, so it's the combination of inheritance and subselect in targetlist that's needed to trigger the bug. This probably also explains the other report you filed this morning; once the subselect is messed up, all sorts of things start to go wrong :-( I think you could back-patch the fix into 7.0.* just by dropping rev 1.64 of setrefs.c into the 7.0 source tree --- see http://www.postgresql.org/cgi/cvswebtest.cgi/pgsql/src/backend/optimizer/plan/setrefs.c for that version. regards, tom lane