forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita4d56f5
committed
Use the right memory context for partkey's FmgrInfo
We were using CurrentMemoryContext to put the partsupfunc fmgr_infointo, which isn't right, because we want the PartitionKey as a whole tobe in the isolated Relation->rd_partkeycxt context. This can cause acrash with user-defined support functions in the operator classes usedby partitioning keys. (Maybe this can cause problems with core-suppliedopclasses too, not sure.)This is demonstrably broken in Postgres 10, too, but the initialproposed fix runs afoul of a problem discussed back when8a0596c("Get rid of copy_partition_key") reorganized that code: namely that itis possible to jump out of RelationBuildPartitionKey because of someerror and leave a dangling memory context child of CacheMemoryContext.Also, while reviewing this I noticed that the removed-in-pg11copy_partition_key was doing something wrong, unfixed in pg10, namelydoing memcpy() on the FmgrInfo, which is bogus (should be doingfmgr_info_copy). Therefore, in branch pg10, the sane fix seems to be tobackpatch both the aforementioned8a0596c and its followupbe23432 ("Protect against hypothetical memory leaks inRelationGetPartitionKey"), so do that, then apply the fmgr_info memcxtbugfix on top.Add a test case exercising btree-based custom operator classes, whichcauses a crash prior to this fix. This is not a security problem,because in order to create an operator class you need superuserprivileges anyway.Authors: Álvaro Herrera and Amit LangoteReported and diagnosed by: Amit LangoteDiscussion:https://postgr.es/m/3041e853-b1dd-a0c6-ff21-7cc5633bffd0@lab.ntt.co.jp1 parent3e110a3 commita4d56f5
File tree
3 files changed
+30
-5
lines changed- src
- backend/utils/cache
- test/regress
- expected
- sql
3 files changed
+30
-5
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1034 | 1034 |
| |
1035 | 1035 |
| |
1036 | 1036 |
| |
1037 |
| - | |
| 1037 | + | |
1038 | 1038 |
| |
1039 | 1039 |
| |
1040 | 1040 |
| |
|
Lines changed: 14 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
837 | 837 |
| |
838 | 838 |
| |
839 | 839 |
| |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
840 | 851 |
| |
841 | 852 |
| |
842 |
| - | |
843 |
| - | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
844 | 856 |
| |
845 | 857 |
| |
846 | 858 |
| |
|
Lines changed: 15 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
688 | 688 |
| |
689 | 689 |
| |
690 | 690 |
| |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
691 | 703 |
| |
692 | 704 |
| |
693 |
| - | |
694 |
| - | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
695 | 708 |
| |
696 | 709 |
| |
697 | 710 |
| |
|
0 commit comments
Comments
(0)