forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9a785ad
committed
Fix creation of resjunk tlist entries for inherited mixed UPDATE/DELETE.
rewriteTargetListUD's processing is dependent on the relkind of the query'starget table. That was fine at the time it was made to act that way, evenfor queries on inheritance trees, because all tables in an inheritance treewould necessarily be plain tables. However, the 9.5 feature additionallowing some members of an inheritance tree to be foreign tables broke theassumption that rewriteTargetListUD's output tlist could be applied to allchild tables with nothing more than column-number mapping. This led tovisible failures if foreign child tables had row-level triggers, and wouldalso break in cases where child tables belonged to FDWs that used methodsother than CTID for row identification.To fix, delay running rewriteTargetListUD until after the planner hasexpanded inheritance, so that it is applied separately to the (alreadymapped) tlist for each child table. We can conveniently call it frompreprocess_targetlist. Refactor associated code slightly to avoid theneed to heap_open the target relation multiple times duringpreprocess_targetlist. (The APIs remain a bit ugly, particularly aroundthe point of which steps scribble on parse->targetList and which don't.But avoiding such scribbling would require a change in FDW callback APIs,which is more pain than it's worth.)Also fix ExecModifyTable to ensure that "tupleid" is reset to NULL whenwe transition from rows providing a CTID to rows that don't. (That'sreally an independent bug, but it manifests in much the same cases.)Add a regression test checking one manifestation of this problem, whichwas that row-level triggers on a foreign child table did not work right.Back-patch to 9.5 where the problem was introduced.Etsuro Fujita, reviewed by Ildus Kurbangaliev and Ashutosh BapatDiscussion:https://postgr.es/m/20170514150525.0346ba72@postgrespro.ru1 parent1174690 commit9a785ad
File tree
10 files changed
+185
-101
lines changed- contrib/postgres_fdw
- expected
- sql
- doc/src/sgml
- src
- backend
- executor
- optimizer
- plan
- prep
- rewrite
- include
- optimizer
- rewrite
10 files changed
+185
-101
lines changedLines changed: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
7022 | 7022 |
| |
7023 | 7023 |
| |
7024 | 7024 |
| |
| 7025 | + | |
| 7026 | + | |
| 7027 | + | |
| 7028 | + | |
| 7029 | + | |
| 7030 | + | |
| 7031 | + | |
| 7032 | + | |
| 7033 | + | |
| 7034 | + | |
| 7035 | + | |
| 7036 | + | |
| 7037 | + | |
| 7038 | + | |
| 7039 | + | |
| 7040 | + | |
| 7041 | + | |
| 7042 | + | |
| 7043 | + | |
| 7044 | + | |
| 7045 | + | |
| 7046 | + | |
| 7047 | + | |
| 7048 | + | |
| 7049 | + | |
| 7050 | + | |
| 7051 | + | |
| 7052 | + | |
| 7053 | + | |
| 7054 | + | |
| 7055 | + | |
| 7056 | + | |
| 7057 | + | |
| 7058 | + | |
| 7059 | + | |
| 7060 | + | |
| 7061 | + | |
| 7062 | + | |
| 7063 | + | |
| 7064 | + | |
| 7065 | + | |
| 7066 | + | |
| 7067 | + | |
| 7068 | + | |
| 7069 | + | |
| 7070 | + | |
| 7071 | + | |
| 7072 | + | |
| 7073 | + | |
| 7074 | + | |
| 7075 | + | |
| 7076 | + | |
| 7077 | + | |
| 7078 | + | |
| 7079 | + | |
| 7080 | + | |
| 7081 | + | |
7025 | 7082 |
| |
7026 | 7083 |
| |
7027 | 7084 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1656 | 1656 |
| |
1657 | 1657 |
| |
1658 | 1658 |
| |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
| 1675 | + | |
| 1676 | + | |
1659 | 1677 |
| |
1660 | 1678 |
| |
1661 | 1679 |
| |
|
Lines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
429 | 429 |
| |
430 | 430 |
| |
431 | 431 |
| |
| 432 | + | |
| 433 | + | |
| 434 | + | |
432 | 435 |
| |
433 | 436 |
| |
434 | 437 |
| |
435 |
| - | |
436 |
| - | |
| 438 | + | |
| 439 | + | |
437 | 440 |
| |
438 | 441 |
| |
439 | 442 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
167 | 167 |
| |
168 | 168 |
| |
169 | 169 |
| |
170 |
| - | |
| 170 | + | |
171 | 171 |
| |
172 | 172 |
| |
173 | 173 |
| |
174 |
| - | |
175 |
| - | |
| 174 | + | |
| 175 | + | |
176 | 176 |
| |
177 | 177 |
| |
178 | 178 |
| |
| |||
194 | 194 |
| |
195 | 195 |
| |
196 | 196 |
| |
197 |
| - | |
| 197 | + | |
198 | 198 |
| |
199 | 199 |
| |
200 | 200 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1576 | 1576 |
| |
1577 | 1577 |
| |
1578 | 1578 |
| |
1579 |
| - | |
| 1579 | + | |
1580 | 1580 |
| |
1581 | 1581 |
| |
1582 | 1582 |
| |
| |||
1699 | 1699 |
| |
1700 | 1700 |
| |
1701 | 1701 |
| |
| 1702 | + | |
1702 | 1703 |
| |
1703 | 1704 |
| |
1704 | 1705 |
| |
|
Lines changed: 2 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1555 | 1555 |
| |
1556 | 1556 |
| |
1557 | 1557 |
| |
1558 |
| - | |
| 1558 | + | |
1559 | 1559 |
| |
1560 | 1560 |
| |
1561 | 1561 |
| |
| |||
1685 | 1685 |
| |
1686 | 1686 |
| |
1687 | 1687 |
| |
1688 |
| - | |
1689 |
| - | |
1690 |
| - | |
1691 |
| - | |
1692 |
| - | |
1693 |
| - | |
1694 |
| - | |
| 1688 | + | |
1695 | 1689 |
| |
1696 | 1690 |
| |
1697 | 1691 |
| |
|
Lines changed: 62 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4 | 4 |
| |
5 | 5 |
| |
6 | 6 |
| |
7 |
| - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
8 | 10 |
| |
9 | 11 |
| |
10 | 12 |
| |
11 | 13 |
| |
12 |
| - | |
13 |
| - | |
14 |
| - | |
15 |
| - | |
16 |
| - | |
17 |
| - | |
18 |
| - | |
19 |
| - | |
20 |
| - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
21 | 23 |
| |
22 | 24 |
| |
23 | 25 |
| |
| |||
47 | 49 |
| |
48 | 50 |
| |
49 | 51 |
| |
| 52 | + | |
50 | 53 |
| |
51 | 54 |
| |
52 | 55 |
| |
53 | 56 |
| |
54 |
| - | |
| 57 | + | |
55 | 58 |
| |
56 | 59 |
| |
57 | 60 |
| |
58 | 61 |
| |
59 | 62 |
| |
60 | 63 |
| |
61 | 64 |
| |
| 65 | + | |
| 66 | + | |
| 67 | + | |
62 | 68 |
| |
63 | 69 |
| |
64 |
| - | |
| 70 | + | |
65 | 71 |
| |
66 | 72 |
| |
67 | 73 |
| |
68 | 74 |
| |
69 | 75 |
| |
| 76 | + | |
| 77 | + | |
| 78 | + | |
70 | 79 |
| |
71 | 80 |
| |
72 | 81 |
| |
73 |
| - | |
74 |
| - | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
75 | 85 |
| |
76 | 86 |
| |
77 | 87 |
| |
78 |
| - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
79 | 96 |
| |
80 |
| - | |
81 |
| - | |
| 97 | + | |
82 | 98 |
| |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
83 | 110 |
| |
84 | 111 |
| |
85 | 112 |
| |
86 | 113 |
| |
87 | 114 |
| |
88 | 115 |
| |
| 116 | + | |
89 | 117 |
| |
90 | 118 |
| |
91 |
| - | |
| 119 | + | |
92 | 120 |
| |
93 | 121 |
| |
94 | 122 |
| |
| |||
193 | 221 |
| |
194 | 222 |
| |
195 | 223 |
| |
196 |
| - | |
197 |
| - | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
198 | 234 |
| |
199 |
| - | |
200 |
| - | |
201 |
| - | |
202 |
| - | |
203 |
| - | |
204 |
| - | |
205 |
| - | |
206 |
| - | |
207 |
| - | |
208 |
| - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
209 | 239 |
| |
210 | 240 |
| |
211 | 241 |
| |
| |||
223 | 253 |
| |
224 | 254 |
| |
225 | 255 |
| |
226 |
| - | |
| 256 | + | |
227 | 257 |
| |
228 | 258 |
| |
229 | 259 |
| |
230 |
| - | |
231 | 260 |
| |
232 | 261 |
| |
233 | 262 |
| |
| |||
238 | 267 |
| |
239 | 268 |
| |
240 | 269 |
| |
241 |
| - | |
242 |
| - | |
243 |
| - | |
| 270 | + | |
244 | 271 |
| |
245 |
| - | |
246 |
| - | |
247 | 272 |
| |
248 | 273 |
| |
249 | 274 |
| |
| |||
386 | 411 |
| |
387 | 412 |
| |
388 | 413 |
| |
389 |
| - | |
390 |
| - | |
391 | 414 |
| |
392 | 415 |
| |
393 | 416 |
| |
|
0 commit comments
Comments
(0)