- Notifications
You must be signed in to change notification settings - Fork28
Commit8e56684
committed
Fix permission checks on constraint violation errors on partitions.
If a cross-partition UPDATE violates a constraint on the target partition,and the columns in the new partition are in different physical order thanin the parent, the error message can reveal columns that the user does nothave SELECT permission on. A similar bug was fixed earlier in commit804b6b6.The cause of the bug is that the callers of theExecBuildSlotValueDescription() function got confused when constructingthe list of modified columns. If the tuple was routed from a parent, weconverted the tuple to the parent's format, but the list of modifiedcolumns was grabbed directly from the child's RTE entry.ExecUpdateLockMode() had a similar issue. That lead to confusion on whichcolumns are key columns, leading to wrong tuple lock being taken on tablesreferenced by foreign keys, when a row is updated with INSERT ON CONFLICTUPDATE. A new isolation test is added for that corner case.With this patch, the ri_RangeTableIndex field is no longer set forpartitions that don't have an entry in the range table. Previously, it wasset to the RTE entry of the parent relation, but that was confusing.NOTE: This modifies the ResultRelInfo struct, replacing theri_PartitionRoot field with ri_RootResultRelInfo. That's a bit risky tobackpatch, because it breaks any extensions accessing the field. Thechange that ri_RangeTableIndex is not set for partitions could potentiallybreak extensions, too. The ResultRelInfos are visible to FDWs at least,and this patch required small changes to postgres_fdw. Nevertheless, thisseem like the least bad option. I don't think these fields widely used inextensions; I don't think there are FDWs out there that uses the FDW"direct update" API, other than postgres_fdw. If there is, you will get acompilation error, so hopefully it is caught quickly.Backpatch to 11, where support for both cross-partition UPDATEs, and uniqueindexes on partitioned tables, were added.Reviewed-by: Amit LangoteSecurity:CVE-2021-33931 parentb4199a9 commit8e56684
File tree
17 files changed
+370
-89
lines changed- contrib/postgres_fdw
- src
- backend
- access/common
- commands
- executor
- include
- access
- executor
- nodes
- test
- isolation
- expected
- specs
- regress
- expected
- sql
17 files changed
+370
-89
lines changedLines changed: 15 additions & 5 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1922 | 1922 |
| |
1923 | 1923 |
| |
1924 | 1924 |
| |
1925 |
| - | |
| 1925 | + | |
1926 | 1926 |
| |
1927 | 1927 |
| |
1928 | 1928 |
| |
| |||
1973 | 1973 |
| |
1974 | 1974 |
| |
1975 | 1975 |
| |
1976 |
| - | |
| 1976 | + | |
| 1977 | + | |
1977 | 1978 |
| |
1978 | 1979 |
| |
1979 | 1980 |
| |
1980 | 1981 |
| |
1981 | 1982 |
| |
1982 | 1983 |
| |
1983 | 1984 |
| |
1984 |
| - | |
1985 |
| - | |
| 1985 | + | |
1986 | 1986 |
| |
| 1987 | + | |
| 1988 | + | |
| 1989 | + | |
1987 | 1990 |
| |
1988 | 1991 |
| |
1989 | 1992 |
| |
| |||
1995 | 1998 |
| |
1996 | 1999 |
| |
1997 | 2000 |
| |
1998 |
| - | |
| 2001 | + | |
1999 | 2002 |
| |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
2000 | 2010 |
| |
2001 | 2011 |
| |
2002 | 2012 |
| |
|
Lines changed: 51 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
226 | 226 |
| |
227 | 227 |
| |
228 | 228 |
| |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
229 | 280 |
| |
230 | 281 |
| |
231 | 282 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2804 | 2804 |
| |
2805 | 2805 |
| |
2806 | 2806 |
| |
| 2807 | + | |
2807 | 2808 |
| |
2808 | 2809 |
| |
2809 | 2810 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3681 | 3681 |
| |
3682 | 3682 |
| |
3683 | 3683 |
| |
3684 |
| - | |
| 3684 | + | |
3685 | 3685 |
| |
3686 | 3686 |
| |
3687 | 3687 |
| |
|
Lines changed: 10 additions & 14 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
69 | 69 |
| |
70 | 70 |
| |
71 | 71 |
| |
72 |
| - | |
73 |
| - | |
74 |
| - | |
75 |
| - | |
76 |
| - | |
77 |
| - | |
78 |
| - | |
79 |
| - | |
80 |
| - | |
81 |
| - | |
82 | 72 |
| |
83 | 73 |
| |
84 | 74 |
| |
| |||
2570 | 2560 |
| |
2571 | 2561 |
| |
2572 | 2562 |
| |
2573 |
| - | |
| 2563 | + | |
| 2564 | + | |
| 2565 | + | |
| 2566 | + | |
2574 | 2567 |
| |
2575 | 2568 |
| |
2576 | 2569 |
| |
| |||
2611 | 2604 |
| |
2612 | 2605 |
| |
2613 | 2606 |
| |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
2614 | 2610 |
| |
2615 | 2611 |
| |
2616 | 2612 |
| |
2617 |
| - | |
| 2613 | + | |
2618 | 2614 |
| |
2619 | 2615 |
| |
2620 | 2616 |
| |
| |||
2684 | 2680 |
| |
2685 | 2681 |
| |
2686 | 2682 |
| |
2687 |
| - | |
| 2683 | + | |
2688 | 2684 |
| |
2689 | 2685 |
| |
2690 | 2686 |
| |
| |||
2785 | 2781 |
| |
2786 | 2782 |
| |
2787 | 2783 |
| |
2788 |
| - | |
| 2784 | + | |
2789 | 2785 |
| |
2790 | 2786 |
| |
2791 | 2787 |
| |
|
Lines changed: 39 additions & 48 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
104 |
| - | |
105 |
| - | |
106 |
| - | |
107 |
| - | |
108 |
| - | |
109 |
| - | |
110 |
| - | |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 |
| - | |
116 |
| - | |
117 | 103 |
| |
118 | 104 |
| |
119 | 105 |
| |
| |||
1277 | 1263 |
| |
1278 | 1264 |
| |
1279 | 1265 |
| |
1280 |
| - | |
| 1266 | + | |
1281 | 1267 |
| |
1282 | 1268 |
| |
1283 | 1269 |
| |
| |||
1342 | 1328 |
| |
1343 | 1329 |
| |
1344 | 1330 |
| |
1345 |
| - | |
| 1331 | + | |
1346 | 1332 |
| |
1347 | 1333 |
| |
1348 | 1334 |
| |
| |||
1840 | 1826 |
| |
1841 | 1827 |
| |
1842 | 1828 |
| |
1843 |
| - | |
| 1829 | + | |
1844 | 1830 |
| |
| 1831 | + | |
1845 | 1832 |
| |
1846 | 1833 |
| |
1847 | 1834 |
| |
1848 |
| - | |
1849 |
| - | |
| 1835 | + | |
| 1836 | + | |
1850 | 1837 |
| |
1851 | 1838 |
| |
1852 | 1839 |
| |
| |||
1859 | 1846 |
| |
1860 | 1847 |
| |
1861 | 1848 |
| |
| 1849 | + | |
| 1850 | + | |
1862 | 1851 |
| |
1863 | 1852 |
| |
1864 | 1853 |
| |
1865 | 1854 |
| |
1866 | 1855 |
| |
| 1856 | + | |
| 1857 | + | |
1867 | 1858 |
| |
1868 | 1859 |
| |
1869 |
| - | |
1870 |
| - | |
1871 |
| - | |
1872 | 1860 |
| |
1873 | 1861 |
| |
1874 | 1862 |
| |
| |||
1901 | 1889 |
| |
1902 | 1890 |
| |
1903 | 1891 |
| |
1904 |
| - | |
1905 |
| - | |
1906 | 1892 |
| |
1907 | 1893 |
| |
1908 | 1894 |
| |
| |||
1928 | 1914 |
| |
1929 | 1915 |
| |
1930 | 1916 |
| |
1931 |
| - | |
| 1917 | + | |
1932 | 1918 |
| |
| 1919 | + | |
1933 | 1920 |
| |
1934 | 1921 |
| |
1935 |
| - | |
1936 |
| - | |
| 1922 | + | |
1937 | 1923 |
| |
1938 | 1924 |
| |
1939 | 1925 |
| |
| |||
1945 | 1931 |
| |
1946 | 1932 |
| |
1947 | 1933 |
| |
| 1934 | + | |
| 1935 | + | |
| 1936 | + | |
1948 | 1937 |
| |
1949 |
| - | |
1950 |
| - | |
1951 |
| - | |
1952 |
| - | |
| 1938 | + | |
| 1939 | + | |
| 1940 | + | |
1953 | 1941 |
| |
1954 | 1942 |
| |
1955 | 1943 |
| |
| |||
1977 | 1965 |
| |
1978 | 1966 |
| |
1979 | 1967 |
| |
1980 |
| - | |
| 1968 | + | |
1981 | 1969 |
| |
| 1970 | + | |
1982 | 1971 |
| |
1983 | 1972 |
| |
1984 | 1973 |
| |
1985 |
| - | |
1986 |
| - | |
| 1974 | + | |
1987 | 1975 |
| |
1988 | 1976 |
| |
1989 | 1977 |
| |
| |||
1995 | 1983 |
| |
1996 | 1984 |
| |
1997 | 1985 |
| |
| 1986 | + | |
| 1987 | + | |
| 1988 | + | |
1998 | 1989 |
| |
1999 |
| - | |
2000 |
| - | |
2001 |
| - | |
2002 |
| - | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
2003 | 1993 |
| |
2004 | 1994 |
| |
2005 | 1995 |
| |
| |||
2068 | 2058 |
| |
2069 | 2059 |
| |
2070 | 2060 |
| |
2071 |
| - | |
2072 |
| - | |
2073 | 2061 |
| |
2074 | 2062 |
| |
2075 | 2063 |
| |
| |||
2084 | 2072 |
| |
2085 | 2073 |
| |
2086 | 2074 |
| |
2087 |
| - | |
| 2075 | + | |
2088 | 2076 |
| |
| 2077 | + | |
2089 | 2078 |
| |
2090 | 2079 |
| |
2091 | 2080 |
| |
2092 |
| - | |
2093 |
| - | |
| 2081 | + | |
2094 | 2082 |
| |
2095 | 2083 |
| |
2096 | 2084 |
| |
| |||
2102 | 2090 |
| |
2103 | 2091 |
| |
2104 | 2092 |
| |
2105 |
| - | |
2106 | 2093 |
| |
2107 |
| - | |
2108 |
| - | |
2109 |
| - | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
2110 | 2101 |
| |
2111 | 2102 |
| |
2112 | 2103 |
| |
| |||
2320 | 2311 |
| |
2321 | 2312 |
| |
2322 | 2313 |
| |
2323 |
| - | |
| 2314 | + | |
2324 | 2315 |
| |
2325 | 2316 |
| |
2326 | 2317 |
| |
|
0 commit comments
Comments
(0)