pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #7787: ERROR:  could not find RelOptInfo for given relids
2+ messages / 2 participants
[nested] [flat]

* BUG #7787: ERROR:  could not find RelOptInfo for given relids
@ 2013-01-04 19:31  gdurbin@synchr.com
  0 siblings, 1 reply; 2+ messages in thread

From: gdurbin@synchr.com @ 2013-01-04 19:31 UTC (permalink / raw)
  To: pgsql-bugs

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:        

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=pdr.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=de.dependentid
AND de.createts=TIMESTAMP WITH time ZONE '2199-12-31 +0'
JOIN person_bene_election pbe ON pbe.personid = p.personid
AND pbe.effectivedate = de.effectivedate
AND pbe.createts = TIMESTAMP WITH time ZONE '2199-12-31 +0'
AND pbe.benefitsubclass = de.benefitsubclass
AND pbe.selectedoption = 'Y'
AND pbe.benefitelection = '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 = de.benefitplanid and
de.effectivedate between bpd.effectivedate and bpd.enddate 
and current_timestamp between bpd.createts and bpd.endts 
JOIN AllowedDependents pdr
  on pdr.dependentid = de.dependentid and de.effectivedate between
pdr.effectivedate and pdr.enddate
JOIN dependent_desc dd
  ON dd.dependentid=de.dependentid
 AND dd.effectivedate <= dd.enddate
 AND de.effectivedate BETWEEN dd.effectivedate AND dd.enddate
LEFT JOIN person_vitals pv on pdr.dependentid = 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 = bpd.benefitcalcruleid
		AND de.effectivedate between bcrd.EffectiveDate and bcrd.EndDate
	   and current_timestamp between bcrd.CreateTS and bcrd.EndTs
where  de.selectedoption='Y'  and (pdr.dependentrelationship not IN
('SP','DP','H','NA') AND  (pv.birthdate IS NOT NULL 
  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 = p.personid
AND cx.dependentid = de.dependentid
AND cx.benefitplanid = pbe.benefitplanid

WHERE p.personid='25237'
  AND cx.dependentid IS NULL

Not fail:

SELECT   *
FROM person p
JOIN person_dependent_relationship pdr ON p.personid=pdr.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=de.dependentid
AND de.createts=TIMESTAMP WITH time ZONE '2199-12-31 +0'
JOIN person_bene_election pbe ON pbe.personid = p.personid
AND pbe.effectivedate = de.effectivedate
AND pbe.createts = TIMESTAMP WITH time ZONE '2199-12-31 +0'
AND pbe.benefitsubclass = de.benefitsubclass
AND pbe.selectedoption = 'Y'
AND pbe.benefitelection = '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 = de.benefitplanid and
de.effectivedate between bpd.effectivedate and bpd.enddate 
and current_timestamp between bpd.createts and bpd.endts 
JOIN AllowedDependents pdr
  on pdr.dependentid = de.dependentid and de.effectivedate between
pdr.effectivedate and pdr.enddate
JOIN dependent_desc dd
  ON dd.dependentid=de.dependentid
 AND dd.effectivedate <= dd.enddate
 AND de.effectivedate BETWEEN dd.effectivedate AND dd.enddate
LEFT JOIN person_vitals pv on pdr.dependentid = 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 = bpd.benefitcalcruleid
		AND de.effectivedate between bcrd.EffectiveDate and bcrd.EndDate
	   and current_timestamp between bcrd.CreateTS and bcrd.EndTs
where  de.selectedoption='Y'  and (pdr.dependentrelationship not IN
('SP','DP','H','NA') AND  (pv.birthdate IS NOT NULL 
  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 = bpd.benefitcalcruleid or
bcrd.benefitcalcruleid is null) )
 cx ON cx.userid = p.personid
AND cx.dependentid = de.dependentid
AND cx.benefitplanid = pbe.benefitplanid

WHERE p.personid='25237'
  AND cx.dependentid IS NULL
  



-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



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

* Re: BUG #7787: ERROR: could not find RelOptInfo for given relids
@ 2013-01-05 18:32  Tom Lane <tgl@sss.pgh.pa.us>
  parent: gdurbin@synchr.com
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2013-01-05 18:32 UTC (permalink / raw)
  To: gdurbin@synchr.com; +Cc: pgsql-bugs

gdurbin@synchr.com writes:
> 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.

This is not investigatable without a self-contained test case.
The problem query alone is not useful, especially not when it's
this complicated.

http://www.postgresql.org/docs/9.1/static/bug-reporting.html

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



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


end of thread, other threads:[~2013-01-05 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2013-01-04 19:31 BUG #7787: ERROR:  could not find RelOptInfo for given relids gdurbin@synchr.com
2013-01-05 18:32 ` Re: BUG #7787: ERROR: could not find RelOptInfo for given relids 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