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, and the destination of the INSERT appears as the first of the
range table entries.  Do I misunderstand the query trees, or the
documentation, or both?

The documentation I quoted is at:

http://www3.us.postgresql.org/users-lounge/docs/7.3/postgres/querytree.html


-- 
Brandon Craig Rhodes                         http://www.rhodesmill.org/brandon
Georgia Tech                                            brandon@oit.gatech.edu

28 Feb 2003 13:17:30 -0500
Brandon Craig Rhodes <brandon@oit.gatech.edu>
result relation used anymore?
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 child tables to the rtable and
     * store a list of the rtindexes of all the result relations here.
     * This is done at plan time, 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;    /* integer list 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

Fri, 28 Feb 2003 15:17:19 -0500
Tom Lane <tgl@sss.pgh.pa.us>
Re: result relation used anymore? 