Brandon Craig Rhodes <brandon@oit.gatech.edu> writes:
> While learning how to read query trees, I have been puzzled by the
> assertion in the manual that the :resultRelations of an INSERT holds
> `the table (or view!) where the changes take effect,' because in all
> of the INSERTs I have generated the resultRelation in fact appears
> empty,
You seem to be confusing resultRelation with resultRelations. The
documentation is speaking of the former. Of the latter, parsenodes.h
says
/* * If the resultRelation turns out to be the parent of an inheritance * tree, the planner will add all the
childtables to the rtable and * store a list of the rtindexes of all the result relations here. * This is done at
plantime, not parse time, since we don't want to * commit to the exact set of child tables at parse time. This
field * ought to go in some sort of TopPlan plan node, not in the Query. */ List *resultRelations; /*
integerlist of RT indexes, or NIL */
Note in particular that this only gets set when the target is an
inheritance tree --- which, by definition, it never is for INSERT.
regards, tom lane