forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit99be6fe
committed
Fix more bugs caused by adding columns to the end of a view.
If a view is defined atop another view, and then CREATE OR REPLACEVIEW is used to add columns to the lower view, then when the upperview's referencing RTE is expanded by ApplyRetrieveRule we will havea subquery RTE with fewer eref->colnames than output columns. Thisconfuses various code that assumes those lists are always in sync,as they are in plain parser output.We have seen such problems before (cf commitd5b760e), and nowI think the time has come to do what was speculated about in thatcommit: let's make ApplyRetrieveRule synthesize some column names topreserve the invariant that holds in parser output. Otherwise we'llbe chasing this class of bugs indefinitely. Moreover, it appears fromtesting that this actually gives us better results in the test cased5b760e added, and likely in other corner cases that we lackcoverage for.In HEAD, I replacedd5b760e's hack to make expandRTE exit early withan elog(ERROR) call, since the case is now presumably unreachable.But it seems like changing that in back branches would bring more riskthan benefit, so there I just updated the comment.Per bug #17811 from Alexander Lakhin. Back-patch to all supportedbranches.Discussion:https://postgr.es/m/17811-d31686b78f0dffc9@postgresql.org1 parentce1215d commit99be6fe
File tree
4 files changed
+77
-13
lines changed- src
- backend
- parser
- rewrite
- test/regress
- expected
- sql
4 files changed
+77
-13
lines changedLines changed: 8 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2697 | 2697 |
| |
2698 | 2698 |
| |
2699 | 2699 |
| |
2700 |
| - | |
2701 |
| - | |
2702 |
| - | |
2703 |
| - | |
2704 |
| - | |
2705 |
| - | |
| 2700 | + | |
| 2701 | + | |
| 2702 | + | |
| 2703 | + | |
| 2704 | + | |
| 2705 | + | |
2706 | 2706 |
| |
2707 | 2707 |
| |
2708 |
| - | |
| 2708 | + | |
| 2709 | + | |
2709 | 2710 |
| |
2710 | 2711 |
| |
2711 | 2712 |
| |
|
Lines changed: 16 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
29 | 30 |
| |
30 | 31 |
| |
31 | 32 |
| |
| |||
1730 | 1731 |
| |
1731 | 1732 |
| |
1732 | 1733 |
| |
| 1734 | + | |
1733 | 1735 |
| |
1734 | 1736 |
| |
1735 | 1737 |
| |
| |||
1855 | 1857 |
| |
1856 | 1858 |
| |
1857 | 1859 |
| |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
1858 | 1874 |
| |
1859 | 1875 |
| |
1860 | 1876 |
| |
|
Lines changed: 35 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2551 | 2551 |
| |
2552 | 2552 |
| |
2553 | 2553 |
| |
2554 |
| - | |
2555 |
| - | |
| 2554 | + | |
| 2555 | + | |
2556 | 2556 |
| |
2557 |
| - | |
| 2557 | + | |
2558 | 2558 |
| |
2559 | 2559 |
| |
2560 | 2560 |
| |
2561 |
| - | |
2562 |
| - | |
2563 |
| - | |
| 2561 | + | |
| 2562 | + | |
| 2563 | + | |
2564 | 2564 |
| |
2565 | 2565 |
| |
2566 | 2566 |
| |
2567 | 2567 |
| |
2568 | 2568 |
| |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
2569 | 2598 |
| |
2570 | 2599 |
| |
2571 | 2600 |
| |
|
Lines changed: 18 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1635 | 1635 |
| |
1636 | 1636 |
| |
1637 | 1637 |
| |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
1638 | 1656 |
| |
1639 | 1657 |
| |
1640 | 1658 |
| |
|
0 commit comments
Comments
(0)