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

Commit11e22e4

Browse files
committed
Match RelOptInfos by relids not pointer equality.
Commit1c2cb27 added some code that tried to detect whether twoRelOptInfos were the "same" rel by pointer comparison; but it turnsout that inheritance_planner breaks that, through its shenaniganswith copying some relations forward into new subproblems. Comparerelid sets instead. Add a regression test case to exercise thisarea.Problem reported by Rushabh Lathia; diagnosis and fix by Amit Langote,modified a bit by me.Discussion:https://postgr.es/m/CAGPqQf3anJGj65bqAQ9edDr8gF7qig6_avRgwMT9MsZ19COUPw@mail.gmail.com
1 parent9b7c56d commit11e22e4

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

‎src/backend/partitioning/partprune.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ make_partitionedrel_pruneinfo(PlannerInfo *root, RelOptInfo *parentrel,
384384
* because in later iterations of the loop for child partitions,
385385
* we want to translate from parent to child variables.
386386
*/
387-
if (parentrel!=subpart)
387+
if (!bms_equal(parentrel->relids,subpart->relids))
388388
{
389389
intnappinfos;
390390
AppendRelInfo**appinfos=find_appinfos_by_relids(root,

‎src/test/regress/expected/partition_prune.out

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,85 @@ deallocate ab_q2;
24772477
deallocate ab_q3;
24782478
deallocate ab_q4;
24792479
deallocate ab_q5;
2480+
-- UPDATE on a partition subtree has been seen to have problems.
2481+
insert into ab values (1,2);
2482+
explain (analyze, costs off, summary off, timing off)
2483+
update ab_a1 set b = 3 from ab where ab.a = 1 and ab.a = ab_a1.a;
2484+
QUERY PLAN
2485+
-------------------------------------------------------------------------------------
2486+
Update on ab_a1 (actual rows=0 loops=1)
2487+
Update on ab_a1_b1
2488+
Update on ab_a1_b2
2489+
Update on ab_a1_b3
2490+
-> Nested Loop (actual rows=0 loops=1)
2491+
-> Append (actual rows=1 loops=1)
2492+
-> Bitmap Heap Scan on ab_a1_b1 ab_a1_b1_1 (actual rows=0 loops=1)
2493+
Recheck Cond: (a = 1)
2494+
-> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1)
2495+
Index Cond: (a = 1)
2496+
-> Bitmap Heap Scan on ab_a1_b2 ab_a1_b2_1 (actual rows=1 loops=1)
2497+
Recheck Cond: (a = 1)
2498+
Heap Blocks: exact=1
2499+
-> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1)
2500+
Index Cond: (a = 1)
2501+
-> Bitmap Heap Scan on ab_a1_b3 ab_a1_b3_1 (actual rows=0 loops=1)
2502+
Recheck Cond: (a = 1)
2503+
-> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=0 loops=1)
2504+
Index Cond: (a = 1)
2505+
-> Materialize (actual rows=0 loops=1)
2506+
-> Bitmap Heap Scan on ab_a1_b1 (actual rows=0 loops=1)
2507+
Recheck Cond: (a = 1)
2508+
-> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1)
2509+
Index Cond: (a = 1)
2510+
-> Nested Loop (actual rows=1 loops=1)
2511+
-> Append (actual rows=1 loops=1)
2512+
-> Bitmap Heap Scan on ab_a1_b1 ab_a1_b1_1 (actual rows=0 loops=1)
2513+
Recheck Cond: (a = 1)
2514+
-> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1)
2515+
Index Cond: (a = 1)
2516+
-> Bitmap Heap Scan on ab_a1_b2 ab_a1_b2_1 (actual rows=1 loops=1)
2517+
Recheck Cond: (a = 1)
2518+
Heap Blocks: exact=1
2519+
-> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1)
2520+
Index Cond: (a = 1)
2521+
-> Bitmap Heap Scan on ab_a1_b3 ab_a1_b3_1 (actual rows=0 loops=1)
2522+
Recheck Cond: (a = 1)
2523+
-> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1)
2524+
Index Cond: (a = 1)
2525+
-> Materialize (actual rows=1 loops=1)
2526+
-> Bitmap Heap Scan on ab_a1_b2 (actual rows=1 loops=1)
2527+
Recheck Cond: (a = 1)
2528+
Heap Blocks: exact=1
2529+
-> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1)
2530+
Index Cond: (a = 1)
2531+
-> Nested Loop (actual rows=0 loops=1)
2532+
-> Append (actual rows=1 loops=1)
2533+
-> Bitmap Heap Scan on ab_a1_b1 ab_a1_b1_1 (actual rows=0 loops=1)
2534+
Recheck Cond: (a = 1)
2535+
-> Bitmap Index Scan on ab_a1_b1_a_idx (actual rows=0 loops=1)
2536+
Index Cond: (a = 1)
2537+
-> Bitmap Heap Scan on ab_a1_b2 ab_a1_b2_1 (actual rows=1 loops=1)
2538+
Recheck Cond: (a = 1)
2539+
Heap Blocks: exact=1
2540+
-> Bitmap Index Scan on ab_a1_b2_a_idx (actual rows=1 loops=1)
2541+
Index Cond: (a = 1)
2542+
-> Bitmap Heap Scan on ab_a1_b3 ab_a1_b3_1 (actual rows=0 loops=1)
2543+
Recheck Cond: (a = 1)
2544+
-> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1)
2545+
Index Cond: (a = 1)
2546+
-> Materialize (actual rows=0 loops=1)
2547+
-> Bitmap Heap Scan on ab_a1_b3 (actual rows=0 loops=1)
2548+
Recheck Cond: (a = 1)
2549+
-> Bitmap Index Scan on ab_a1_b3_a_idx (actual rows=1 loops=1)
2550+
Index Cond: (a = 1)
2551+
(65 rows)
2552+
2553+
table ab;
2554+
a | b
2555+
---+---
2556+
1 | 3
2557+
(1 row)
2558+
24802559
drop table ab, lprt_a;
24812560
-- Join
24822561
create table tbl1(col1 int);

‎src/test/regress/sql/partition_prune.sql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,12 @@ deallocate ab_q3;
554554
deallocate ab_q4;
555555
deallocate ab_q5;
556556

557+
-- UPDATE on a partition subtree has been seen to have problems.
558+
insert into abvalues (1,2);
559+
explain (analyze, costs off, summary off, timing off)
560+
update ab_a1set b=3from abwhereab.a=1andab.a=ab_a1.a;
561+
table ab;
562+
557563
droptable ab, lprt_a;
558564

559565
-- Join

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp