diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c
index f35e87962dac21f7eafa04f64e27a2b5680538f7..de82c3df8d08308e67e889b253bdcd9af7e6ca23 100644
--- a/src/backend/optimizer/path/allpaths.c
+++ b/src/backend/optimizer/path/allpaths.c
@@ -8,7 +8,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.145 2006/04/30 18:30:39 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/optimizer/path/allpaths.c,v 1.146 2006/05/02 04:34:18 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -273,6 +273,13 @@ set_append_rel_pathlist(PlannerInfo *root, RelOptInfo *rel,
 				(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
 				 errmsg("SELECT FOR UPDATE/SHARE is not supported for inheritance queries")));
 
+	/*
+	 * We might have looked up indexes for the parent rel, but they're
+	 * really not relevant to the appendrel.  Reset the pointer to avoid
+	 * any confusion.
+	 */
+	rel->indexlist = NIL;
+
 	/*
 	 * Initialize to compute size estimates for whole append relation
 	 */
diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c
index 082089b9f112cefcad169524a6a601554876ec24..5f830ef0cd3a8422ac0b5acb77c1a28b22ee75a7 100644
--- a/src/backend/utils/adt/selfuncs.c
+++ b/src/backend/utils/adt/selfuncs.c
@@ -15,7 +15,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.203 2006/04/27 17:52:40 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/backend/utils/adt/selfuncs.c,v 1.204 2006/05/02 04:34:18 tgl Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -3265,19 +3265,27 @@ examine_variable(PlannerInfo *root, Node *node, int varRelid,
 		(varRelid == 0 || varRelid == ((Var *) basenode)->varno))
 	{
 		Var		   *var = (Var *) basenode;
-		Oid			relid;
+		RangeTblEntry *rte;
 
 		vardata->var = basenode;	/* return Var without relabeling */
 		vardata->rel = find_base_rel(root, var->varno);
 		vardata->atttype = var->vartype;
 		vardata->atttypmod = var->vartypmod;
 
-		relid = getrelid(var->varno, root->parse->rtable);
+		rte = rt_fetch(var->varno, root->parse->rtable);
 
-		if (OidIsValid(relid))
+		if (rte->inh)
+		{
+			/*
+			 * XXX This means the Var represents a column of an append relation.
+			 * Later add code to look at the member relations and try to derive
+			 * some kind of combined statistics?
+			 */
+		}
+		else if (rte->rtekind == RTE_RELATION)
 		{
 			vardata->statsTuple = SearchSysCache(STATRELATT,
-												 ObjectIdGetDatum(relid),
+												 ObjectIdGetDatum(rte->relid),
 												 Int16GetDatum(var->varattno),
 												 0, 0);
 		}