- Notifications
You must be signed in to change notification settings - Fork5k
Commit8cfbdf8
committed
Fix some issues in contrib/spi/refint.c.
check_foreign_key incorrectly used a single cache entry for its savedplans for a 'c' (cascade) trigger, although there are two differentqueries to execute depending on whether it fires for an update or adelete. This caused the wrong things to be done if both types ofevent occur in one session. (This was indeed visible in the triggersregression test, but apparently nobody ever questioned it.) To fix,add the operation type to the cache key.Its debug log output failed to distinguish update from deleteevents, too.Also, change the intended trigger usage from BEFORE ROW to AFTER ROW,and add checks insisting on that usage. BEFORE is really ratherunsafe, since if there are other BEFORE triggers they might change orcancel the operation we are trying to check. AFTER triggers are thestandard way to propagate changes to other rows, so we should followthat way here.In passing, remove a useless duplicate lookup of the cache entry.This code is mostly intended as a documentation example, so wewon't consider a back-patch.Author: Dmitrii Bondar <d.bondar@postgrespro.ru>Reviewed-by: Paul Jungwirth <pj@illuminatedcomputing.com>Reviewed-by: Lilian Ontowhee <ontowhee@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/79755a2b18ed4fe5e29da6a87a1e00d1@postgrespro.ru1 parent8e293e6 commit8cfbdf8
File tree
4 files changed
+55
-34
lines changed- contrib/spi
- doc/src/sgml
- src/test/regress
- expected
- sql
4 files changed
+55
-34
lines changedLines changed: 19 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
84 | 84 |
| |
85 | 85 |
| |
86 | 86 |
| |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
87 | 91 |
| |
88 | 92 |
| |
89 | 93 |
| |
| |||
287 | 291 |
| |
288 | 292 |
| |
289 | 293 |
| |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
290 | 298 |
| |
291 | 299 |
| |
292 | 300 |
| |
| |||
338 | 346 |
| |
339 | 347 |
| |
340 | 348 |
| |
341 |
| - | |
342 |
| - | |
| 349 | + | |
| 350 | + | |
343 | 351 |
| |
344 |
| - | |
| 352 | + | |
345 | 353 |
| |
346 | 354 |
| |
347 | 355 |
| |
| |||
573 | 581 |
| |
574 | 582 |
| |
575 | 583 |
| |
576 |
| - | |
577 |
| - | |
578 | 584 |
| |
579 | 585 |
| |
580 | 586 |
| |
| |||
596 | 602 |
| |
597 | 603 |
| |
598 | 604 |
| |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
599 | 612 |
| |
600 |
| - | |
601 |
| - | |
| 613 | + | |
602 | 614 |
| |
603 | 615 |
| |
604 | 616 |
| |
|
Lines changed: 12 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
36 | 36 |
| |
37 | 37 |
| |
38 | 38 |
| |
39 |
| - | |
| 39 | + | |
40 | 40 |
| |
41 | 41 |
| |
42 | 42 |
| |
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
| 49 | + | |
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| |||
60 | 60 |
| |
61 | 61 |
| |
62 | 62 |
| |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
63 | 73 |
| |
64 | 74 |
| |
65 | 75 |
| |
|
Lines changed: 19 additions & 20 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
| 49 | + | |
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
54 |
| - | |
| 54 | + | |
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 | 61 |
| |
62 |
| - | |
| 62 | + | |
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
| |||
74 | 74 |
| |
75 | 75 |
| |
76 | 76 |
| |
77 |
| - | |
| 77 | + | |
78 | 78 |
| |
79 | 79 |
| |
80 | 80 |
| |
| |||
85 | 85 |
| |
86 | 86 |
| |
87 | 87 |
| |
88 |
| - | |
| 88 | + | |
89 | 89 |
| |
90 | 90 |
| |
91 | 91 |
| |
| |||
116 | 116 |
| |
117 | 117 |
| |
118 | 118 |
| |
119 |
| - | |
120 |
| - | |
121 |
| - | |
| 119 | + | |
| 120 | + | |
122 | 121 |
| |
123 |
| - | |
124 |
| - | |
| 122 | + | |
| 123 | + | |
125 | 124 |
| |
126 | 125 |
| |
127 | 126 |
| |
| |||
130 | 129 |
| |
131 | 130 |
| |
132 | 131 |
| |
133 |
| - | |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 |
| - | |
138 |
| - | |
139 |
| - | |
140 |
| - | |
141 |
| - | |
142 |
| - | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
143 | 142 |
| |
144 | 143 |
| |
145 | 144 |
| |
|
Lines changed: 5 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
57 | 57 |
| |
58 | 58 |
| |
59 | 59 |
| |
60 |
| - | |
| 60 | + | |
61 | 61 |
| |
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
66 |
| - | |
| 66 | + | |
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
| |||
72 | 72 |
| |
73 | 73 |
| |
74 | 74 |
| |
75 |
| - | |
| 75 | + | |
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
91 |
| - | |
| 91 | + | |
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
| 103 | + | |
104 | 104 |
| |
105 | 105 |
| |
106 | 106 |
| |
|
0 commit comments
Comments
(0)