Make sure that for base relations, both the paths (left and right)
and join restrictlist are NULL (or NIL for the list). I'm not sure
if this is true for RELOPT_OTHER_MEMBER_REL also, so only do this
for RELOPT_BASEREL.
Perhaps we should also convert the inverse condition (for join
relations) to an assert - currently it's an if condition:
if (rel->reloptkind == RELOPT_JOINREL && (!leftpath || !rightpath))
...
but I've left that alone for now.
switch (rel->reloptkind)
{
case RELOPT_BASEREL:
+
+ /*
+ * For baserels, the left/right path and restrictlist should be NULL.
+ *
+ * XXX I'm not sure if the same is true for other non-join rels, so
+ * let's only add it for the RELOPT_BASEREL case.
+ */
+ Assert(leftpath == NULL && rightpath == NULL && join_restrictlist == NIL);
+
+ /* fall-through */
+
case RELOPT_OTHER_MEMBER_REL:
{
RangeTblEntry *rte = rt_fetch(rel->relid, root->parse->rtable);