forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit743ddaf
committed
Ensure we preprocess expressions before checking their volatility.
contain_mutable_functions and contain_volatile_functions givereliable answers only after expression preprocessing (specificallyeval_const_expressions). Some places understand this, but some didnot get the memo --- which is not entirely their fault, because theproblem is documented only in places far away from those functions.Introduce wrapper functions that allow doing the right thing easily,and add commentary in hopes of preventing future mistakes fromcopy-and-paste of code that's only conditionally safe.Two actual bugs of this ilk are fixed here. We failed to preprocesscolumn GENERATED expressions before checking mutability, so that thecode could fail to detect the use of a volatile functiondefault-argument expression, or it could reject a polymorphic functionthat is actually immutable on the datatype of interest. Likewise,column DEFAULT expressions weren't preprocessed before determining ifit's safe to apply the attmissingval mechanism. A false negativewould just result in an unnecessary table rewrite, but a falsepositive could allow the attmissingval mechanism to be used in a casewhere it should not be, resulting in unexpected initial values in anew column.In passing, re-order the steps in ComputePartitionAttrs so that itschecks for invalid column references are done before applyingexpression_planner, rather than after. The previous coding wouldnot complain if a partition expression contains a disallowed columnreference that gets optimized away by constant folding, which seemsto me to be a behavior we do not want.Per bug #18097 from Jim Keener. Back-patch to all supported versions.Discussion:https://postgr.es/m/18097-ebb179674f22932f@postgresql.org1 parentbc15a12 commit743ddaf
File tree
10 files changed
+141
-56
lines changed- src
- backend
- catalog
- commands
- optimizer/util
- include/optimizer
- test/regress
- expected
- sql
10 files changed
+141
-56
lines changedLines changed: 5 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2365 | 2365 |
| |
2366 | 2366 |
| |
2367 | 2367 |
| |
2368 |
| - | |
| 2368 | + | |
| 2369 | + | |
2369 | 2370 |
| |
2370 | 2371 |
| |
2371 | 2372 |
| |
| |||
3087 | 3088 |
| |
3088 | 3089 |
| |
3089 | 3090 |
| |
| 3091 | + | |
3090 | 3092 |
| |
3091 | 3093 |
| |
3092 |
| - | |
| 3094 | + | |
| 3095 | + | |
3093 | 3096 |
| |
3094 | 3097 |
| |
3095 | 3098 |
| |
|
Lines changed: 5 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
887 | 887 |
| |
888 | 888 |
| |
889 | 889 |
| |
| 890 | + | |
| 891 | + | |
| 892 | + | |
890 | 893 |
| |
891 | 894 |
| |
892 | 895 |
| |
| |||
1616 | 1619 |
| |
1617 | 1620 |
| |
1618 | 1621 |
| |
1619 |
| - | |
| 1622 | + | |
| 1623 | + | |
1620 | 1624 |
| |
1621 | 1625 |
| |
1622 | 1626 |
| |
|
Lines changed: 2 additions & 29 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1791 | 1791 |
| |
1792 | 1792 |
| |
1793 | 1793 |
| |
1794 |
| - | |
1795 |
| - | |
1796 |
| - | |
1797 |
| - | |
1798 |
| - | |
1799 |
| - | |
1800 |
| - | |
1801 |
| - | |
1802 |
| - | |
1803 |
| - | |
1804 |
| - | |
1805 |
| - | |
1806 |
| - | |
1807 |
| - | |
1808 |
| - | |
1809 |
| - | |
1810 |
| - | |
1811 |
| - | |
1812 |
| - | |
1813 |
| - | |
1814 |
| - | |
1815 |
| - | |
1816 |
| - | |
1817 |
| - | |
1818 |
| - | |
1819 |
| - | |
1820 |
| - | |
1821 | 1794 |
| |
1822 | 1795 |
| |
1823 | 1796 |
| |
| |||
1841 | 1814 |
| |
1842 | 1815 |
| |
1843 | 1816 |
| |
1844 |
| - | |
| 1817 | + | |
1845 | 1818 |
| |
1846 | 1819 |
| |
1847 | 1820 |
| |
| |||
1985 | 1958 |
| |
1986 | 1959 |
| |
1987 | 1960 |
| |
1988 |
| - | |
| 1961 | + | |
1989 | 1962 |
| |
1990 | 1963 |
| |
1991 | 1964 |
| |
|
Lines changed: 26 additions & 24 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
18159 | 18159 |
| |
18160 | 18160 |
| |
18161 | 18161 |
| |
18162 |
| - | |
18163 |
| - | |
18164 |
| - | |
18165 |
| - | |
18166 |
| - | |
18167 |
| - | |
18168 |
| - | |
18169 |
| - | |
18170 |
| - | |
18171 |
| - | |
18172 |
| - | |
18173 |
| - | |
18174 |
| - | |
18175 |
| - | |
18176 |
| - | |
18177 |
| - | |
18178 |
| - | |
18179 |
| - | |
18180 |
| - | |
18181 |
| - | |
18182 |
| - | |
18183 |
| - | |
18184 |
| - | |
18185 |
| - | |
18186 | 18162 |
| |
18187 | 18163 |
| |
18188 | 18164 |
| |
| |||
18224 | 18200 |
| |
18225 | 18201 |
| |
18226 | 18202 |
| |
| 18203 | + | |
| 18204 | + | |
| 18205 | + | |
| 18206 | + | |
| 18207 | + | |
| 18208 | + | |
| 18209 | + | |
| 18210 | + | |
| 18211 | + | |
| 18212 | + | |
| 18213 | + | |
| 18214 | + | |
| 18215 | + | |
| 18216 | + | |
| 18217 | + | |
| 18218 | + | |
| 18219 | + | |
| 18220 | + | |
| 18221 | + | |
| 18222 | + | |
| 18223 | + | |
| 18224 | + | |
| 18225 | + | |
| 18226 | + | |
| 18227 | + | |
| 18228 | + | |
18227 | 18229 |
| |
18228 | 18230 |
| |
18229 | 18231 |
| |
|
Lines changed: 66 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
360 | 360 |
| |
361 | 361 |
| |
362 | 362 |
| |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
363 | 368 |
| |
364 | 369 |
| |
365 | 370 |
| |
| |||
446 | 451 |
| |
447 | 452 |
| |
448 | 453 |
| |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
449 | 482 |
| |
450 | 483 |
| |
451 | 484 |
| |
| |||
459 | 492 |
| |
460 | 493 |
| |
461 | 494 |
| |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
462 | 500 |
| |
463 | 501 |
| |
464 | 502 |
| |
| |||
582 | 620 |
| |
583 | 621 |
| |
584 | 622 |
| |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
585 | 651 |
| |
586 | 652 |
| |
587 | 653 |
| |
|
Lines changed: 2 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
138 | 138 |
| |
139 | 139 |
| |
140 | 140 |
| |
| 141 | + | |
141 | 142 |
| |
| 143 | + | |
142 | 144 |
| |
143 | 145 |
| |
144 | 146 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
272 | 272 |
| |
273 | 273 |
| |
274 | 274 |
| |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
275 | 292 |
| |
| 293 | + | |
276 | 294 |
| |
277 | 295 |
| |
278 | 296 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
61 | 61 |
| |
62 | 62 |
| |
63 | 63 |
| |
| 64 | + | |
| 65 | + | |
| 66 | + | |
64 | 67 |
| |
65 | 68 |
| |
66 | 69 |
| |
|
Lines changed: 11 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
256 | 256 |
| |
257 | 257 |
| |
258 | 258 |
| |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
259 | 269 |
| |
| 270 | + | |
260 | 271 |
| |
261 | 272 |
| |
262 | 273 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 |
| |
30 | 33 |
| |
31 | 34 |
| |
|
0 commit comments
Comments
(0)