forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit0f79440
committed
Fix SQL-spec incompatibilities in new transition table feature.
The standard says that all changes of the same kind (insert, update, ordelete) caused in one table by a single SQL statement should be reportedin a single transition table; and by that, they mean to include foreign keyenforcement actions cascading from the statement's direct effects. It'salso reasonable to conclude that if the standard had wCTEs, they would saythat effects of wCTEs applying to the same table as each other or the outerstatement should be merged into one transition table. We weren't doing itlike that.Hence, arrange to merge tuples from multiple update actions into a singletransition table as much as we can. There is a problem, which is that ifthe firing of FK enforcement triggers and after-row triggers withtransition tables is interspersed, we might need to report more tuplesafter some triggers have already seen the transition table. It seems likea bad idea for the transition table to be mutable between trigger calls.There's no good way around this without a major redesign of the FK logic,so for now, resolve it by opening a new transition table each time thishappens.Also, ensure that AFTER STATEMENT triggers fire just once per statement,or once per transition table when we're forced to make more than one.Previous versions of Postgres have allowed each FK enforcement queryto cause an additional firing of the AFTER STATEMENT triggers for thereferencing table, but that's certainly not per spec. (We're stilldoing multiple firings of BEFORE STATEMENT triggers, though; is thatsomething worth changing?)Also, forbid using transition tables with column-specific UPDATE triggers.The spec requires such transition tables to show only the tuples for whichthe UPDATE trigger would have fired, which means maintaining multipletransition tables or else somehow filtering the contents at readout.Maybe someday we'll bother to support that option, but it looks like alot of trouble for a marginal feature.The transition tables are now managed by the AfterTriggers data structures,rather than being directly the responsibility of ModifyTable nodes. Thisremoves a subtransaction-lifespan memory leak introduced by my previousband-aid patch3c43595.In passing, refactor the AfterTriggers data structures to reduce themanagement overhead for them, by using arrays of structs rather thanseveral parallel arrays for per-query-level and per-subtransaction state.I failed to resist the temptation to do some copy-editing on the SGMLdocs about triggers, above and beyond merely documenting the effectsof this patch.Back-patch to v10, because we don't want the semantics of transitiontables to change post-release.Patch by me, with help and review from Thomas Munro.Discussion:https://postgr.es/m/20170909064853.25630.12825@wrigleys.postgresql.org1 parent04b64b8 commit0f79440
File tree
11 files changed
+803
-390
lines changed- doc/src/sgml
- ref
- src
- backend
- commands
- executor
- include
- commands
- nodes
- test/regress
- expected
- sql
11 files changed
+803
-390
lines changedLines changed: 80 additions & 32 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
55 |
| - | |
| 55 | + | |
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
| |||
82 | 82 |
| |
83 | 83 |
| |
84 | 84 |
| |
85 |
| - | |
86 |
| - | |
87 |
| - | |
88 |
| - | |
| 85 | + | |
89 | 86 |
| |
90 | 87 |
| |
91 | 88 |
| |
| |||
174 | 171 |
| |
175 | 172 |
| |
176 | 173 |
| |
177 |
| - | |
| 174 | + | |
| 175 | + | |
178 | 176 |
| |
179 | 177 |
| |
180 | 178 |
| |
| |||
184 | 182 |
| |
185 | 183 |
| |
186 | 184 |
| |
187 |
| - | |
188 |
| - | |
189 |
| - | |
190 |
| - | |
191 |
| - | |
192 |
| - | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
193 | 201 |
| |
194 | 202 |
| |
195 | 203 |
| |
196 | 204 |
| |
197 |
| - | |
198 |
| - | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
199 | 208 |
| |
200 | 209 |
| |
201 | 210 |
| |
| |||
300 | 309 |
| |
301 | 310 |
| |
302 | 311 |
| |
303 |
| - | |
304 |
| - | |
305 |
| - | |
306 |
| - | |
307 |
| - | |
308 |
| - | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
309 | 315 |
| |
310 | 316 |
| |
311 | 317 |
| |
| |||
315 | 321 |
| |
316 | 322 |
| |
317 | 323 |
| |
318 |
| - | |
319 |
| - | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
320 | 327 |
| |
321 | 328 |
| |
322 | 329 |
| |
| |||
325 | 332 |
| |
326 | 333 |
| |
327 | 334 |
| |
328 |
| - | |
| 335 | + | |
| 336 | + | |
329 | 337 |
| |
330 | 338 |
| |
331 | 339 |
| |
| |||
458 | 466 |
| |
459 | 467 |
| |
460 | 468 |
| |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
461 | 498 |
| |
462 | 499 |
| |
463 | 500 |
| |
| |||
589 | 626 |
| |
590 | 627 |
| |
591 | 628 |
| |
592 |
| - | |
593 |
| - | |
594 |
| - | |
595 |
| - | |
596 |
| - | |
597 |
| - | |
598 |
| - | |
599 |
| - | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
600 | 637 |
| |
601 | 638 |
| |
602 | 639 |
| |
603 | 640 |
| |
604 |
| - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
605 | 653 |
| |
606 | 654 |
| |
607 | 655 |
| |
|
Lines changed: 29 additions & 25 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
41 | 41 |
| |
42 | 42 |
| |
43 | 43 |
| |
44 |
| - | |
45 |
| - | |
46 |
| - | |
47 |
| - | |
48 |
| - | |
49 |
| - | |
50 |
| - | |
51 |
| - | |
52 |
| - | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
53 | 49 |
| |
54 |
| - | |
| 50 | + | |
55 | 51 |
| |
56 | 52 |
| |
57 | 53 |
| |
| |||
97 | 93 |
| |
98 | 94 |
| |
99 | 95 |
| |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
| 96 | + | |
104 | 97 |
| |
105 | 98 |
| |
106 | 99 |
| |
| |||
117 | 110 |
| |
118 | 111 |
| |
119 | 112 |
| |
120 |
| - | |
121 |
| - | |
122 |
| - | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
123 | 116 |
| |
124 | 117 |
| |
125 | 118 |
| |
| |||
132 | 125 |
| |
133 | 126 |
| |
134 | 127 |
| |
135 |
| - | |
136 |
| - | |
137 |
| - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
138 | 131 |
| |
139 | 132 |
| |
140 | 133 |
| |
141 |
| - | |
| 134 | + | |
| 135 | + | |
142 | 136 |
| |
143 | 137 |
| |
144 | 138 |
| |
145 |
| - | |
146 |
| - | |
| 139 | + | |
| 140 | + | |
147 | 141 |
| |
148 | 142 |
| |
149 | 143 |
| |
| |||
314 | 308 |
| |
315 | 309 |
| |
316 | 310 |
| |
317 |
| - | |
318 |
| - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
319 | 323 |
| |
320 | 324 |
| |
321 | 325 |
| |
|
Lines changed: 6 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2432 | 2432 |
| |
2433 | 2433 |
| |
2434 | 2434 |
| |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
2435 | 2438 |
| |
2436 | 2439 |
| |
2437 | 2440 |
| |
2438 | 2441 |
| |
2439 | 2442 |
| |
2440 |
| - | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
2441 | 2446 |
| |
2442 | 2447 |
| |
2443 | 2448 |
| |
| |||
2513 | 2518 |
| |
2514 | 2519 |
| |
2515 | 2520 |
| |
2516 |
| - | |
2517 |
| - | |
2518 |
| - | |
2519 | 2521 |
| |
2520 | 2522 |
| |
2521 | 2523 |
| |
|
0 commit comments
Comments
(0)