To save cycles, I modified create_foreignscan_plan so that it detects whether any system columns are requested if scanning a base relation. Also, I revised other code there a little bit.
For ExecInitForeignScan, I simplified the code there to determine the scan tuple type, whith seems to me complex beyound necessity. Maybe that might be nitpicking, though.
I just glanced at this and noticed that the method for determining if there's any system columns could be made a bit nicer.
/* Now, are any system columns requested from rel? */
scan_plan->fsSystemCol = false;
for (i = FirstLowInvalidHeapAttributeNumber + 1; i < 0; i++)
{
if (bms_is_member(i - FirstLowInvalidHeapAttributeNumber, attrs_used))
{
scan_plan->fsSystemCol = true;
break;
}
}
I think could just be written as:
/* Now, are any system columns requested from rel? */