forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitea68ea6
committed
Repair incorrect handling of AfterTriggerSharedData.ats_modifiedcols.
This patch fixes two distinct errors that both ultimately traceto commit71d60e2, which added the ats_modifiedcols field.The more severe error is that ats_modifiedcols wasn't accounted forin afterTriggerAddEvent's scanning loop that looks for a pre-existingduplicate AfterTriggerSharedData. Thus, a new event could beincorrectly matched to an AfterTriggerSharedData that has a differentvalue of ats_modifiedcols, resulting in the wrong tg_updatedcolsbitmap getting passed to the trigger whenever it finally gets fired.We'd not noticed because (a) few triggers consult tg_updatedcols,and (b) we had no tests exercising a case where such a trigger wascalled as an AFTER trigger. In the test case added by this commit,contrib/lo's trigger fails to remove a large object when expectedbecause (without this fix) it thinks the LO OID column hasn't changed.The other problem was introduced by commitce5aaea, which copied themodified-columns bitmap into trigger-related storage. It made a copyfor every trigger event, whereas what we really want is to make a newcopy only when we make a new AfterTriggerSharedData entry. (We couldimagine adding extra logic to reduce the number of bitmap copies stillmore, but it doesn't look worthwhile at the moment.) In a simple testof an UPDATE of 10000000 rows with a single AFTER trigger, this thinkoroughly tripled the amount of memory consumed by the pending-triggersdata structures, from 160446744 to 480443440 bytes.Fixing the first problem requires introducing a bms_equal() call intoafterTriggerAddEvent's scanning loop, which is slightly annoying froma speed perspective. However, getting rid of the excessive bms_copy()calls from the second problem balances that out; overall speed oftrigger operations is the same or slightly better, in my tests.Discussion:https://postgr.es/m/3496294.1737501591@sss.pgh.pa.usBackpatch-through: 131 parent991974b commitea68ea6
3 files changed
+118
-10
lines changedLines changed: 69 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
47 | 47 |
| |
48 | 48 |
| |
49 | 49 |
| |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
50 | 119 |
| |
51 | 120 |
| |
52 | 121 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
27 | 27 |
| |
28 | 28 |
| |
29 | 29 |
| |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
30 | 71 |
| |
31 | 72 |
| |
32 | 73 |
|
Lines changed: 8 additions & 10 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4006 | 4006 |
| |
4007 | 4007 |
| |
4008 | 4008 |
| |
4009 |
| - | |
4010 |
| - | |
4011 |
| - | |
4012 |
| - | |
4013 |
| - | |
4014 |
| - | |
4015 |
| - | |
4016 | 4009 |
| |
4017 | 4010 |
| |
4018 | 4011 |
| |
| |||
4117 | 4110 |
| |
4118 | 4111 |
| |
4119 | 4112 |
| |
| 4113 | + | |
4120 | 4114 |
| |
4121 |
| - | |
4122 | 4115 |
| |
| 4116 | + | |
4123 | 4117 |
| |
4124 |
| - | |
| 4118 | + | |
| 4119 | + | |
| 4120 | + | |
4125 | 4121 |
| |
4126 | 4122 |
| |
4127 | 4123 |
| |
4128 | 4124 |
| |
4129 | 4125 |
| |
| 4126 | + | |
| 4127 | + | |
4130 | 4128 |
| |
4131 | 4129 |
| |
4132 | 4130 |
| |
| |||
6437 | 6435 |
| |
6438 | 6436 |
| |
6439 | 6437 |
| |
6440 |
| - | |
| 6438 | + | |
6441 | 6439 |
| |
6442 | 6440 |
| |
6443 | 6441 |
| |
|
0 commit comments
Comments
(0)