Commit 9401cf3
committed
Support matview status maintenance for multi-table JOIN queries
Previously, GetViewBaseRelids() rejected any query with more than one
base table, so materialized views defined with JOINs were never
registered in gp_matview_aux/gp_matview_tables. This meant no status
tracking and no staleness propagation for join matviews.
Add a recursive helper extract_base_relids_from_jointree() that walks
RangeTblRef, JoinExpr, and FromExpr nodes to collect all base relation
OIDs. This is the only C function changed -- the existing downstream
infrastructure (InsertMatviewTablesEntries, SetRelativeMatviewAuxStatus,
MaintainMaterializedViewStatus, reference counting) already supports
N base tables per matview.
This is a first step toward AQUMV support for join queries. Users can
also inspect a join matview's freshness status manually via
gp_matview_aux.
Key behaviors:
- Self-joins (t1 JOIN t1) are deduplicated to one catalog entry
- All join types supported: INNER, LEFT, RIGHT, FULL, implicit cross
- Subquery/function RTEs in FROM are still rejected
- Partitioned tables in joins propagate DML status correctly
- Status escalation across multiple base tables works (i→e on delete)
- Transaction rollback correctly reverts status changes
Includes regression tests for: two/three-table joins, implicit joins,
self-joins, all outer join types, mixed join types, join with GROUP BY,
shared base tables across multiple MVs, multi-DML transactions,
transaction rollback, cross joins, partitioned tables in joins,
VACUUM FULL, TRUNCATE, WITH NO DATA, and DROP CASCADE.1 parent 7e867f6 commit 9401cf3
3 files changed
Lines changed: 834 additions & 79 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
55 | 58 | | |
56 | 59 | | |
57 | 60 | | |
| |||
60 | 63 | | |
61 | 64 | | |
62 | 65 | | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
63 | 154 | | |
64 | 155 | | |
65 | 156 | | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
70 | 160 | | |
71 | 161 | | |
72 | 162 | | |
73 | 163 | | |
74 | 164 | | |
75 | 165 | | |
76 | | - | |
77 | 166 | | |
78 | 167 | | |
79 | 168 | | |
| |||
109 | 198 | | |
110 | 199 | | |
111 | 200 | | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
129 | | - | |
130 | | - | |
131 | | - | |
132 | | - | |
133 | | - | |
134 | | - | |
135 | | - | |
136 | 201 | | |
137 | | - | |
| 202 | + | |
138 | 203 | | |
139 | | - | |
140 | | - | |
141 | | - | |
142 | | - | |
143 | | - | |
144 | | - | |
145 | | - | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
146 | 207 | | |
147 | 208 | | |
148 | | - | |
149 | | - | |
150 | 209 | | |
151 | 210 | | |
152 | 211 | | |
| |||
0 commit comments