- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit387f9ed
committed
Fix problems when a plain-inheritance parent table is excluded.
When an UPDATE/DELETE/MERGE's target table is an old-styleinheritance tree, it's possible for the parent to get excludedfrom the plan while some children are not. (I believe this isonly possible if we can prove that a CHECK ... NO INHERITconstraint on the parent contradicts the query WHERE clause,so it's a very unusual case.) In such a case, ExecInitModifyTablemistakenly concluded that the first surviving child is the targettable, leading to at least two bugs:1. The wrong table's statement-level triggers would get fired.2. In v16 and up, it was possible to fail with "invalid perminfoindex0 in RTE with relid nnnn" due to the child RTE not having permissionsdata included in the query plan. This was hard to reproduce reliablybecause it did not occur unless the update triggered some non-HOTindex updates.In v14 and up, this is easy to fix by defining ModifyTable.rootRelationto be the parent RTE in plain inheritance as well as partitioned cases.While the wrong-triggers bug also appears in older branches, therelevant code in both the planner and executor is quite a bitdifferent, so it would take a good deal of effort to develop andtest a suitable patch. Given the lack of field complaints about thetrigger issue, I'll desist for now. (Patching v11 for this seemsunwise anyway, given that it will have no more releases after nextmonth.)Per bug #18147 from Hans Buschmann.Amit Langote and Tom LaneDiscussion:https://postgr.es/m/18147-6fc796538913ee88@postgresql.org1 parent74e5ea1 commit387f9ed
File tree
7 files changed
+64
-22
lines changed- src
- backend
- executor
- optimizer
- plan
- util
- include/nodes
- test/regress
- expected
- sql
7 files changed
+64
-22
lines changedLines changed: 5 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3966 | 3966 |
| |
3967 | 3967 |
| |
3968 | 3968 |
| |
3969 |
| - | |
3970 |
| - | |
3971 |
| - | |
3972 |
| - | |
| 3969 | + | |
| 3970 | + | |
| 3971 | + | |
| 3972 | + | |
3973 | 3973 |
| |
3974 | 3974 |
| |
3975 | 3975 |
| |
| |||
3980 | 3980 |
| |
3981 | 3981 |
| |
3982 | 3982 |
| |
| 3983 | + | |
3983 | 3984 |
| |
3984 | 3985 |
| |
3985 | 3986 |
| |
|
Lines changed: 4 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1800 | 1800 |
| |
1801 | 1801 |
| |
1802 | 1802 |
| |
| 1803 | + | |
| 1804 | + | |
| 1805 | + | |
1803 | 1806 |
| |
1804 | 1807 |
| |
1805 | 1808 |
| |
| |||
1923 | 1926 |
| |
1924 | 1927 |
| |
1925 | 1928 |
| |
| 1929 | + | |
1926 | 1930 |
| |
1927 | 1931 |
| |
1928 | 1932 |
| |
| |||
1934 | 1938 |
| |
1935 | 1939 |
| |
1936 | 1940 |
| |
1937 |
| - | |
1938 |
| - | |
1939 |
| - | |
1940 |
| - | |
1941 |
| - | |
1942 |
| - | |
1943 |
| - | |
1944 |
| - | |
1945 |
| - | |
1946 |
| - | |
1947 | 1941 |
| |
1948 | 1942 |
| |
1949 | 1943 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3663 | 3663 |
| |
3664 | 3664 |
| |
3665 | 3665 |
| |
3666 |
| - | |
| 3666 | + | |
3667 | 3667 |
| |
3668 | 3668 |
| |
3669 | 3669 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2344 | 2344 |
| |
2345 | 2345 |
| |
2346 | 2346 |
| |
2347 |
| - | |
| 2347 | + | |
2348 | 2348 |
| |
2349 | 2349 |
| |
2350 | 2350 |
| |
|
Lines changed: 7 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
219 |
| - | |
220 |
| - | |
221 |
| - | |
222 |
| - | |
223 |
| - | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
224 | 225 |
| |
225 | 226 |
| |
226 | 227 |
| |
| |||
232 | 233 |
| |
233 | 234 |
| |
234 | 235 |
| |
235 |
| - | |
| 236 | + | |
236 | 237 |
| |
237 | 238 |
| |
238 | 239 |
| |
|
Lines changed: 27 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
539 | 539 |
| |
540 | 540 |
| |
541 | 541 |
| |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 568 | + | |
542 | 569 |
| |
543 | 570 |
| |
544 | 571 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
97 | 97 |
| |
98 | 98 |
| |
99 | 99 |
| |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
100 | 119 |
| |
101 | 120 |
| |
102 | 121 |
| |
|
0 commit comments
Comments
(0)