Commit b35617d
committed
Process session_preload_libraries within InitPostgres's transaction.
Previously we did this after InitPostgres, at a somewhat randomly chosen
place within PostgresMain. However, since commit a0ffa88 doing this
outside a transaction can cause a crash, if we need to check permissions
while replacing a placeholder GUC. (Besides which, a preloaded library
could itself want to do database access within _PG_init.)
To avoid needing an additional transaction start/end in every session,
move the process_session_preload_libraries call to within InitPostgres's
transaction. That requires teaching the code not to call it when
InitPostgres is called from somewhere other than PostgresMain, since
we don't want session_preload_libraries to affect background workers.
The most future-proof solution here seems to be to add an additional
flag parameter to InitPostgres; fortunately, we're not yet very worried
about API stability for v15.
Doing this also exposed the fact that we're currently honoring
session_preload_libraries in walsenders, even those not connected to
any database. This seems, at minimum, a POLA violation: walsenders
are not interactive sessions. Let's stop doing that.
(All these comments also apply to local_preload_libraries, of course.)
Per report from Gurjeet Singh (thanks also to Nathan Bossart and Kyotaro
Horiguchi for review). Backpatch to v15 where a0ffa88 came in.
Discussion: https://postgr.es/m/CABwTF4VEpwTHhRQ+q5MiC5ucngN-whN-PdcKeufX7eLSoAfbZA@mail.gmail.com1 parent 7a08f78 commit b35617d
File tree
6 files changed
+64
-25
lines changed- src
- backend
- bootstrap
- postmaster
- tcop
- utils/init
- include
6 files changed
+64
-25
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
357 | | - | |
| 357 | + | |
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
475 | 475 | | |
476 | 476 | | |
477 | 477 | | |
478 | | - | |
| 478 | + | |
479 | 479 | | |
480 | 480 | | |
481 | 481 | | |
| |||
1694 | 1694 | | |
1695 | 1695 | | |
1696 | 1696 | | |
1697 | | - | |
| 1697 | + | |
1698 | 1698 | | |
1699 | 1699 | | |
1700 | 1700 | | |
1701 | 1701 | | |
1702 | | - | |
| 1702 | + | |
| 1703 | + | |
1703 | 1704 | | |
1704 | 1705 | | |
1705 | 1706 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5654 | 5654 | | |
5655 | 5655 | | |
5656 | 5656 | | |
5657 | | - | |
| 5657 | + | |
| 5658 | + | |
| 5659 | + | |
| 5660 | + | |
| 5661 | + | |
5658 | 5662 | | |
5659 | 5663 | | |
5660 | 5664 | | |
| |||
5677 | 5681 | | |
5678 | 5682 | | |
5679 | 5683 | | |
5680 | | - | |
| 5684 | + | |
| 5685 | + | |
| 5686 | + | |
| 5687 | + | |
| 5688 | + | |
5681 | 5689 | | |
5682 | 5690 | | |
5683 | 5691 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4076 | 4076 | | |
4077 | 4077 | | |
4078 | 4078 | | |
4079 | | - | |
| 4079 | + | |
| 4080 | + | |
| 4081 | + | |
| 4082 | + | |
| 4083 | + | |
4080 | 4084 | | |
4081 | 4085 | | |
4082 | 4086 | | |
| |||
4112 | 4116 | | |
4113 | 4117 | | |
4114 | 4118 | | |
4115 | | - | |
4116 | | - | |
4117 | | - | |
4118 | | - | |
4119 | | - | |
4120 | | - | |
4121 | 4119 | | |
4122 | 4120 | | |
4123 | 4121 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
622 | 622 | | |
623 | 623 | | |
624 | 624 | | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
625 | 632 | | |
626 | | - | |
| 633 | + | |
| 634 | + | |
627 | 635 | | |
628 | 636 | | |
629 | 637 | | |
630 | | - | |
| 638 | + | |
631 | 639 | | |
632 | 640 | | |
633 | | - | |
634 | | - | |
635 | | - | |
636 | | - | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
| 652 | + | |
637 | 653 | | |
638 | | - | |
639 | | - | |
| 654 | + | |
| 655 | + | |
640 | 656 | | |
641 | 657 | | |
642 | 658 | | |
643 | 659 | | |
644 | 660 | | |
645 | 661 | | |
646 | | - | |
647 | | - | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
648 | 667 | | |
649 | 668 | | |
650 | 669 | | |
| |||
1108 | 1127 | | |
1109 | 1128 | | |
1110 | 1129 | | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
1111 | 1140 | | |
1112 | 1141 | | |
1113 | 1142 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
449 | 449 | | |
450 | 450 | | |
451 | 451 | | |
452 | | - | |
453 | | - | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
454 | 457 | | |
455 | 458 | | |
456 | 459 | | |
| |||
0 commit comments