forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitc35b714
committed
Fix misbehavior with expression indexes on ON COMMIT DELETE ROWS tables.
We implement ON COMMIT DELETE ROWS by truncating tables marked thatway, which requires also truncating/rebuilding their indexes. ButRelationTruncateIndexes asks the relcache for up-to-date copies of anyindex expressions, which may cause execution of eval_const_expressionson them, which can result in actual execution of subexpressions.This is a bad thing to have happening during ON COMMIT. Manuel Riggerreported that use of a SQL function resulted in crashes due toexpectations that ActiveSnapshot would be set, which it isn't.The most obvious fix perhaps would be to push a snapshot duringPreCommit_on_commit_actions, but I think that would just open the doorto more problems: CommitTransaction explicitly expects that nouser-defined code can be running at this point.Fortunately, since we know that no tuples exist to be indexed, thereseems no need to use the real index expressions or predicates duringRelationTruncateIndexes. We can set up dummy index expressionsinstead (we do need something that will expose the right data type,as there are places that build index tupdescs based on this), andjust ignore predicates and exclusion constraints.In a green field it'd likely be better to reimplement ON COMMIT DELETEROWS using the same "init fork" infrastructure used for unloggedrelations. That seems impractical without catalog changes though,and even without that it'd be too big a change to back-patch.So for now do it like this.Per private report from Manuel Rigger. This has been broken forever,so back-patch to all supported branches.1 parent4dc6355 commitc35b714
File tree
7 files changed
+118
-2
lines changed- src
- backend
- catalog
- utils/cache
- include
- catalog
- utils
- test/regress
- expected
- sql
7 files changed
+118
-2
lines changedLines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3148 | 3148 |
| |
3149 | 3149 |
| |
3150 | 3150 |
| |
3151 |
| - | |
3152 |
| - | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
3153 | 3160 |
| |
3154 | 3161 |
| |
3155 | 3162 |
| |
|
Lines changed: 50 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2324 | 2324 |
| |
2325 | 2325 |
| |
2326 | 2326 |
| |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
| 2334 | + | |
| 2335 | + | |
| 2336 | + | |
| 2337 | + | |
| 2338 | + | |
| 2339 | + | |
| 2340 | + | |
| 2341 | + | |
| 2342 | + | |
| 2343 | + | |
| 2344 | + | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
| 2352 | + | |
| 2353 | + | |
| 2354 | + | |
| 2355 | + | |
| 2356 | + | |
| 2357 | + | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
| 2368 | + | |
| 2369 | + | |
| 2370 | + | |
| 2371 | + | |
| 2372 | + | |
| 2373 | + | |
| 2374 | + | |
| 2375 | + | |
| 2376 | + | |
2327 | 2377 |
| |
2328 | 2378 |
| |
2329 | 2379 |
| |
|
Lines changed: 51 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
4629 | 4629 |
| |
4630 | 4630 |
| |
4631 | 4631 |
| |
| 4632 | + | |
| 4633 | + | |
| 4634 | + | |
| 4635 | + | |
| 4636 | + | |
| 4637 | + | |
| 4638 | + | |
| 4639 | + | |
| 4640 | + | |
| 4641 | + | |
| 4642 | + | |
| 4643 | + | |
| 4644 | + | |
| 4645 | + | |
| 4646 | + | |
| 4647 | + | |
| 4648 | + | |
| 4649 | + | |
| 4650 | + | |
| 4651 | + | |
| 4652 | + | |
| 4653 | + | |
| 4654 | + | |
| 4655 | + | |
| 4656 | + | |
| 4657 | + | |
| 4658 | + | |
| 4659 | + | |
| 4660 | + | |
| 4661 | + | |
| 4662 | + | |
| 4663 | + | |
| 4664 | + | |
| 4665 | + | |
| 4666 | + | |
| 4667 | + | |
| 4668 | + | |
| 4669 | + | |
| 4670 | + | |
| 4671 | + | |
| 4672 | + | |
| 4673 | + | |
| 4674 | + | |
| 4675 | + | |
| 4676 | + | |
| 4677 | + | |
| 4678 | + | |
| 4679 | + | |
| 4680 | + | |
| 4681 | + | |
| 4682 | + | |
4632 | 4683 |
| |
4633 | 4684 |
| |
4634 | 4685 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
106 | 106 |
| |
107 | 107 |
| |
108 | 108 |
| |
| 109 | + | |
| 110 | + | |
109 | 111 |
| |
110 | 112 |
| |
111 | 113 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
48 | 48 |
| |
49 | 49 |
| |
50 | 50 |
| |
| 51 | + | |
51 | 52 |
| |
52 | 53 |
| |
53 | 54 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
49 | 49 |
| |
50 | 50 |
| |
51 | 51 |
| |
| 52 | + | |
| 53 | + | |
52 | 54 |
| |
53 | 55 |
| |
54 | 56 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
55 | 55 |
| |
56 | 56 |
| |
57 | 57 |
| |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 |
| |
59 | 62 |
| |
60 | 63 |
| |
|
0 commit comments
Comments
(0)