forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit5f11c6e
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 parent08e6cda commit5f11c6e
File tree
4 files changed
+60
-80
lines changed- src
- backend/utils/cache
- include/access
- test/regress
- expected
- sql
4 files changed
+60
-80
lines changedLines changed: 30 additions & 79 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
269 |
| - | |
270 | 269 |
| |
271 | 270 |
| |
272 | 271 |
| |
| |||
811 | 810 |
| |
812 | 811 |
| |
813 | 812 |
| |
814 |
| - | |
815 |
| - | |
816 |
| - | |
817 |
| - | |
818 |
| - | |
819 |
| - | |
820 |
| - | |
821 |
| - | |
822 |
| - | |
823 |
| - | |
824 |
| - | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
825 | 823 |
| |
826 | 824 |
| |
827 | 825 |
| |
| |||
849 | 847 |
| |
850 | 848 |
| |
851 | 849 |
| |
852 |
| - | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
853 | 856 |
| |
854 | 857 |
| |
855 | 858 |
| |
| |||
896 | 899 |
| |
897 | 900 |
| |
898 | 901 |
| |
899 |
| - | |
| 902 | + | |
| 903 | + | |
900 | 904 |
| |
901 |
| - | |
902 |
| - | |
903 |
| - | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
904 | 908 |
| |
905 | 909 |
| |
| 910 | + | |
906 | 911 |
| |
907 | 912 |
| |
908 | 913 |
| |
| |||
917 | 922 |
| |
918 | 923 |
| |
919 | 924 |
| |
| 925 | + | |
920 | 926 |
| |
921 | 927 |
| |
922 | 928 |
| |
| |||
951 | 957 |
| |
952 | 958 |
| |
953 | 959 |
| |
954 |
| - | |
| 960 | + | |
955 | 961 |
| |
956 | 962 |
| |
957 | 963 |
| |
| |||
984 | 990 |
| |
985 | 991 |
| |
986 | 992 |
| |
987 |
| - | |
988 |
| - | |
989 |
| - | |
990 |
| - | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
991 | 998 |
| |
992 |
| - | |
993 |
| - | |
994 |
| - | |
995 |
| - | |
996 |
| - | |
997 |
| - | |
998 |
| - | |
999 |
| - | |
1000 |
| - | |
1001 |
| - | |
1002 |
| - | |
1003 |
| - | |
1004 |
| - | |
1005 |
| - | |
1006 |
| - | |
1007 |
| - | |
1008 |
| - | |
1009 |
| - | |
1010 |
| - | |
1011 |
| - | |
1012 |
| - | |
1013 |
| - | |
1014 |
| - | |
1015 |
| - | |
1016 |
| - | |
1017 |
| - | |
1018 |
| - | |
1019 |
| - | |
1020 |
| - | |
1021 |
| - | |
1022 |
| - | |
1023 |
| - | |
1024 |
| - | |
1025 |
| - | |
1026 |
| - | |
1027 |
| - | |
1028 |
| - | |
1029 |
| - | |
1030 |
| - | |
1031 |
| - | |
1032 |
| - | |
1033 |
| - | |
1034 |
| - | |
1035 |
| - | |
1036 |
| - | |
1037 |
| - | |
1038 |
| - | |
1039 |
| - | |
1040 |
| - | |
1041 |
| - | |
1042 |
| - | |
1043 |
| - | |
1044 |
| - | |
1045 |
| - | |
1046 |
| - | |
1047 |
| - | |
1048 |
| - | |
| 999 | + | |
1049 | 1000 |
| |
1050 | 1001 |
| |
1051 | 1002 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
290 | 290 |
| |
291 | 291 |
| |
292 | 292 |
| |
293 |
| - | |
| 293 | + | |
294 | 294 |
| |
295 | 295 |
| |
296 | 296 |
| |
|
Lines changed: 14 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
764 | 764 |
| |
765 | 765 |
| |
766 | 766 |
| |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
767 | 778 |
| |
768 | 779 |
| |
| 780 | + | |
| 781 | + | |
| 782 | + | |
769 | 783 |
| |
770 | 784 |
| |
771 | 785 |
| |
|
Lines changed: 15 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
637 | 637 |
| |
638 | 638 |
| |
639 | 639 |
| |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
640 | 652 |
| |
641 | 653 |
| |
| 654 | + | |
| 655 | + | |
| 656 | + | |
642 | 657 |
| |
643 | 658 |
| |
644 | 659 |
| |
|
0 commit comments
Comments
(0)