OK, seems it is resolved. We now throw a warning for the query.
> >> What it looks like to me is that we have a bug in the expansion of '*'.
> >> It should be generating columns for both the explicit and the implicit
> >> FROM clause, but it's evidently deciding that it should only produce
> >> output columns for the first one.
>
> I thought that the behavior had something to do with the fact that
> the underlying table was the same for both the explicit and the implicit
> rangetable entry, but not so. In fact, ExpandAllTables() deliberately
> refrains from expanding implicit entries, and always has AFAICT:
>
> /*
> * we only expand those listed in the from clause. (This will
> * also prevent us from using the wrong table in inserts: eg.
> * tenk2 in "insert into tenk2 select * from tenk1;")
> */
> if (!rte->inFromCl)
> continue;
>
> I think the comment in parentheses is no longer applicable, but there
> are other sources of implicit rangetable entries besides this particular
> feature --- rules and set functions both seem to add them. So I'm not
> sure what we might break by changing it.
>
> I'm inclined to leave this behavior alone, and go back to the idea of
> emitting warning notices when an implicit FROM clause is added.
>
> regards, tom lane
>
-- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610)
853-3000+ If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill,
Pennsylvania19026