The loop over in subquery_planner() looked about like this:
for (i = 1; i < root->simple_rel_array_size - 1; i++)
which fails to check the last element in the array, due to a trivial
off-by-one error. Instead, the loop should be:
for (i = 1; i < root->simple_rel_array_size; i++)
recursiveOk = true;
/* seems to start at 1... */
- for (idx = 1; idx < root->simple_rel_array_size - 1 && recursiveOk; idx++)
+ for (idx = 1; idx < root->simple_rel_array_size && recursiveOk; idx++)
{
RangeTblEntry *rte;