- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit705d433
committed
Revise attribute handling code on partition creation
The original code to propagate NOT NULL and default expressionsspecified when creating a partition was mostly copy-pasted fromtyped-tables creation, but not being a great match it contained someduplicity, inefficiency and bugs.This commit fixes the bug that NOT NULL constraints declared in theparent table would not be honored in the partition. One reported issuethat is not fixed is that a DEFAULT declared in the child is not usedwhen inserting through the parent. That would amount to a behavioralchange that's better not back-patched.This rewrite makes the code simpler:1. instead of checking for duplicate column names in its own block,reuse the original one that already did that;2. instead of concatenating the list of columns from parent and the onedeclared in the partition and scanning the result to (incorrectly)propagate defaults and not-null constraints, just scan the lattersearching the former for a match, and merging sensibly. This worksbecause we know the list in the parent is already correct and there canonly be one parent.This rewrite makes ColumnDef->is_from_parent unused, so it's removedon branch master; on released branches, it's kept as an unused field inorder not to cause ABI incompatibilities.This commit also adds a test case for creating partitions withcollations mismatching that on the parent table, something that isclosely related to the code being patched. No code change is introducedthough, since that'd be a behavior change that could break some (broken)working applications.Amit Langote wrote a less invasive fix for the originalNOT NULL/defaults bug, but while I kept the tests he added, I ended upnot using his original code. Ashutosh Bapat reviewed Amit's fix. Amitreviewed mine.Author: Álvaro Herrera, Amit LangoteReviewed-by: Ashutosh Bapat, Amit LangoteReported-by: Jürgen Strobel (bug #15212)Discussion:https://postgr.es/m/152746742177.1291.9847032632907407358@wrigleys.postgresql.org1 parent12d5f39 commit705d433
File tree
11 files changed
+91
-65
lines changed- src
- backend
- commands
- nodes
- parser
- include/nodes
- test/regress
- expected
- sql
11 files changed
+91
-65
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
172 | 172 |
| |
173 | 173 |
| |
174 | 174 |
| |
175 |
| - | |
176 | 175 |
| |
177 | 176 |
| |
178 | 177 |
| |
|
Lines changed: 46 additions & 53 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1892 | 1892 |
| |
1893 | 1893 |
| |
1894 | 1894 |
| |
1895 |
| - | |
1896 |
| - | |
1897 |
| - | |
1898 |
| - | |
1899 |
| - | |
1900 |
| - | |
1901 |
| - | |
1902 |
| - | |
1903 |
| - | |
1904 |
| - | |
1905 |
| - | |
1906 | 1895 |
| |
1907 | 1896 |
| |
1908 | 1897 |
| |
| |||
1916 | 1905 |
| |
1917 | 1906 |
| |
1918 | 1907 |
| |
1919 |
| - | |
1920 |
| - | |
| 1908 | + | |
| 1909 | + | |
1921 | 1910 |
| |
1922 | 1911 |
| |
1923 | 1912 |
| |
1924 |
| - | |
| 1913 | + | |
| 1914 | + | |
1925 | 1915 |
| |
1926 | 1916 |
| |
1927 | 1917 |
| |
1928 | 1918 |
| |
1929 | 1919 |
| |
| 1920 | + | |
1930 | 1921 |
| |
1931 | 1922 |
| |
1932 | 1923 |
| |
| |||
1959 | 1950 |
| |
1960 | 1951 |
| |
1961 | 1952 |
| |
| 1953 | + | |
| 1954 | + | |
| 1955 | + | |
| 1956 | + | |
| 1957 | + | |
| 1958 | + | |
| 1959 | + | |
| 1960 | + | |
| 1961 | + | |
| 1962 | + | |
| 1963 | + | |
1962 | 1964 |
| |
1963 | 1965 |
| |
1964 | 1966 |
| |
| |||
2175 | 2177 |
| |
2176 | 2178 |
| |
2177 | 2179 |
| |
2178 |
| - | |
2179 | 2180 |
| |
2180 | 2181 |
| |
2181 | 2182 |
| |
| |||
2428 | 2429 |
| |
2429 | 2430 |
| |
2430 | 2431 |
| |
2431 |
| - | |
2432 |
| - | |
| 2432 | + | |
| 2433 | + | |
2433 | 2434 |
| |
2434 |
| - | |
| 2435 | + | |
2435 | 2436 |
| |
2436 |
| - | |
2437 |
| - | |
2438 |
| - | |
| 2437 | + | |
2439 | 2438 |
| |
2440 |
| - | |
2441 |
| - | |
2442 |
| - | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
2443 | 2442 |
| |
2444 |
| - | |
2445 |
| - | |
2446 |
| - | |
2447 |
| - | |
2448 |
| - | |
2449 |
| - | |
2450 |
| - | |
2451 |
| - | |
2452 |
| - | |
2453 |
| - | |
2454 |
| - | |
| 2443 | + | |
2455 | 2444 |
| |
2456 |
| - | |
2457 |
| - | |
2458 |
| - | |
| 2445 | + | |
2459 | 2446 |
| |
2460 | 2447 |
| |
2461 | 2448 |
| |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
2462 | 2452 |
| |
2463 |
| - | |
2464 |
| - | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
2465 | 2460 |
| |
2466 |
| - | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
2467 | 2464 |
| |
2468 |
| - | |
2469 | 2465 |
| |
2470 |
| - | |
2471 |
| - | |
2472 |
| - | |
2473 |
| - | |
| 2466 | + | |
2474 | 2467 |
| |
2475 |
| - | |
2476 |
| - | |
2477 |
| - | |
2478 |
| - | |
2479 |
| - | |
2480 | 2468 |
| |
2481 |
| - | |
2482 |
| - | |
2483 | 2469 |
| |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
2484 | 2477 |
| |
2485 | 2478 |
| |
2486 | 2479 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2873 | 2873 |
| |
2874 | 2874 |
| |
2875 | 2875 |
| |
2876 |
| - | |
2877 | 2876 |
| |
2878 | 2877 |
| |
2879 | 2878 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2553 | 2553 |
| |
2554 | 2554 |
| |
2555 | 2555 |
| |
2556 |
| - | |
2557 | 2556 |
| |
2558 | 2557 |
| |
2559 | 2558 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
496 | 496 |
| |
497 | 497 |
| |
498 | 498 |
| |
499 |
| - | |
500 | 499 |
| |
501 | 500 |
| |
502 | 501 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2874 | 2874 |
| |
2875 | 2875 |
| |
2876 | 2876 |
| |
2877 |
| - | |
2878 | 2877 |
| |
2879 | 2878 |
| |
2880 | 2879 |
| |
|
Lines changed: 0 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3388 | 3388 |
| |
3389 | 3389 |
| |
3390 | 3390 |
| |
3391 |
| - | |
3392 | 3391 |
| |
3393 | 3392 |
| |
3394 | 3393 |
| |
| |||
3410 | 3409 |
| |
3411 | 3410 |
| |
3412 | 3411 |
| |
3413 |
| - | |
3414 | 3412 |
| |
3415 | 3413 |
| |
3416 | 3414 |
| |
| |||
3429 | 3427 |
| |
3430 | 3428 |
| |
3431 | 3429 |
| |
3432 |
| - | |
3433 | 3430 |
| |
3434 | 3431 |
| |
3435 | 3432 |
| |
| |||
12267 | 12264 |
| |
12268 | 12265 |
| |
12269 | 12266 |
| |
12270 |
| - | |
12271 | 12267 |
| |
12272 | 12268 |
| |
12273 | 12269 |
| |
|
Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
988 | 988 |
| |
989 | 989 |
| |
990 | 990 |
| |
991 |
| - | |
992 | 991 |
| |
993 | 992 |
| |
994 | 993 |
| |
| |||
1265 | 1264 |
| |
1266 | 1265 |
| |
1267 | 1266 |
| |
1268 |
| - | |
1269 | 1267 |
| |
1270 | 1268 |
| |
1271 | 1269 |
| |
|
Lines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
649 | 649 |
| |
650 | 650 |
| |
651 | 651 |
| |
652 |
| - | |
653 | 652 |
| |
654 | 653 |
| |
655 | 654 |
| |
|
Lines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
728 | 728 |
| |
729 | 729 |
| |
730 | 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 | + | |
731 | 757 |
| |
732 | 758 |
| |
733 | 759 |
| |
|
Lines changed: 19 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
654 | 654 |
| |
655 | 655 |
| |
656 | 656 |
| |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
657 | 676 |
| |
658 | 677 |
| |
659 | 678 |
| |
|
0 commit comments
Comments
(0)