aboutsummaryrefslogtreecommitdiff
path: root/src/backend/executor/execMain.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-04-27 17:48:57 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2013-04-27 17:48:57 -0400
commit5194024d72f33fb209e10f9ab0ada7cc67df45b7 (patch)
tree81de10ef02d808084d0b62d2ed2bd609954be176 /src/backend/executor/execMain.c
parentf5d576c6d278a61beec282b9b276a3a3cb2aec50 (diff)
downloadpostgresql-5194024d72f33fb209e10f9ab0ada7cc67df45b7.tar.gz
postgresql-5194024d72f33fb209e10f9ab0ada7cc67df45b7.zip
Incidental cleanup of matviews code.
Move checking for unscannable matviews into ExecOpenScanRelation, which is a better place for it first because the open relation is already available (saving a relcache lookup cycle), and second because this eliminates the problem of telling the difference between rangetable entries that will or will not be scanned by the query. In particular we can get rid of the not-terribly-well-thought-out-or-implemented isResultRel field that the initial matviews patch added to RangeTblEntry. Also get rid of entirely unnecessary scannability check in the rewriter, and a bogus decision about whether RefreshMatViewStmt requires a parse-time snapshot. catversion bump due to removal of a RangeTblEntry field, which changes stored rules.
Diffstat (limited to 'src/backend/executor/execMain.c')
-rw-r--r--src/backend/executor/execMain.c72
1 files changed, 0 insertions, 72 deletions
diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c
index 8d1d0aa927d..e1b280a065c 100644
--- a/src/backend/executor/execMain.c
+++ b/src/backend/executor/execMain.c
@@ -85,7 +85,6 @@ static char *ExecBuildSlotValueDescription(TupleTableSlot *slot,
int maxfieldlen);
static void EvalPlanQualStart(EPQState *epqstate, EState *parentestate,
Plan *planTree);
-static bool RelationIdIsScannable(Oid relid);
/* end of local decls */
@@ -495,63 +494,6 @@ ExecutorRewind(QueryDesc *queryDesc)
/*
- * ExecCheckRelationsScannable
- * Check that relations which are to be accessed are in a scannable
- * state.
- *
- * Currently the only relations which are not are materialized views which
- * have not been populated by their queries.
- */
-static void
-ExecCheckRelationsScannable(List *rangeTable)
-{
- ListCell *l;
-
- foreach(l, rangeTable)
- {
- RangeTblEntry *rte = (RangeTblEntry *) lfirst(l);
-
- if (rte->rtekind != RTE_RELATION)
- continue;
-
- if (rte->relkind != RELKIND_MATVIEW)
- continue;
-
- /* It is OK to target an unpopulated materialized for results. */
- if (rte->isResultRel)
- continue;
-
- if (!RelationIdIsScannable(rte->relid))
- ereport(ERROR,
- (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
- errmsg("materialized view \"%s\" has not been populated",
- get_rel_name(rte->relid)),
- errhint("Use the REFRESH MATERIALIZED VIEW command.")));
- }
-}
-
-/*
- * Tells whether a relation is scannable based on its OID.
- *
- * Currently only non-populated materialized views are not. This is likely to
- * change to include other conditions.
- *
- * This should only be called while a lock is held on the relation.
- */
-static bool
-RelationIdIsScannable(Oid relid)
-{
- Relation relation;
- bool result;
-
- relation = heap_open(relid, NoLock);
- result = RelationIsScannable(relation);
- heap_close(relation, NoLock);
-
- return result;
-}
-
-/*
* ExecCheckRTPerms
* Check access permissions for all relations listed in a range table.
*
@@ -942,20 +884,6 @@ InitPlan(QueryDesc *queryDesc, int eflags)
planstate = ExecInitNode(plan, estate, eflags);
/*
- * Unless we are creating a view or are creating a materialized view WITH
- * NO DATA, ensure that all referenced relations are scannable. The
- * omitted cases will be checked as SELECT statements in a different
- * phase, so checking again here would be wasteful and it would generate
- * errors on a materialized view referenced as a target.
- *
- * NB: This is being done after all relations are locked, files have been
- * opened, etc., to avoid duplicating that effort or creating deadlock
- * possibilities.
- */
- if ((eflags & EXEC_FLAG_WITH_NO_DATA) == 0)
- ExecCheckRelationsScannable(rangeTable);
-
- /*
* Get the tuple descriptor describing the type of tuples to return.
*/
tupType = ExecGetResultType(planstate);