forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitaaf10f3
committed
Fix assorted bugs in pg_get_partition_constraintdef().
It failed if passed a nonexistent relation OID, or one that was a non-heaprelation, because of blindly applying heap_open to a user-supplied OID.This is not OK behavior for a SQL-exposed function; we have a projectpolicy that we should return NULL in such cases. Moreover, sincepg_get_partition_constraintdef ought now to work on indexes, restrictingit to heaps is flat wrong anyway.The underlying function generate_partition_qual() wasn't on board withindexes having partition quals either, nor for that matter with relshaving relispartition set but yet null relpartbound. (One wonderswhether the person who wrote the function comment blocks claiming thatthese functions allow a missing relpartbound had ever tested it.)Fix by testing relispartition before opening the rel, and by usingrelation_open not heap_open. (If any other relkinds ever grow theability to have relispartition set, the code will work with themautomatically.) Also, don't reject null relpartbound ingenerate_partition_qual.Back-patch to v11, and all but the null-relpartbound change to v10.(It's not really necessary to change generate_partition_qual at allin v10, but I thought s/heap_open/relation_open/ would be a goodidea anyway just to keep the code in sync with later branches.)Per report from Justin Pryzby.Discussion:https://postgr.es/m/20180927200020.GJ776@telsasoft.com1 parent4ec90f5 commitaaf10f3
File tree
5 files changed
+75
-19
lines changed- src
- backend/utils/cache
- include/utils
- test/regress
- expected
- sql
5 files changed
+75
-19
lines changedLines changed: 24 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1846 | 1846 |
| |
1847 | 1847 |
| |
1848 | 1848 |
| |
| 1849 | + | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
1849 | 1873 |
| |
1850 | 1874 |
| |
1851 | 1875 |
| |
|
Lines changed: 29 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
797 | 797 |
| |
798 | 798 |
| |
799 | 799 |
| |
800 |
| - | |
801 |
| - | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
802 | 807 |
| |
803 | 808 |
| |
804 | 809 |
| |
805 | 810 |
| |
806 |
| - | |
807 | 811 |
| |
808 |
| - | |
809 | 812 |
| |
810 |
| - | |
811 |
| - | |
| 813 | + | |
| 814 | + | |
812 | 815 |
| |
| 816 | + | |
| 817 | + | |
| 818 | + | |
813 | 819 |
| |
814 | 820 |
| |
| 821 | + | |
815 | 822 |
| |
816 | 823 |
| |
817 | 824 |
| |
818 | 825 |
| |
819 | 826 |
| |
820 | 827 |
| |
821 |
| - | |
822 | 828 |
| |
823 |
| - | |
824 |
| - | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
825 | 832 |
| |
826 | 833 |
| |
827 | 834 |
| |
| |||
845 | 852 |
| |
846 | 853 |
| |
847 | 854 |
| |
848 |
| - | |
849 | 855 |
| |
850 | 856 |
| |
851 | 857 |
| |
| |||
859 | 865 |
| |
860 | 866 |
| |
861 | 867 |
| |
862 |
| - | |
863 |
| - | |
| 868 | + | |
| 869 | + | |
864 | 870 |
| |
865 | 871 |
| |
866 | 872 |
| |
| |||
871 | 877 |
| |
872 | 878 |
| |
873 | 879 |
| |
874 |
| - | |
875 |
| - | |
876 |
| - | |
877 |
| - | |
878 |
| - | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
879 | 886 |
| |
880 |
| - | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
881 | 891 |
| |
882 | 892 |
| |
883 | 893 |
| |
| |||
903 | 913 |
| |
904 | 914 |
| |
905 | 915 |
| |
906 |
| - | |
| 916 | + | |
907 | 917 |
| |
908 | 918 |
| |
909 | 919 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
128 | 128 |
| |
129 | 129 |
| |
130 | 130 |
| |
| 131 | + | |
131 | 132 |
| |
132 | 133 |
| |
133 | 134 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
75 | 75 |
| |
76 | 76 |
| |
77 | 77 |
| |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
78 | 97 |
| |
79 | 98 |
| |
80 | 99 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
44 | 44 |
| |
45 | 45 |
| |
46 | 46 |
| |
| 47 | + | |
| 48 | + | |
47 | 49 |
| |
48 | 50 |
| |
49 | 51 |
| |
|
0 commit comments
Comments
(0)