diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-04-27 17:48:57 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-04-27 17:48:57 -0400 |
commit | 5194024d72f33fb209e10f9ab0ada7cc67df45b7 (patch) | |
tree | 81de10ef02d808084d0b62d2ed2bd609954be176 /src/backend/commands/matview.c | |
parent | f5d576c6d278a61beec282b9b276a3a3cb2aec50 (diff) | |
download | postgresql-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/commands/matview.c')
-rw-r--r-- | src/backend/commands/matview.c | 24 |
1 files changed, 1 insertions, 23 deletions
diff --git a/src/backend/commands/matview.c b/src/backend/commands/matview.c index ac7719e40da..da373045cc0 100644 --- a/src/backend/commands/matview.c +++ b/src/backend/commands/matview.c @@ -215,10 +215,8 @@ refresh_matview_datafill(DestReceiver *dest, Query *query, List *rewritten; PlannedStmt *plan; QueryDesc *queryDesc; - List *rtable; - RangeTblEntry *initial_rte; - RangeTblEntry *second_rte; + /* Rewrite, copying the given Query to make sure it's not changed */ rewritten = QueryRewrite((Query *) copyObject(query)); /* SELECT should never rewrite to more or less than one SELECT query */ @@ -229,26 +227,6 @@ refresh_matview_datafill(DestReceiver *dest, Query *query, /* Check for user-requested abort. */ CHECK_FOR_INTERRUPTS(); - /* - * Kludge here to allow refresh of a materialized view which is invalid - * (that is, it was created or refreshed WITH NO DATA. We flag the first - * two RangeTblEntry list elements, which were added to the front of the - * rewritten Query to keep the rules system happy, with the isResultRel - * flag to indicate that it is OK if they are flagged as invalid. See - * UpdateRangeTableOfViewParse() for details. - * - * NOTE: The rewrite has switched the frist two RTEs, but they are still - * in the first two positions. If that behavior changes, the asserts here - * will fail. - */ - rtable = query->rtable; - initial_rte = ((RangeTblEntry *) linitial(rtable)); - Assert(strcmp(initial_rte->alias->aliasname, "new")); - initial_rte->isResultRel = true; - second_rte = ((RangeTblEntry *) lsecond(rtable)); - Assert(strcmp(second_rte->alias->aliasname, "old")); - second_rte->isResultRel = true; - /* Plan the query which will generate data for the refresh. */ plan = pg_plan_query(query, 0, NULL); |