Skip to content

Commit 907985e

Browse files
avaminglimy-ship-it
authored andcommitted
[AQUMV] Check relation actually has children when view matching.
We arbitrarily set inh to false with a FIXME before this commit. It should be corrected later during planning, but it's earlier as we are doing view matching on parse tree. Correct inh and skip it if has children. Authored-by: Zhang Mingli avamingli@gmail.com
1 parent 63fcf2d commit 907985e

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/backend/optimizer/plan/aqumv.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ answer_query_using_materialized_views(PlannerInfo *root,
254254
if (mvrte->relid != origin_rel_oid)
255255
continue;
256256

257+
/*
258+
* Check if it actually has children here to match before planning.
259+
*/
260+
mvrte->inh = has_subclass(mvrte->relid);
261+
if (mvrte->inh)
262+
continue;
263+
257264
subroot = (PlannerInfo *) palloc(sizeof(PlannerInfo));
258265
memcpy(subroot, root, sizeof(PlannerInfo));
259266
subroot->parent_root = root;
@@ -371,11 +378,6 @@ answer_query_using_materialized_views(PlannerInfo *root,
371378
/* Rewrite with mv's query tree*/
372379
mvrte->relkind = RELKIND_MATVIEW;
373380
mvrte->relid = matviewRel->rd_rel->oid;
374-
/*
375-
* AQUMV_FIXME_MVP
376-
* Not sure where it's true from actions even it's not inherit tables.
377-
*/
378-
mvrte->inh = false;
379381
viewQuery->rtable = list_make1(mvrte); /* rewrite to SELECT FROM mv itself. */
380382
viewQuery->jointree->quals = (Node *)post_quals; /* Could be NULL, but doesn'y matter for now. */
381383

0 commit comments

Comments
 (0)