mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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.
This commit is contained in:
@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user