forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit8e2e0f7
committed
Fix failure to validate the result of select_common_type().
Although select_common_type() has a failure-return convention, anapparent successful return just provides a type OID that *might* workas a common supertype; we've not validated that the required castsactually exist. In the mainstream use-cases that doesn't matter,because we'll proceed to invoke coerce_to_common_type() on each input,which will fail appropriately if the proposed common type doesn'tactually work. However, a few callers didn't read the (nonexistent)fine print, and thought that if they got back a nonzero OID then thecoercions were sure to work.This affects in particular the recently-added "anycompatible"polymorphic types; we might think that a function/operator usingsuch types matches cases it really doesn't. A likely end resultof that is unexpected "ambiguous operator" errors, as for examplein bug #17387 from James Inform. Another, much older, case is thatthe parser might try to transform an "x IN (list)" construct toa ScalarArrayOpExpr even when the list elements don't actually havea common supertype.It doesn't seem desirable to add more checking to select_common_typeitself, as that'd just slow down the mainstream use-cases. Instead,write a separate function verify_common_type that performs themissing checks, and add a call to that where necessary. Likewise addverify_common_type_from_oids to go with select_common_type_from_oids.Back-patch to v13 where the "anycompatible" types came in. (Thesymptom complained of in bug #17387 doesn't appear till v14, butthat's just because we didn't get around to converting || to useanycompatible till then.) In principle the "x IN (list)" fix couldgo back all the way, but I'm not currently convinced that it makesmuch difference in real-world cases, so I won't bother for now.Discussion:https://postgr.es/m/17387-5dfe54b988444963@postgresql.org1 parent5ecd018 commit8e2e0f7
File tree
7 files changed
+131
-1
lines changed- src
- backend/parser
- include/parser
- test/regress
- expected
- sql
7 files changed
+131
-1
lines changedLines changed: 65 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1298 | 1298 |
| |
1299 | 1299 |
| |
1300 | 1300 |
| |
| 1301 | + | |
| 1302 | + | |
| 1303 | + | |
| 1304 | + | |
1301 | 1305 |
| |
1302 | 1306 |
| |
1303 | 1307 |
| |
| |||
1426 | 1430 |
| |
1427 | 1431 |
| |
1428 | 1432 |
| |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1429 | 1437 |
| |
1430 | 1438 |
| |
1431 | 1439 |
| |
| |||
1548 | 1556 |
| |
1549 | 1557 |
| |
1550 | 1558 |
| |
| 1559 | + | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
| 1589 | + | |
| 1590 | + | |
| 1591 | + | |
| 1592 | + | |
| 1593 | + | |
| 1594 | + | |
| 1595 | + | |
| 1596 | + | |
| 1597 | + | |
| 1598 | + | |
| 1599 | + | |
| 1600 | + | |
1551 | 1601 |
| |
1552 | 1602 |
| |
1553 | 1603 |
| |
| |||
1917 | 1967 |
| |
1918 | 1968 |
| |
1919 | 1969 |
| |
1920 |
| - | |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
1921 | 1977 |
| |
1922 | 1978 |
| |
1923 | 1979 |
| |
| |||
2494 | 2550 |
| |
2495 | 2551 |
| |
2496 | 2552 |
| |
| 2553 | + | |
| 2554 | + | |
| 2555 | + | |
| 2556 | + | |
| 2557 | + | |
| 2558 | + | |
| 2559 | + | |
| 2560 | + | |
2497 | 2561 |
| |
2498 | 2562 |
| |
2499 | 2563 |
| |
|
Lines changed: 5 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1121 | 1121 |
| |
1122 | 1122 |
| |
1123 | 1123 |
| |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
1124 | 1129 |
| |
1125 | 1130 |
| |
1126 | 1131 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| 73 | + | |
73 | 74 |
| |
74 | 75 |
| |
75 | 76 |
| |
|
Lines changed: 12 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
747 | 747 |
| |
748 | 748 |
| |
749 | 749 |
| |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
750 | 762 |
| |
751 | 763 |
| |
752 | 764 |
| |
|
Lines changed: 30 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
232 | 232 |
| |
233 | 233 |
| |
234 | 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 | + | |
235 | 265 |
| |
236 | 266 |
| |
237 | 267 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
317 | 317 |
| |
318 | 318 |
| |
319 | 319 |
| |
| 320 | + | |
| 321 | + | |
320 | 322 |
| |
321 | 323 |
| |
322 | 324 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
103 | 103 |
| |
104 | 104 |
| |
105 | 105 |
| |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
106 | 122 |
| |
107 | 123 |
| |
108 | 124 |
| |
|
0 commit comments
Comments
(0)