- Notifications
You must be signed in to change notification settings - Fork5
Commit541ffa6
committed
Prevent CREATE TABLE LIKE/INHERITS from (mis) copying whole-row Vars.
If a CHECK constraint or index definition contained a whole-row Var (thatis, "table.*"), an attempt to copy that definition via CREATE TABLE LIKE ortable inheritance produced incorrect results: the copied Var still claimedto have the rowtype of the source table, rather than the created table.For the LIKE case, it seems reasonable to just throw error for thissituation, since the point of LIKE is that the new table is not permanentlycoupled to the old, so there's no reason to assume its rowtype will staycompatible. In the inheritance case, we should ideally allow suchconstraints, but doing so will require nontrivial refactoring of CREATETABLE processing (because we'd need to know the OID of the new table'srowtype before we adjust inherited CHECK constraints). In view of the lackof previous complaints, that doesn't seem worth the risk in a back-patchedbug fix, so just make it throw error for the inheritance case as well.Along the way, replace change_varattnos_of_a_node() with a more robustfunction map_variable_attnos(), which is capable of being extended tohandle insertion of ConvertRowtypeExpr whenever we get around to fixingthe inheritance case nicely, and in the meantime it returns a failureindication to the caller so that a helpful message with some context can bethrown. Also, this code will do the right thing with subselects (if weever allow them in CHECK or indexes), and it range-checks varattnos beforeusing them to index into the map array.Per report from Sergey Konoplev. Back-patch to all supported branches.1 parente4ffa86 commit541ffa6
File tree
5 files changed
+215
-132
lines changed- src
- backend
- commands
- parser
- rewrite
- include
- commands
- rewrite
5 files changed
+215
-132
lines changedLines changed: 22 additions & 109 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
68 | 68 |
| |
69 | 69 |
| |
70 | 70 |
| |
| 71 | + | |
71 | 72 |
| |
72 | 73 |
| |
73 | 74 |
| |
| |||
253 | 254 |
| |
254 | 255 |
| |
255 | 256 |
| |
256 |
| - | |
257 | 257 |
| |
258 | 258 |
| |
259 | 259 |
| |
| |||
1496 | 1496 |
| |
1497 | 1497 |
| |
1498 | 1498 |
| |
1499 |
| - | |
| 1499 | + | |
1500 | 1500 |
| |
1501 | 1501 |
| |
1502 | 1502 |
| |
| |||
1510 | 1510 |
| |
1511 | 1511 |
| |
1512 | 1512 |
| |
1513 |
| - | |
1514 |
| - | |
1515 |
| - | |
1516 |
| - | |
1517 |
| - | |
1518 |
| - | |
1519 |
| - | |
1520 |
| - | |
1521 |
| - | |
| 1513 | + | |
1522 | 1514 |
| |
1523 | 1515 |
| |
1524 | 1516 |
| |
| |||
1656 | 1648 |
| |
1657 | 1649 |
| |
1658 | 1650 |
| |
| 1651 | + | |
1659 | 1652 |
| |
1660 | 1653 |
| |
1661 | 1654 |
| |
1662 | 1655 |
| |
1663 | 1656 |
| |
1664 |
| - | |
1665 |
| - | |
1666 |
| - | |
| 1657 | + | |
| 1658 | + | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
| 1662 | + | |
| 1663 | + | |
| 1664 | + | |
| 1665 | + | |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 1674 | + | |
1667 | 1675 |
| |
1668 | 1676 |
| |
1669 | 1677 |
| |
| |||
1866 | 1874 |
| |
1867 | 1875 |
| |
1868 | 1876 |
| |
1869 |
| - | |
1870 |
| - | |
1871 |
| - | |
1872 |
| - | |
1873 |
| - | |
1874 |
| - | |
1875 |
| - | |
1876 |
| - | |
1877 |
| - | |
1878 |
| - | |
1879 |
| - | |
1880 |
| - | |
1881 |
| - | |
1882 |
| - | |
1883 |
| - | |
1884 |
| - | |
1885 |
| - | |
1886 |
| - | |
1887 |
| - | |
1888 |
| - | |
1889 |
| - | |
1890 |
| - | |
1891 |
| - | |
1892 |
| - | |
1893 |
| - | |
1894 |
| - | |
1895 |
| - | |
1896 |
| - | |
1897 |
| - | |
1898 |
| - | |
1899 |
| - | |
1900 |
| - | |
1901 |
| - | |
1902 |
| - | |
1903 |
| - | |
1904 |
| - | |
1905 |
| - | |
1906 |
| - | |
1907 |
| - | |
1908 |
| - | |
1909 |
| - | |
1910 |
| - | |
1911 |
| - | |
1912 |
| - | |
1913 |
| - | |
1914 |
| - | |
1915 |
| - | |
1916 |
| - | |
1917 |
| - | |
1918 |
| - | |
1919 |
| - | |
1920 |
| - | |
1921 |
| - | |
1922 |
| - | |
1923 |
| - | |
1924 |
| - | |
1925 |
| - | |
1926 |
| - | |
1927 |
| - | |
1928 |
| - | |
1929 |
| - | |
1930 |
| - | |
1931 |
| - | |
1932 |
| - | |
1933 |
| - | |
1934 |
| - | |
1935 |
| - | |
1936 |
| - | |
1937 |
| - | |
1938 |
| - | |
1939 |
| - | |
1940 |
| - | |
1941 |
| - | |
1942 |
| - | |
1943 |
| - | |
1944 |
| - | |
1945 |
| - | |
1946 |
| - | |
1947 |
| - | |
1948 |
| - | |
1949 |
| - | |
1950 |
| - | |
1951 |
| - | |
1952 |
| - | |
1953 |
| - | |
1954 |
| - | |
1955 |
| - | |
1956 |
| - | |
1957 |
| - | |
1958 |
| - | |
1959 |
| - | |
1960 |
| - | |
1961 |
| - | |
1962 |
| - | |
1963 |
| - | |
1964 | 1877 |
| |
1965 | 1878 |
| |
1966 | 1879 |
| |
|
Lines changed: 75 additions & 19 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
108 | 108 |
| |
109 | 109 |
| |
110 | 110 |
| |
111 |
| - | |
| 111 | + | |
| 112 | + | |
112 | 113 |
| |
113 | 114 |
| |
114 | 115 |
| |
| |||
634 | 635 |
| |
635 | 636 |
| |
636 | 637 |
| |
| 638 | + | |
637 | 639 |
| |
638 | 640 |
| |
639 | 641 |
| |
| |||
642 | 644 |
| |
643 | 645 |
| |
644 | 646 |
| |
645 |
| - | |
646 |
| - | |
647 |
| - | |
648 |
| - | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
649 | 651 |
| |
650 | 652 |
| |
651 | 653 |
| |
652 |
| - | |
| 654 | + | |
653 | 655 |
| |
654 | 656 |
| |
655 | 657 |
| |
| |||
676 | 678 |
| |
677 | 679 |
| |
678 | 680 |
| |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
679 | 688 |
| |
680 | 689 |
| |
681 | 690 |
| |
| |||
687 | 696 |
| |
688 | 697 |
| |
689 | 698 |
| |
690 |
| - | |
| 699 | + | |
691 | 700 |
| |
692 | 701 |
| |
693 | 702 |
| |
| |||
718 | 727 |
| |
719 | 728 |
| |
720 | 729 |
| |
| 730 | + | |
| 731 | + | |
721 | 732 |
| |
722 | 733 |
| |
723 | 734 |
| |
| |||
776 | 787 |
| |
777 | 788 |
| |
778 | 789 |
| |
779 |
| - | |
| 790 | + | |
780 | 791 |
| |
781 | 792 |
| |
782 | 793 |
| |
783 | 794 |
| |
784 |
| - | |
785 | 795 |
| |
786 | 796 |
| |
787 | 797 |
| |
788 | 798 |
| |
789 | 799 |
| |
790 | 800 |
| |
791 |
| - | |
792 | 801 |
| |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
793 | 809 |
| |
794 |
| - | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
795 | 823 |
| |
796 | 824 |
| |
797 | 825 |
| |
| |||
827 | 855 |
| |
828 | 856 |
| |
829 | 857 |
| |
830 |
| - | |
831 | 858 |
| |
832 | 859 |
| |
833 | 860 |
| |
| |||
842 | 869 |
| |
843 | 870 |
| |
844 | 871 |
| |
845 |
| - | |
| 872 | + | |
| 873 | + | |
846 | 874 |
| |
847 | 875 |
| |
848 | 876 |
| |
| |||
961 | 989 |
| |
962 | 990 |
| |
963 | 991 |
| |
964 |
| - | |
| 992 | + | |
965 | 993 |
| |
966 | 994 |
| |
967 | 995 |
| |
| |||
1149 | 1177 |
| |
1150 | 1178 |
| |
1151 | 1179 |
| |
| 1180 | + | |
1152 | 1181 |
| |
1153 | 1182 |
| |
1154 | 1183 |
| |
1155 | 1184 |
| |
1156 | 1185 |
| |
1157 | 1186 |
| |
1158 |
| - | |
1159 |
| - | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1160 | 1200 |
| |
1161 | 1201 |
| |
1162 | 1202 |
| |
| |||
1213 | 1253 |
| |
1214 | 1254 |
| |
1215 | 1255 |
| |
| 1256 | + | |
| 1257 | + | |
1216 | 1258 |
| |
1217 | 1259 |
| |
1218 | 1260 |
| |
1219 |
| - | |
1220 |
| - | |
1221 |
| - | |
| 1261 | + | |
| 1262 | + | |
| 1263 | + | |
| 1264 | + | |
| 1265 | + | |
| 1266 | + | |
| 1267 | + | |
| 1268 | + | |
| 1269 | + | |
| 1270 | + | |
| 1271 | + | |
| 1272 | + | |
| 1273 | + | |
| 1274 | + | |
| 1275 | + | |
| 1276 | + | |
| 1277 | + | |
1222 | 1278 |
| |
1223 | 1279 |
| |
1224 | 1280 |
| |
|
0 commit comments
Comments
(0)