- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit5c8c7c7
committed
Fix assorted bugs in CREATE INDEX CONCURRENTLY.
This patch changes CREATE INDEX CONCURRENTLY so that the pg_indexflag changes it makes without exclusive lock on the index are made viaheap_inplace_update() rather than a normal transactional update. Thelatter is not very safe because moving the pg_index tuple could result inconcurrent SnapshotNow scans finding it twice or not at all, thus possiblyresulting in index corruption.In addition, fix various places in the code that ought to check to makesure that the indexes they are manipulating are valid and/or ready asappropriate. These represent bugs that have existed since 8.2, sincea failed CREATE INDEX CONCURRENTLY could leave a corrupt or invalidindex behind, and we ought not try to do anything that might fail withsuch an index.Also fix RelationReloadIndexInfo to ensure it copies all the pg_indexcolumns that are allowed to change after initial creation. Previously wecould have been left with stale values of some fields in an index relcacheentry. It's not clear whether this actually had any user-visibleconsequences, but it's at least a bug waiting to happen.This is a subset of a patch already applied in 9.2 and HEAD. Back-patchinto all earlier supported branches.Tom Lane and Andres Freund1 parentfc9b2d0 commit5c8c7c7
File tree
11 files changed
+173
-57
lines changed- src
- backend
- access/heap
- catalog
- commands
- executor
- optimizer/util
- utils/cache
- include/catalog
11 files changed
+173
-57
lines changedLines changed: 6 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
404 | 404 |
| |
405 | 405 |
| |
406 | 406 |
| |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
407 | 413 |
| |
408 | 414 |
| |
409 | 415 |
| |
|
Lines changed: 84 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
995 | 995 |
| |
996 | 996 |
| |
997 | 997 |
| |
998 |
| - | |
| 998 | + | |
999 | 999 |
| |
1000 | 1000 |
| |
1001 | 1001 |
| |
| |||
1397 | 1397 |
| |
1398 | 1398 |
| |
1399 | 1399 |
| |
1400 |
| - | |
1401 |
| - | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
1402 | 1414 |
| |
1403 | 1415 |
| |
1404 | 1416 |
| |
| |||
2208 | 2220 |
| |
2209 | 2221 |
| |
2210 | 2222 |
| |
| 2223 | + | |
| 2224 | + | |
| 2225 | + | |
| 2226 | + | |
| 2227 | + | |
| 2228 | + | |
| 2229 | + | |
| 2230 | + | |
| 2231 | + | |
| 2232 | + | |
| 2233 | + | |
| 2234 | + | |
| 2235 | + | |
| 2236 | + | |
| 2237 | + | |
| 2238 | + | |
| 2239 | + | |
| 2240 | + | |
| 2241 | + | |
| 2242 | + | |
| 2243 | + | |
| 2244 | + | |
| 2245 | + | |
| 2246 | + | |
| 2247 | + | |
| 2248 | + | |
| 2249 | + | |
| 2250 | + | |
| 2251 | + | |
| 2252 | + | |
| 2253 | + | |
| 2254 | + | |
| 2255 | + | |
| 2256 | + | |
| 2257 | + | |
| 2258 | + | |
| 2259 | + | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
| 2263 | + | |
| 2264 | + | |
| 2265 | + | |
| 2266 | + | |
| 2267 | + | |
| 2268 | + | |
| 2269 | + | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
| 2273 | + | |
| 2274 | + | |
| 2275 | + | |
| 2276 | + | |
| 2277 | + | |
| 2278 | + | |
| 2279 | + | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
2211 | 2283 |
| |
2212 | 2284 |
| |
2213 | 2285 |
| |
| |||
2357 | 2429 |
| |
2358 | 2430 |
| |
2359 | 2431 |
| |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
2360 | 2441 |
| |
2361 | 2442 |
| |
2362 | 2443 |
| |
|
Lines changed: 9 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
431 | 431 |
| |
432 | 432 |
| |
433 | 433 |
| |
434 |
| - | |
| 434 | + | |
435 | 435 |
| |
436 | 436 |
| |
437 | 437 |
| |
| |||
473 | 473 |
| |
474 | 474 |
| |
475 | 475 |
| |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
476 | 481 |
| |
477 | 482 |
| |
478 | 483 |
| |
| |||
533 | 538 |
| |
534 | 539 |
| |
535 | 540 |
| |
| 541 | + | |
| 542 | + | |
| 543 | + | |
536 | 544 |
| |
537 | 545 |
| |
538 | 546 |
| |
|
Lines changed: 3 additions & 40 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
131 | 131 |
| |
132 | 132 |
| |
133 | 133 |
| |
134 |
| - | |
135 |
| - | |
136 |
| - | |
137 | 134 |
| |
138 | 135 |
| |
139 | 136 |
| |
| |||
559 | 556 |
| |
560 | 557 |
| |
561 | 558 |
| |
562 |
| - | |
563 |
| - | |
564 |
| - | |
565 |
| - | |
566 |
| - | |
567 |
| - | |
568 |
| - | |
569 |
| - | |
570 |
| - | |
571 |
| - | |
572 |
| - | |
573 |
| - | |
574 |
| - | |
575 |
| - | |
576 |
| - | |
577 |
| - | |
578 |
| - | |
579 |
| - | |
| 559 | + | |
580 | 560 |
| |
581 | 561 |
| |
582 | 562 |
| |
| |||
654 | 634 |
| |
655 | 635 |
| |
656 | 636 |
| |
657 |
| - | |
658 |
| - | |
659 |
| - | |
660 |
| - | |
661 |
| - | |
662 |
| - | |
663 |
| - | |
664 |
| - | |
665 |
| - | |
666 |
| - | |
667 |
| - | |
668 |
| - | |
669 |
| - | |
670 |
| - | |
671 |
| - | |
672 |
| - | |
673 |
| - | |
674 |
| - | |
| 637 | + | |
675 | 638 |
| |
676 | 639 |
| |
677 | 640 |
| |
678 | 641 |
| |
679 | 642 |
| |
680 | 643 |
| |
681 | 644 |
| |
682 |
| - | |
| 645 | + | |
683 | 646 |
| |
684 | 647 |
| |
685 | 648 |
| |
|
Lines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3228 | 3228 |
| |
3229 | 3229 |
| |
3230 | 3230 |
| |
| 3231 | + | |
| 3232 | + | |
3231 | 3233 |
| |
3232 | 3234 |
| |
3233 | 3235 |
| |
| |||
4226 | 4228 |
| |
4227 | 4229 |
| |
4228 | 4230 |
| |
4229 |
| - | |
| 4231 | + | |
4230 | 4232 |
| |
4231 | 4233 |
| |
4232 | 4234 |
| |
| |||
4242 | 4244 |
| |
4243 | 4245 |
| |
4244 | 4246 |
| |
4245 |
| - | |
| 4247 | + | |
4246 | 4248 |
| |
4247 | 4249 |
| |
4248 | 4250 |
| |
| |||
4330 | 4332 |
| |
4331 | 4333 |
| |
4332 | 4334 |
| |
4333 |
| - | |
| 4335 | + | |
| 4336 | + | |
4334 | 4337 |
| |
4335 | 4338 |
| |
4336 | 4339 |
| |
| 4340 | + | |
4337 | 4341 |
| |
4338 | 4342 |
| |
4339 | 4343 |
| |
|
Lines changed: 23 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3672 | 3672 |
| |
3673 | 3673 |
| |
3674 | 3674 |
| |
3675 |
| - | |
3676 |
| - | |
3677 |
| - | |
| 3675 | + | |
| 3676 | + | |
| 3677 | + | |
| 3678 | + | |
| 3679 | + | |
| 3680 | + | |
| 3681 | + | |
| 3682 | + | |
| 3683 | + | |
| 3684 | + | |
3678 | 3685 |
| |
3679 | 3686 |
| |
3680 | 3687 |
| |
| |||
3688 | 3695 |
| |
3689 | 3696 |
| |
3690 | 3697 |
| |
3691 |
| - | |
| 3698 | + | |
| 3699 | + | |
3692 | 3700 |
| |
3693 |
| - | |
3694 |
| - | |
| 3701 | + | |
| 3702 | + | |
3695 | 3703 |
| |
3696 | 3704 |
| |
3697 | 3705 |
| |
| 3706 | + | |
3698 | 3707 |
| |
3699 | 3708 |
| |
3700 | 3709 |
| |
3701 | 3710 |
| |
| 3711 | + | |
3702 | 3712 |
| |
3703 |
| - | |
| 3713 | + | |
| 3714 | + | |
| 3715 | + | |
| 3716 | + | |
| 3717 | + | |
3704 | 3718 |
| |
3705 | 3719 |
| |
| 3720 | + | |
| 3721 | + | |
3706 | 3722 |
| |
3707 | 3723 |
| |
3708 | 3724 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
921 | 921 |
| |
922 | 922 |
| |
923 | 923 |
| |
| 924 | + | |
| 925 | + | |
| 926 | + | |
924 | 927 |
| |
925 | 928 |
| |
926 | 929 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
159 | 159 |
| |
160 | 160 |
| |
161 | 161 |
| |
162 |
| - | |
| 162 | + | |
| 163 | + | |
163 | 164 |
| |
164 |
| - | |
| 165 | + | |
165 | 166 |
| |
166 | 167 |
| |
167 | 168 |
| |
|
Lines changed: 18 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1700 | 1700 |
| |
1701 | 1701 |
| |
1702 | 1702 |
| |
| 1703 | + | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
1703 | 1712 |
| |
1704 | 1713 |
| |
1705 | 1714 |
| |
| 1715 | + | |
| 1716 | + | |
1706 | 1717 |
| |
1707 | 1718 |
| |
1708 | 1719 |
| |
| |||
3077 | 3088 |
| |
3078 | 3089 |
| |
3079 | 3090 |
| |
3080 |
| - | |
| 3091 | + | |
| 3092 | + | |
3081 | 3093 |
| |
3082 | 3094 |
| |
3083 | 3095 |
| |
| |||
3384 | 3396 |
| |
3385 | 3397 |
| |
3386 | 3398 |
| |
| 3399 | + | |
| 3400 | + | |
| 3401 | + | |
| 3402 | + | |
| 3403 | + | |
3387 | 3404 |
| |
3388 | 3405 |
| |
3389 | 3406 |
| |
|
0 commit comments
Comments
(0)