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

Commitdb001cb

Browse files
committed
fix RuntimeAppend + dropped columns
1 parent59bd7f5 commitdb001cb

File tree

3 files changed

+65
-2
lines changed

3 files changed

+65
-2
lines changed

‎expected/pathman_runtime_nodes.out

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,37 @@ where parent = 'test.runtime_test_4'::regclass and coalesce(range_min::int, 1) <
403403
t
404404
(1 row)
405405

406+
/* RuntimeAppend (check that dropped columns don't break tlists) */
407+
create table test.dropped_cols(val int4 not null);
408+
select pathman.create_hash_partitions('test.dropped_cols', 'val', 4);
409+
create_hash_partitions
410+
------------------------
411+
4
412+
(1 row)
413+
414+
insert into test.dropped_cols select generate_series(1, 100);
415+
alter table test.dropped_cols add column new_col text;/* add column */
416+
alter table test.dropped_cols drop column new_col;/* drop column! */
417+
explain (costs off) select * from generate_series(1, 10) f(id), lateral (select count(1) FILTER (WHERE true) from test.dropped_cols where val = f.id) c;
418+
QUERY PLAN
419+
-----------------------------------------------------------
420+
Nested Loop
421+
-> Function Scan on generate_series f
422+
-> Aggregate
423+
-> Custom Scan (RuntimeAppend)
424+
Prune by: (dropped_cols.val = f.id)
425+
-> Seq Scan on dropped_cols_0 dropped_cols
426+
Filter: (val = f.id)
427+
-> Seq Scan on dropped_cols_1 dropped_cols
428+
Filter: (val = f.id)
429+
-> Seq Scan on dropped_cols_2 dropped_cols
430+
Filter: (val = f.id)
431+
-> Seq Scan on dropped_cols_3 dropped_cols
432+
Filter: (val = f.id)
433+
(13 rows)
434+
435+
drop table test.dropped_cols cascade;
436+
NOTICE: drop cascades to 4 other objects
406437
set enable_hashjoin = off;
407438
set enable_mergejoin = off;
408439
select from test.runtime_test_4

‎sql/pathman_runtime_nodes.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,15 @@ join (select * from test.run_values limit 4) as t2 on t1.id = t2.val;
312312
selectcount(*)=0frompathman.pathman_partition_list
313313
where parent='test.runtime_test_4'::regclassand coalesce(range_min::int,1)<0;
314314

315+
/* RuntimeAppend (check that dropped columns don't break tlists)*/
316+
createtabletest.dropped_cols(val int4not null);
317+
selectpathman.create_hash_partitions('test.dropped_cols','val',4);
318+
insert intotest.dropped_colsselect generate_series(1,100);
319+
altertabletest.dropped_cols add column new_coltext;/* add column*/
320+
altertabletest.dropped_cols drop column new_col;/* drop column!*/
321+
explain (costs off)select*from generate_series(1,10) f(id), lateral (selectcount(1) FILTER (WHERE true)fromtest.dropped_colswhere val=f.id) c;
322+
droptabletest.dropped_cols cascade;
323+
315324
set enable_hashjoin= off;
316325
set enable_mergejoin= off;
317326

‎src/nodes_common.c

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,18 +141,41 @@ build_parent_tlist(List *tlist, AppendRelInfo *appinfo)
141141

142142
foreach (lc1,pulled_vars)
143143
{
144-
Var*tlist_var= (Var*)lfirst(lc1);
144+
Var*tlist_var= (Var*)lfirst(lc1);
145+
boolfound_column= false;
146+
AttrNumberattnum;
145147

146-
AttrNumberattnum=0;
148+
/* Skip system attributes */
149+
if (tlist_var->varattno<InvalidAttrNumber)
150+
continue;
151+
152+
attnum=0;
147153
foreach (lc2,appinfo->translated_vars)
148154
{
149155
Var*translated_var= (Var*)lfirst(lc2);
150156

157+
/* Don't forget to inc 'attunum'! */
151158
attnum++;
152159

160+
/* Skip dropped columns */
161+
if (!translated_var)
162+
continue;
163+
164+
/* Find this column in list of parent table columns */
153165
if (translated_var->varattno==tlist_var->varattno)
166+
{
154167
tlist_var->varattno=attnum;
168+
found_column= true;/* successful mapping */
169+
}
155170
}
171+
172+
/* Raise ERROR if mapping failed */
173+
if (!found_column)
174+
elog(ERROR,
175+
"table \"%s\" has no attribute %d of partition \"%s\"",
176+
get_rel_name_or_relid(appinfo->parent_relid),
177+
tlist_var->varoattno,
178+
get_rel_name_or_relid(appinfo->child_relid));
156179
}
157180

158181
ChangeVarNodes((Node*)temp_tlist,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp