Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TrYMY-00085j-Ja for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Jan 2013 18:20:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.72) (envelope-from ) id 1TrYMX-0005nx-Aw for pgsql-bugs@arkaria.postgresql.org; Sat, 05 Jan 2013 18:20:53 +0000 Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TrCzL-0007zV-BP for pgsql-bugs@postgresql.org; Fri, 04 Jan 2013 19:31:31 +0000 Received: from mahout.postgresql.org ([98.129.198.123]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TrCzG-0001f6-Me for pgsql-bugs@postgresql.org; Fri, 04 Jan 2013 19:31:30 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TrCzG-0006yt-2f for pgsql-bugs@postgresql.org; Fri, 04 Jan 2013 19:31:26 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.72) (envelope-from ) id 1TrCzF-0000p9-Du for pgsql-bugs@postgresql.org; Fri, 04 Jan 2013 19:31:25 +0000 Date: Fri, 04 Jan 2013 19:31:25 +0000 Message-Id: Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: BUG #7787: ERROR: could not find RelOptInfo for given relids To: pgsql-bugs@postgresql.org From: gdurbin@synchr.com X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 7787 Logged by: Gary Durbin Email address: gdurbin@synchr.com PostgreSQL version: 9.1.7 Operating system: "(Red Hat 4.4.6-4), 64-bit" Description:=20=20=20=20=20=20=20=20 Two queries follow. The first gets the error, the second doesn't the only difference is the additional expression in the where clause in the inner join. Fail: SELECT * FROM person p JOIN person_dependent_relationship pdr ON p.personid=3Dpdr.personid AND CURRENT_DATE BETWEEN pdr.effectivedate AND pdr.enddate AND CURRENT_TIMESTAMP BETWEEN pdr.createts AND pdr.endts JOIN dependent_enrollment de ON pdr.dependentid=3Dde.dependentid AND de.createts=3DTIMESTAMP WITH time ZONE '2199-12-31 +0' JOIN person_bene_election pbe ON pbe.personid =3D p.personid AND pbe.effectivedate =3D de.effectivedate AND pbe.createts =3D TIMESTAMP WITH time ZONE '2199-12-31 +0' AND pbe.benefitsubclass =3D de.benefitsubclass AND pbe.selectedoption =3D 'Y' AND pbe.benefitelection =3D 'E' LEFT JOIN /*CX_DEPENROLLAGELIMIT*/ (Select p.personid as userid , de.dependentid , de.benefitplanid , de.dependentenrollpid from dependent_enrollment de cross JOIN person p JOIN benefit_plan_desc bpd on bpd.benefitplanid =3D de.benefitplanid and de.effectivedate between bpd.effectivedate and bpd.enddate=20 and current_timestamp between bpd.createts and bpd.endts=20 JOIN AllowedDependents pdr on pdr.dependentid =3D de.dependentid and de.effectivedate between pdr.effectivedate and pdr.enddate JOIN dependent_desc dd ON dd.dependentid=3Dde.dependentid AND dd.effectivedate <=3D dd.enddate AND de.effectivedate BETWEEN dd.effectivedate AND dd.enddate LEFT JOIN person_vitals pv on pdr.dependentid =3D pv.personid AND de.effectivedate BETWEEN pv.effectivedate AND pv.enddate AND current_timestamp BETWEEN pv.createts AND pv.endTS LEFT JOIN Benefit_Calc_Rule_Desc bcrd ON bcrd.benefitcalcruleid =3D bpd.benefitcalcruleid AND de.effectivedate between bcrd.EffectiveDate and bcrd.EndDate and current_timestamp between bcrd.CreateTS and bcrd.EndTs where de.selectedoption=3D'Y' and (pdr.dependentrelationship not IN ('SP','DP','H','NA') AND (pv.birthdate IS NOT NULL=20 AND (bpd.dependentagelimit IS not NULL and extract(years from age( de.EffectiveDate, pv.BirthDate))>bpd.dependentagelimit)) ) AND dd.dependentstatus<> 'D') cx ON cx.userid =3D p.personid AND cx.dependentid =3D de.dependentid AND cx.benefitplanid =3D pbe.benefitplanid WHERE p.personid=3D'25237' AND cx.dependentid IS NULL Not fail: SELECT * FROM person p JOIN person_dependent_relationship pdr ON p.personid=3Dpdr.personid AND CURRENT_DATE BETWEEN pdr.effectivedate AND pdr.enddate AND CURRENT_TIMESTAMP BETWEEN pdr.createts AND pdr.endts JOIN dependent_enrollment de ON pdr.dependentid=3Dde.dependentid AND de.createts=3DTIMESTAMP WITH time ZONE '2199-12-31 +0' JOIN person_bene_election pbe ON pbe.personid =3D p.personid AND pbe.effectivedate =3D de.effectivedate AND pbe.createts =3D TIMESTAMP WITH time ZONE '2199-12-31 +0' AND pbe.benefitsubclass =3D de.benefitsubclass AND pbe.selectedoption =3D 'Y' AND pbe.benefitelection =3D 'E' LEFT JOIN /*CX_DEPENROLLAGELIMIT*/ (Select p.personid as userid , de.dependentid , de.benefitplanid , de.dependentenrollpid from dependent_enrollment de cross JOIN person p JOIN benefit_plan_desc bpd on bpd.benefitplanid =3D de.benefitplanid and de.effectivedate between bpd.effectivedate and bpd.enddate=20 and current_timestamp between bpd.createts and bpd.endts=20 JOIN AllowedDependents pdr on pdr.dependentid =3D de.dependentid and de.effectivedate between pdr.effectivedate and pdr.enddate JOIN dependent_desc dd ON dd.dependentid=3Dde.dependentid AND dd.effectivedate <=3D dd.enddate AND de.effectivedate BETWEEN dd.effectivedate AND dd.enddate LEFT JOIN person_vitals pv on pdr.dependentid =3D pv.personid AND de.effectivedate BETWEEN pv.effectivedate AND pv.enddate AND current_timestamp BETWEEN pv.createts AND pv.endTS LEFT JOIN Benefit_Calc_Rule_Desc bcrd ON bcrd.benefitcalcruleid =3D bpd.benefitcalcruleid AND de.effectivedate between bcrd.EffectiveDate and bcrd.EndDate and current_timestamp between bcrd.CreateTS and bcrd.EndTs where de.selectedoption=3D'Y' and (pdr.dependentrelationship not IN ('SP','DP','H','NA') AND (pv.birthdate IS NOT NULL=20 AND (bpd.dependentagelimit IS not NULL and extract(years from age( de.EffectiveDate, pv.BirthDate))>bpd.dependentagelimit)) ) AND dd.dependentstatus<> 'D' /* Following line was added */ and (bcrd.benefitcalcruleid =3D bpd.benefitcalcruleid or bcrd.benefitcalcruleid is null) ) cx ON cx.userid =3D p.personid AND cx.dependentid =3D de.dependentid AND cx.benefitplanid =3D pbe.benefitplanid WHERE p.personid=3D'25237' AND cx.dependentid IS NULL =20=20 --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs