Currently when we call select_common_type, it compares the 2 exprs, if the expr
type of both are unknown, it will be set to TEXTOID with some reasons, which
can cause the issue like below.
postgres=# select null union all select null union all select 1;
ERROR: UNION types text and integer cannot be matched
LINE 1: select null union all select null union all select 1;
In this case, we can't blame the user, they may want the nulls to be at the top
of the result.
I worked on a patch to fix this, the main idea is before going to the above
logic, I peak all the exprs for a given column first, and choose a default one
when we see the Unknown & Unknown case(rather than TextOid),
do you think it is ok?
--