- Notifications
You must be signed in to change notification settings - Fork5
Commit11e1318
committed
Improve ruleutils.c's heuristics for dealing with rangetable aliases.
The previous scheme had bugs in some corner cases involving tables that hadbeen renamed since a view was made. This could result in dumped views thatfailed to reload or reloaded incorrectly, as seen in bug #7553 from LloydAlbin, as well as in some pgsql-hackers discussion back in January. Also,its behavior for printing EXPLAIN plans was sometimes confusing because ofwillingness to use the same alias for multiple RTEs (it was AshutoshBapat's complaint about that aspect that started the January thread).To fix, ensure that each RTE in the query has a unique unqualified alias,by modifying the alias if necessary (we add "_" and digits as needed tocreate a non-conflicting name). Then we can just print its variables withthat alias, avoiding the confusing and bug-prone scheme of sometimesschema-qualifying variable names. In EXPLAIN, it proves to be expedient totake the further step of only assigning such aliases to RTEs that areactually referenced in the query, since the planner has a habit ofgenerating extra RTEs with the same alias in situations such asinheritance-tree expansion.Although this fixes a bug of very long standing, I'm hesitant to back-patchsuch a noticeable behavioral change. My experiments while creating aregression test convinced me that actually incorrect output (as opposed toconfusing output) occurs only in very narrow cases, which is backed up bythe lack of previous complaints from the field. So we may be better offliving with it in released branches; and in any case it'd be smart to letthis ripen awhile in HEAD before we consider back-patching it.1 parent7c45e3a commit11e1318
File tree
12 files changed
+886
-226
lines changed- src
- backend
- commands
- utils/adt
- include
- commands
- utils
- test/regress
- expected
- sql
12 files changed
+886
-226
lines changedLines changed: 147 additions & 8 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
51 | 51 |
| |
52 | 52 |
| |
53 | 53 |
| |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
54 | 58 |
| |
55 | 59 |
| |
56 | 60 |
| |
| |||
539 | 543 |
| |
540 | 544 |
| |
541 | 545 |
| |
| 546 | + | |
| 547 | + | |
542 | 548 |
| |
543 | 549 |
| |
544 | 550 |
| |
| 551 | + | |
| 552 | + | |
545 | 553 |
| |
546 | 554 |
| |
547 | 555 |
| |
| |||
640 | 648 |
| |
641 | 649 |
| |
642 | 650 |
| |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
643 | 777 |
| |
644 | 778 |
| |
645 | 779 |
| |
| |||
1440 | 1574 |
| |
1441 | 1575 |
| |
1442 | 1576 |
| |
1443 |
| - | |
| 1577 | + | |
| 1578 | + | |
1444 | 1579 |
| |
1445 | 1580 |
| |
1446 | 1581 |
| |
| |||
1471 | 1606 |
| |
1472 | 1607 |
| |
1473 | 1608 |
| |
1474 |
| - | |
| 1609 | + | |
| 1610 | + | |
1475 | 1611 |
| |
1476 | 1612 |
| |
1477 | 1613 |
| |
| |||
1573 | 1709 |
| |
1574 | 1710 |
| |
1575 | 1711 |
| |
1576 |
| - | |
| 1712 | + | |
| 1713 | + | |
1577 | 1714 |
| |
1578 | 1715 |
| |
1579 | 1716 |
| |
| |||
1813 | 1950 |
| |
1814 | 1951 |
| |
1815 | 1952 |
| |
| 1953 | + | |
1816 | 1954 |
| |
1817 | 1955 |
| |
| 1956 | + | |
1818 | 1957 |
| |
1819 | 1958 |
| |
1820 | 1959 |
| |
| |||
1887 | 2026 |
| |
1888 | 2027 |
| |
1889 | 2028 |
| |
1890 |
| - | |
1891 |
| - | |
1892 |
| - | |
1893 |
| - | |
| 2029 | + | |
| 2030 | + | |
| 2031 | + | |
1894 | 2032 |
| |
1895 | 2033 |
| |
1896 | 2034 |
| |
1897 | 2035 |
| |
1898 | 2036 |
| |
1899 | 2037 |
| |
1900 | 2038 |
| |
1901 |
| - | |
| 2039 | + | |
| 2040 | + | |
1902 | 2041 |
| |
1903 | 2042 |
| |
1904 | 2043 |
| |
|
0 commit comments
Comments
(0)