Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit00309ba

Browse files
committed
Merge branch 'master' into master_quickfix_164
2 parents7747219 +1c436e8 commit00309ba

File tree

5 files changed

+161
-10
lines changed

5 files changed

+161
-10
lines changed

‎expected/pathman_views.out

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ select create_hash_partitions('views._abc', 'id', 10);
1616
(1 row)
1717

1818
insert into views._abc select generate_series(1, 100);
19+
/* create a dummy table */
20+
create table views._abc_add (like views._abc);
21+
vacuum analyze;
1922
/* create a facade view */
2023
create view views.abc as select * from views._abc;
2124
create or replace function views.disable_modification()
@@ -117,6 +120,69 @@ explain (costs off) delete from views.abc where id = 1 or id = 2;
117120

118121
delete from views.abc where id = 1 or id = 2;
119122
ERROR: DELETE
123+
/* Test SELECT with UNION */
124+
create view views.abc_union as table views._abc union table views._abc_add;
125+
create view views.abc_union_all as table views._abc union all table views._abc_add;
126+
explain (costs off) table views.abc_union;
127+
QUERY PLAN
128+
--------------------------------------
129+
HashAggregate
130+
Group Key: _abc_0.id
131+
-> Append
132+
-> Append
133+
-> Seq Scan on _abc_0
134+
-> Seq Scan on _abc_1
135+
-> Seq Scan on _abc_2
136+
-> Seq Scan on _abc_3
137+
-> Seq Scan on _abc_4
138+
-> Seq Scan on _abc_5
139+
-> Seq Scan on _abc_6
140+
-> Seq Scan on _abc_7
141+
-> Seq Scan on _abc_8
142+
-> Seq Scan on _abc_9
143+
-> Seq Scan on _abc_add
144+
(15 rows)
145+
146+
explain (costs off) select * from views.abc_union where id = 5;
147+
QUERY PLAN
148+
--------------------------------------
149+
HashAggregate
150+
Group Key: _abc_8.id
151+
-> Append
152+
-> Append
153+
-> Seq Scan on _abc_8
154+
Filter: (id = 5)
155+
-> Seq Scan on _abc_add
156+
Filter: (id = 5)
157+
(8 rows)
158+
159+
explain (costs off) table views.abc_union_all;
160+
QUERY PLAN
161+
----------------------------
162+
Append
163+
-> Seq Scan on _abc_0
164+
-> Seq Scan on _abc_1
165+
-> Seq Scan on _abc_2
166+
-> Seq Scan on _abc_3
167+
-> Seq Scan on _abc_4
168+
-> Seq Scan on _abc_5
169+
-> Seq Scan on _abc_6
170+
-> Seq Scan on _abc_7
171+
-> Seq Scan on _abc_8
172+
-> Seq Scan on _abc_9
173+
-> Seq Scan on _abc_add
174+
(12 rows)
175+
176+
explain (costs off) select * from views.abc_union_all where id = 5;
177+
QUERY PLAN
178+
----------------------------
179+
Append
180+
-> Seq Scan on _abc_8
181+
Filter: (id = 5)
182+
-> Seq Scan on _abc_add
183+
Filter: (id = 5)
184+
(5 rows)
185+
120186
DROP SCHEMA views CASCADE;
121-
NOTICE: drop cascades to13 other objects
187+
NOTICE: drop cascades to16 other objects
122188
DROP EXTENSION pg_pathman;

‎expected/pathman_views_1.out

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ select create_hash_partitions('views._abc', 'id', 10);
1616
(1 row)
1717

1818
insert into views._abc select generate_series(1, 100);
19+
/* create a dummy table */
20+
create table views._abc_add (like views._abc);
21+
vacuum analyze;
1922
/* create a facade view */
2023
create view views.abc as select * from views._abc;
2124
create or replace function views.disable_modification()
@@ -173,6 +176,69 @@ explain (costs off) delete from views.abc where id = 1 or id = 2;
173176

174177
delete from views.abc where id = 1 or id = 2;
175178
ERROR: DELETE
179+
/* Test SELECT with UNION */
180+
create view views.abc_union as table views._abc union table views._abc_add;
181+
create view views.abc_union_all as table views._abc union all table views._abc_add;
182+
explain (costs off) table views.abc_union;
183+
QUERY PLAN
184+
--------------------------------------
185+
HashAggregate
186+
Group Key: _abc_0.id
187+
-> Append
188+
-> Append
189+
-> Seq Scan on _abc_0
190+
-> Seq Scan on _abc_1
191+
-> Seq Scan on _abc_2
192+
-> Seq Scan on _abc_3
193+
-> Seq Scan on _abc_4
194+
-> Seq Scan on _abc_5
195+
-> Seq Scan on _abc_6
196+
-> Seq Scan on _abc_7
197+
-> Seq Scan on _abc_8
198+
-> Seq Scan on _abc_9
199+
-> Seq Scan on _abc_add
200+
(15 rows)
201+
202+
explain (costs off) select * from views.abc_union where id = 5;
203+
QUERY PLAN
204+
--------------------------------------
205+
HashAggregate
206+
Group Key: _abc_8.id
207+
-> Append
208+
-> Append
209+
-> Seq Scan on _abc_8
210+
Filter: (id = 5)
211+
-> Seq Scan on _abc_add
212+
Filter: (id = 5)
213+
(8 rows)
214+
215+
explain (costs off) table views.abc_union_all;
216+
QUERY PLAN
217+
----------------------------
218+
Append
219+
-> Seq Scan on _abc_0
220+
-> Seq Scan on _abc_1
221+
-> Seq Scan on _abc_2
222+
-> Seq Scan on _abc_3
223+
-> Seq Scan on _abc_4
224+
-> Seq Scan on _abc_5
225+
-> Seq Scan on _abc_6
226+
-> Seq Scan on _abc_7
227+
-> Seq Scan on _abc_8
228+
-> Seq Scan on _abc_9
229+
-> Seq Scan on _abc_add
230+
(12 rows)
231+
232+
explain (costs off) select * from views.abc_union_all where id = 5;
233+
QUERY PLAN
234+
----------------------------
235+
Append
236+
-> Seq Scan on _abc_8
237+
Filter: (id = 5)
238+
-> Seq Scan on _abc_add
239+
Filter: (id = 5)
240+
(5 rows)
241+
176242
DROP SCHEMA views CASCADE;
177-
NOTICE: drop cascades to13 other objects
243+
NOTICE: drop cascades to16 other objects
178244
DROP EXTENSION pg_pathman;

‎sql/pathman_views.sql

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ create table views._abc(id int4 not null);
1717
select create_hash_partitions('views._abc','id',10);
1818
insert intoviews._abcselect generate_series(1,100);
1919

20+
/* create a dummy table*/
21+
createtableviews._abc_add (likeviews._abc);
22+
23+
24+
vacuum analyze;
25+
2026

2127
/* create a facade view*/
2228
createviewviews.abcasselect*fromviews._abc;
@@ -60,6 +66,15 @@ explain (costs off) delete from views.abc where id = 1 or id = 2;
6066
deletefromviews.abcwhere id=1or id=2;
6167

6268

69+
/* Test SELECT with UNION*/
70+
createviewviews.abc_unionas tableviews._abcunion tableviews._abc_add;
71+
createviewviews.abc_union_allas tableviews._abcunion all tableviews._abc_add;
72+
explain (costs off) tableviews.abc_union;
73+
explain (costs off)select*fromviews.abc_unionwhere id=5;
74+
explain (costs off) tableviews.abc_union_all;
75+
explain (costs off)select*fromviews.abc_union_allwhere id=5;
76+
77+
6378

6479
DROPSCHEMA views CASCADE;
6580
DROP EXTENSION pg_pathman;

‎src/hooks.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,11 +384,14 @@ pathman_rel_pathlist_hook(PlannerInfo *root,
384384
AppendRelInfo*appinfo= (AppendRelInfo*)lfirst(lc);
385385

386386
/*
387-
* If there's an 'appinfo', it means that somebody
387+
* If there's an 'appinfo' with Oid, it means that somebody
388388
* (PG?) has already processed this partitioned table
389389
* and added its children to the plan.
390+
*
391+
* NOTE: there's no Oid iff it's UNION.
390392
*/
391-
if (appinfo->child_relid==rti)
393+
if (appinfo->child_relid==rti&&
394+
OidIsValid(appinfo->parent_reloid))
392395
return;
393396
}
394397
}

‎src/planner_tree_modification.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ reset_query_id_generator(void)
139139

140140

141141
/*
142-
* Basic plan tree walker
142+
* Basic plan tree walker.
143143
*
144-
* 'visitor' is applied right before return
144+
* 'visitor' is applied right before return.
145145
*/
146146
void
147147
plan_tree_walker(Plan*plan,
@@ -172,15 +172,16 @@ plan_tree_walker(Plan *plan,
172172
plan_tree_walker((Plan*)lfirst(l),visitor,context);
173173
break;
174174

175-
/* Since they look alike */
176-
caseT_MergeAppend:
177175
caseT_Append:
178-
Assert(offsetof(Append,appendplans)==
179-
offsetof(MergeAppend,mergeplans));
180176
foreach(l, ((Append*)plan)->appendplans)
181177
plan_tree_walker((Plan*)lfirst(l),visitor,context);
182178
break;
183179

180+
caseT_MergeAppend:
181+
foreach(l, ((MergeAppend*)plan)->mergeplans)
182+
plan_tree_walker((Plan*)lfirst(l),visitor,context);
183+
break;
184+
184185
caseT_BitmapAnd:
185186
foreach(l, ((BitmapAnd*)plan)->bitmapplans)
186187
plan_tree_walker((Plan*)lfirst(l),visitor,context);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp