forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit23e0ba5
committed
Prevent access to an unpinned buffer in BEFORE ROW UPDATE triggers.
When ExecBRUpdateTriggers switches to a new target tuple as a resultof the EvalPlanQual logic, it must form a new proposed update tuple.Since commit86dc900, that tuple (the result ofExecGetUpdateNewTuple) has been a virtual tuple that might containpointers to by-ref fields of the new target tuple (in "oldslot").However, immediately after that we materialize oldslot, causing it todrop its buffer pin, whereupon the by-ref pointers are unsafe to use.This is a live bug only when the new target tuple is in a differentpage than the original target tuple, since we do still hold a pin onthe original one. (Before86dc900, there was no bug because theEPQ plantree would hold a pin on the new target tuple; but now that'snot assured.) To fix, forcibly materialize the new tuple before wematerialize oldslot. This costs nothing since we would have done thatshortly anyway.The real-world impact of this is probably minimal. A visible failurecould occur if the new target tuple's buffer were recycled for someother page in the short interval before we materialize newslot withinthe trigger-calling loop; but that's quite unlikely given that we'djust touched that page. There's a larger hazard that some otherprocess could prune and repack that page within the window. We havelock on the new target tuple, but that wouldn't prevent it being movedon the page.Alexander Lakhin and Tom Lane, per bug #17798 from Alexander Lakhin.Back-patch to v14 where86dc900 came in.Discussion:https://postgr.es/m/17798-0907404928dcf0dd@postgresql.org1 parent56dcd71 commit23e0ba5
1 file changed
+23
-5
lines changedLines changed: 23 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2978 | 2978 |
| |
2979 | 2979 |
| |
2980 | 2980 |
| |
2981 |
| - | |
2982 |
| - | |
2983 |
| - | |
2984 |
| - | |
2985 | 2981 |
| |
2986 | 2982 |
| |
2987 | 2983 |
| |
| |||
2990 | 2986 |
| |
2991 | 2987 |
| |
2992 | 2988 |
| |
2993 |
| - | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
| 2995 | + | |
2994 | 2996 |
| |
| 2997 | + | |
| 2998 | + | |
| 2999 | + | |
| 3000 | + | |
| 3001 | + | |
| 3002 | + | |
| 3003 | + | |
| 3004 | + | |
| 3005 | + | |
| 3006 | + | |
| 3007 | + | |
2995 | 3008 |
| |
2996 | 3009 |
| |
| 3010 | + | |
| 3011 | + | |
| 3012 | + | |
| 3013 | + | |
2997 | 3014 |
| |
2998 | 3015 |
| |
2999 | 3016 |
| |
3000 | 3017 |
| |
| 3018 | + | |
3001 | 3019 |
| |
3002 | 3020 |
| |
3003 | 3021 |
| |
|
0 commit comments
Comments
(0)