SelectStmt containing a larg and rarg as a result of a union could contain uncertainty. However, this uncertainty is not taken into account by the process_select function. In order to resulve this problem:
=== rewrite.c ===
==== process_subquery(SelectStmt *sel) ====
sel->larg = process_select(sel->larg);
sel->rarg = process_select(sel->rarg);
/** ADD */
if (sel->larg->tabletype == TABLETYPE_URELATION || sel->rarg->tabletype == TABLETYPE_URELATION) {
sel->tabletype = TABLETYPE_URELATION;
}
/** ADD */
==== process_select(SelectStmt *sel) ====
if(all_relations_are_certain(list_length(result->fromClause), typeArray) || isCertainSel)
{
/** CHANGED */
if (result->tabletype != TABLETYPE_URELATION ) {
/* Set the tag */
result->tabletype = TABLETYPE_CERTAIN;
}
/** END CHANGED */
}