aboutsummaryrefslogtreecommitdiff
path: root/src/backend/optimizer/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/optimizer/util')
-rw-r--r--src/backend/optimizer/util/pathnode.c4
-rw-r--r--src/backend/optimizer/util/plancat.c7
-rw-r--r--src/backend/optimizer/util/relnode.c12
3 files changed, 13 insertions, 10 deletions
diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c
index 81f7c99e963..6d440001d6b 100644
--- a/src/backend/optimizer/util/pathnode.c
+++ b/src/backend/optimizer/util/pathnode.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.138 2007/02/06 02:59:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/pathnode.c,v 1.139 2007/04/21 21:01:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -800,7 +800,7 @@ create_unique_path(PlannerInfo *root, RelOptInfo *rel, Path *subpath)
*/
if (sub_targetlist && rel->rtekind == RTE_SUBQUERY)
{
- RangeTblEntry *rte = rt_fetch(rel->relid, root->parse->rtable);
+ RangeTblEntry *rte = planner_rt_fetch(rel->relid, root);
List *sub_tlist_colnos;
sub_tlist_colnos = translate_sub_tlist(sub_targetlist, rel->relid);
diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c
index 33b081ffffd..662fcbaaf8e 100644
--- a/src/backend/optimizer/util/plancat.c
+++ b/src/backend/optimizer/util/plancat.c
@@ -9,7 +9,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.133 2007/04/06 22:33:42 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/plancat.c,v 1.134 2007/04/21 21:01:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -497,6 +497,9 @@ get_relation_constraints(Oid relationObjectId, RelOptInfo *rel)
* Detect whether the relation need not be scanned because it has either
* self-inconsistent restrictions, or restrictions inconsistent with the
* relation's CHECK constraints.
+ *
+ * Note: this examines only rel->relid and rel->baserestrictinfo; therefore
+ * it can be called before filling in other fields of the RelOptInfo.
*/
bool
relation_excluded_by_constraints(RelOptInfo *rel, RangeTblEntry *rte)
@@ -595,7 +598,7 @@ build_physical_tlist(PlannerInfo *root, RelOptInfo *rel)
{
List *tlist = NIL;
Index varno = rel->relid;
- RangeTblEntry *rte = rt_fetch(varno, root->parse->rtable);
+ RangeTblEntry *rte = planner_rt_fetch(varno, root);
Relation relation;
Query *subquery;
Var *var;
diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c
index 6dfd2f61149..56f8f3493c2 100644
--- a/src/backend/optimizer/util/relnode.c
+++ b/src/backend/optimizer/util/relnode.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.86 2007/02/22 22:00:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/optimizer/util/relnode.c,v 1.87 2007/04/21 21:01:45 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -56,15 +56,15 @@ build_simple_rel(PlannerInfo *root, int relid, RelOptKind reloptkind)
RelOptInfo *rel;
RangeTblEntry *rte;
- /* Fetch RTE for relation */
- Assert(relid > 0 && relid <= list_length(root->parse->rtable));
- rte = rt_fetch(relid, root->parse->rtable);
-
/* Rel should not exist already */
- Assert(relid < root->simple_rel_array_size);
+ Assert(relid > 0 && relid < root->simple_rel_array_size);
if (root->simple_rel_array[relid] != NULL)
elog(ERROR, "rel %d already exists", relid);
+ /* Fetch RTE for relation */
+ rte = root->simple_rte_array[relid];
+ Assert(rte != NULL);
+
rel = makeNode(RelOptInfo);
rel->reloptkind = reloptkind;
rel->relids = bms_make_singleton(relid);