From 5194024d72f33fb209e10f9ab0ada7cc67df45b7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 27 Apr 2013 17:48:57 -0400 Subject: 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. --- src/backend/executor/nodeSeqscan.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/backend/executor/nodeSeqscan.c') diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index c6f2eabedee..c4edec0750b 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -29,7 +29,7 @@ #include "executor/nodeSeqscan.h" #include "utils/rel.h" -static void InitScanRelation(SeqScanState *node, EState *estate); +static void InitScanRelation(SeqScanState *node, EState *estate, int eflags); static TupleTableSlot *SeqNext(SeqScanState *node); /* ---------------------------------------------------------------- @@ -118,12 +118,11 @@ ExecSeqScan(SeqScanState *node) /* ---------------------------------------------------------------- * InitScanRelation * - * This does the initialization for scan relations and - * subplans of scans. + * Set up to access the scan relation. * ---------------------------------------------------------------- */ static void -InitScanRelation(SeqScanState *node, EState *estate) +InitScanRelation(SeqScanState *node, EState *estate, int eflags) { Relation currentRelation; HeapScanDesc currentScanDesc; @@ -133,8 +132,10 @@ InitScanRelation(SeqScanState *node, EState *estate) * open that relation and acquire appropriate lock on it. */ currentRelation = ExecOpenScanRelation(estate, - ((SeqScan *) node->ps.plan)->scanrelid); + ((SeqScan *) node->ps.plan)->scanrelid, + eflags); + /* initialize a heapscan */ currentScanDesc = heap_beginscan(currentRelation, estate->es_snapshot, 0, @@ -143,6 +144,7 @@ InitScanRelation(SeqScanState *node, EState *estate) node->ss_currentRelation = currentRelation; node->ss_currentScanDesc = currentScanDesc; + /* and report the scan tuple slot's rowtype */ ExecAssignScanType(node, RelationGetDescr(currentRelation)); } @@ -196,7 +198,7 @@ ExecInitSeqScan(SeqScan *node, EState *estate, int eflags) /* * initialize scan relation */ - InitScanRelation(scanstate, estate); + InitScanRelation(scanstate, estate, eflags); scanstate->ps.ps_TupFromTlist = false; -- cgit v1.2.3