Don't remove the 'alias' field from flattened rangetable entries;
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 6 Apr 2007 22:57:20 +0000 (22:57 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 6 Apr 2007 22:57:20 +0000 (22:57 +0000)
there are some corner cases where this is needed by ruleutils.c for
proper display of variables during EXPLAIN.

src/backend/optimizer/plan/setrefs.c

index 5c11d788e00247d7f3e673962975e1f0b0487a95..0739142403e021f7a6223e9b59c8f3c1162838a7 100644 (file)
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.133 2007/02/23 21:59:44 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/optimizer/plan/setrefs.c,v 1.134 2007/04/06 22:57:20 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -156,7 +156,8 @@ set_plan_references(PlannerGlobal *glob, Plan *plan, List *rtable)
    /*
     * In the flat rangetable, we zero out substructure pointers that are
     * not needed by the executor; this reduces the storage space and
-    * copying cost for cached plans.
+    * copying cost for cached plans.  We keep only the alias and eref
+    * Alias fields, which are needed by EXPLAIN.
     */
    foreach(lc, rtable)
    {
@@ -167,14 +168,13 @@ set_plan_references(PlannerGlobal *glob, Plan *plan, List *rtable)
        newrte = (RangeTblEntry *) palloc(sizeof(RangeTblEntry));
        memcpy(newrte, rte, sizeof(RangeTblEntry));
 
-       /* zap unneeded sub-structure (we keep only the eref Alias) */
+       /* zap unneeded sub-structure */
        newrte->subquery = NULL;
        newrte->funcexpr = NULL;
        newrte->funccoltypes = NIL;
        newrte->funccoltypmods = NIL;
        newrte->values_lists = NIL;
        newrte->joinaliasvars = NIL;
-       newrte->alias = NULL;
 
        glob->finalrtable = lappend(glob->finalrtable, newrte);
    }