forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitcf22c8c
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 parent79c89f1 commitcf22c8c
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 | |
---|---|---|---|
| |||
52 | 52 |
| |
53 | 53 |
| |
54 | 54 |
| |
| 55 | + | |
55 | 56 |
| |
56 | 57 |
| |
57 | 58 |
| |
| |||
2157 | 2158 |
| |
2158 | 2159 |
| |
2159 | 2160 |
| |
| 2161 | + | |
2160 | 2162 |
| |
2161 | 2163 |
| |
2162 | 2164 |
| |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
| 2175 | + | |
| 2176 | + | |
2163 | 2177 |
| |
2164 | 2178 |
| |
2165 | 2179 |
| |
| |||
2184 | 2198 |
| |
2185 | 2199 |
| |
2186 | 2200 |
| |
2187 |
| - | |
| 2201 | + | |
2188 | 2202 |
| |
2189 | 2203 |
| |
2190 | 2204 |
| |
2191 | 2205 |
| |
2192 | 2206 |
| |
2193 | 2207 |
| |
| 2208 | + | |
| 2209 | + | |
2194 | 2210 |
| |
2195 | 2211 |
| |
2196 | 2212 |
| |
| |||
2296 | 2312 |
| |
2297 | 2313 |
| |
2298 | 2314 |
| |
| 2315 | + | |
| 2316 | + | |
2299 | 2317 |
| |
2300 | 2318 |
| |
2301 | 2319 |
| |
| |||
2412 | 2430 |
| |
2413 | 2431 |
| |
2414 | 2432 |
| |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
| 2498 | + | |
| 2499 | + | |
| 2500 | + | |
2415 | 2501 |
| |
2416 | 2502 |
| |
2417 | 2503 |
| |
| |||
2656 | 2742 |
| |
2657 | 2743 |
| |
2658 | 2744 |
| |
2659 |
| - | |
2660 |
| - | |
| 2745 | + | |
| 2746 | + | |
| 2747 | + | |
| 2748 | + | |
| 2749 | + | |
| 2750 | + | |
| 2751 | + | |
2661 | 2752 |
| |
2662 | 2753 |
| |
| 2754 | + | |
2663 | 2755 |
| |
2664 | 2756 |
| |
2665 | 2757 |
| |
2666 | 2758 |
| |
2667 | 2759 |
| |
2668 | 2760 |
| |
2669 |
| - | |
| 2761 | + | |
2670 | 2762 |
| |
| 2763 | + | |
2671 | 2764 |
| |
2672 | 2765 |
| |
2673 | 2766 |
| |
|
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)