Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API) - Mailing list pgsql-hackers

From Robert Haas
Subject Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)
Date
Msg-id CA+TgmoYpz=5ZzFBPiLARr-sp2=JvgUXzCiV2=Uwc3XjV4uky0A@mail.gmail.com
Whole thread Raw
In response to Re: Custom/Foreign-Join-APIs (Re: [v9.5] Custom Plan API)  (Kouhei Kaigai <kaigai@ak.jp.nec.com>)
List pgsql-hackers
On Wed, Apr 22, 2015 at 10:48 PM, Kouhei Kaigai <kaigai@ak.jp.nec.com> wrote:
>> +       else if (scan->scanrelid == 0 &&
>> +                        (IsA(scan, ForeignScan) || IsA(scan, CustomScan)))
>> +               varno = INDEX_VAR;
>>
>> Suppose scan->scanrelid == 0 but the scan type is something else?  Is
>> that legal?  Is varno == 0 the correct outcome in that case?
>>
> Right now, no other scan type has capability to return a tuples
> with flexible type/attributes more than static definition.
> I think it is a valid restriction that only foreign/custom-scan
> can have scanrelid == 0.

But the code as you've written it doesn't enforce any such
restriction.  It just spends CPU cycles testing for a condition which,
to the best of your knowledge, will never happen.

If it's really a can't happen condition, how about checking it via an Assert()?

else if (scan->scanrelid == 0)
{   Assert(IsA(scan, ForeignScan) || IsA(scan, CustomScan));   varno = INDEX_VAR;
}

-- 
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company



pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Fwd: [GENERAL] 4B row limit for CLOB tables
Next
From: Amit Kapila
Date:
Subject: Re: Parallel Seq Scan