forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit2afe282
committed
Fix reporting of column typmods for multi-row VALUES constructs.
expandRTE() and get_rte_attribute_type() reported the exprType() andexprTypmod() values of the expressions in the first row of the VALUES asbeing the column type/typmod returned by the VALUES RTE. That's fine forthe data type, since we coerce all expressions in a column to have the samecommon type. But we don't coerce them to have a common typmod, so it waspossible for rows after the first one to return values that violate theclaimed column typmod. This leads to the incorrect result seen in bug#14448 from Hassan Mahmood, as well as some other corner-case misbehaviors.The desired behavior is the same as we use in other type-unificationcases: report the common typmod if there is one, but otherwise return -1indicating no particular constraint.We fixed this in HEAD by deriving the typmods during transformValuesClauseand storing them in the RTE, but that's not a feasible solution in the backbranches. Instead, just use a brute-force approach of determining thecorrect common typmod during expandRTE() and get_rte_attribute_type().Simple testing says that that doesn't really cost much, at least not incommon cases where expandRTE() is only used once per query. It turns outthat get_rte_attribute_type() is typically never used at all on VALUESRTEs, so the inefficiency there is of no great concern.Report:https://postgr.es/m/20161205143037.4377.60754@wrigleys.postgresql.orgDiscussion:https://postgr.es/m/27429.1480968538@sss.pgh.pa.us1 parent8e403f2 commit2afe282
File tree
3 files changed
+147
-4
lines changed- src
- backend/parser
- test/regress
- expected
- sql
3 files changed
+147
-4
lines changedLines changed: 97 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
50 | 50 |
| |
51 | 51 |
| |
52 | 52 |
| |
| 53 | + | |
53 | 54 |
| |
54 | 55 |
| |
55 | 56 |
| |
| |||
1814 | 1815 |
| |
1815 | 1816 |
| |
1816 | 1817 |
| |
| 1818 | + | |
1817 | 1819 |
| |
1818 | 1820 |
| |
1819 | 1821 |
| |
| 1822 | + | |
| 1823 | + | |
| 1824 | + | |
| 1825 | + | |
| 1826 | + | |
| 1827 | + | |
| 1828 | + | |
| 1829 | + | |
| 1830 | + | |
| 1831 | + | |
| 1832 | + | |
| 1833 | + | |
1820 | 1834 |
| |
1821 | 1835 |
| |
1822 | 1836 |
| |
| |||
1841 | 1855 |
| |
1842 | 1856 |
| |
1843 | 1857 |
| |
1844 |
| - | |
| 1858 | + | |
1845 | 1859 |
| |
1846 | 1860 |
| |
1847 | 1861 |
| |
1848 | 1862 |
| |
1849 | 1863 |
| |
1850 | 1864 |
| |
| 1865 | + | |
| 1866 | + | |
1851 | 1867 |
| |
1852 | 1868 |
| |
1853 | 1869 |
| |
| |||
1953 | 1969 |
| |
1954 | 1970 |
| |
1955 | 1971 |
| |
| 1972 | + | |
| 1973 | + | |
1956 | 1974 |
| |
1957 | 1975 |
| |
1958 | 1976 |
| |
| |||
2043 | 2061 |
| |
2044 | 2062 |
| |
2045 | 2063 |
| |
| 2064 | + | |
| 2065 | + | |
| 2066 | + | |
| 2067 | + | |
| 2068 | + | |
| 2069 | + | |
| 2070 | + | |
| 2071 | + | |
| 2072 | + | |
| 2073 | + | |
| 2074 | + | |
| 2075 | + | |
| 2076 | + | |
| 2077 | + | |
| 2078 | + | |
| 2079 | + | |
| 2080 | + | |
| 2081 | + | |
| 2082 | + | |
| 2083 | + | |
| 2084 | + | |
| 2085 | + | |
| 2086 | + | |
| 2087 | + | |
| 2088 | + | |
| 2089 | + | |
| 2090 | + | |
| 2091 | + | |
| 2092 | + | |
| 2093 | + | |
| 2094 | + | |
| 2095 | + | |
| 2096 | + | |
| 2097 | + | |
| 2098 | + | |
| 2099 | + | |
| 2100 | + | |
| 2101 | + | |
| 2102 | + | |
| 2103 | + | |
| 2104 | + | |
| 2105 | + | |
| 2106 | + | |
| 2107 | + | |
| 2108 | + | |
| 2109 | + | |
| 2110 | + | |
| 2111 | + | |
| 2112 | + | |
| 2113 | + | |
| 2114 | + | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
| 2121 | + | |
| 2122 | + | |
| 2123 | + | |
| 2124 | + | |
| 2125 | + | |
| 2126 | + | |
| 2127 | + | |
| 2128 | + | |
| 2129 | + | |
| 2130 | + | |
| 2131 | + | |
2046 | 2132 |
| |
2047 | 2133 |
| |
2048 | 2134 |
| |
| |||
2256 | 2342 |
| |
2257 | 2343 |
| |
2258 | 2344 |
| |
2259 |
| - | |
2260 |
| - | |
| 2345 | + | |
| 2346 | + | |
| 2347 | + | |
| 2348 | + | |
| 2349 | + | |
| 2350 | + | |
| 2351 | + | |
2261 | 2352 |
| |
2262 | 2353 |
| |
| 2354 | + | |
2263 | 2355 |
| |
2264 | 2356 |
| |
2265 | 2357 |
| |
2266 | 2358 |
| |
2267 | 2359 |
| |
2268 | 2360 |
| |
2269 |
| - | |
| 2361 | + | |
2270 | 2362 |
| |
| 2363 | + | |
2271 | 2364 |
| |
2272 | 2365 |
| |
2273 | 2366 |
| |
|
Lines changed: 37 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
288 | 288 |
| |
289 | 289 |
| |
290 | 290 |
| |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
291 | 328 |
| |
292 | 329 |
| |
293 | 330 |
| |
|
Lines changed: 13 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
224 | 224 |
| |
225 | 225 |
| |
226 | 226 |
| |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
227 | 240 |
| |
228 | 241 |
| |
229 | 242 |
| |
|
0 commit comments
Comments
(0)