Commit 749fb12
Create FKs properly when attaching table as partition
Commit f56f8f8 added some code in CloneFkReferencing that's way too
lax about a Constraint node it manufactures, not initializing enough
struct members -- initially_valid in particular was forgotten. This
causes some FKs in partitions added by ALTER TABLE ATTACH PARTITION to
be marked as not validated. Set initially_valid true, which fixes the
bug.
While at it, make the struct initialization more complete. Very similar
code was added in two other places by the same commit; make them all
follow the same pattern for consistency, though no bugs are apparent
there.
This bug has never been reported: I only happened to notice while
working on commit 614a406. The test case that was added there with
the improper result is repaired.
Backpatch to 12.
Discussion: https://postgr.es/m/20221005105523.bhuhkdx4olajboof@alvherre.pgsql1 parent b90e568 commit 749fb12
2 files changed
Lines changed: 37 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11951 | 11951 | | |
11952 | 11952 | | |
11953 | 11953 | | |
11954 | | - | |
| 11954 | + | |
11955 | 11955 | | |
11956 | | - | |
11957 | | - | |
11958 | 11956 | | |
11959 | 11957 | | |
11960 | | - | |
| 11958 | + | |
| 11959 | + | |
| 11960 | + | |
| 11961 | + | |
11961 | 11962 | | |
| 11963 | + | |
| 11964 | + | |
| 11965 | + | |
| 11966 | + | |
| 11967 | + | |
| 11968 | + | |
11962 | 11969 | | |
11963 | 11970 | | |
11964 | 11971 | | |
| |||
12130 | 12137 | | |
12131 | 12138 | | |
12132 | 12139 | | |
12133 | | - | |
12134 | | - | |
| 12140 | + | |
| 12141 | + | |
12135 | 12142 | | |
12136 | 12143 | | |
| 12144 | + | |
| 12145 | + | |
| 12146 | + | |
| 12147 | + | |
12137 | 12148 | | |
| 12149 | + | |
| 12150 | + | |
| 12151 | + | |
| 12152 | + | |
| 12153 | + | |
| 12154 | + | |
12138 | 12155 | | |
12139 | 12156 | | |
12140 | 12157 | | |
| |||
22433 | 22450 | | |
22434 | 22451 | | |
22435 | 22452 | | |
| 22453 | + | |
22436 | 22454 | | |
22437 | | - | |
22438 | | - | |
22439 | 22455 | | |
22440 | 22456 | | |
| 22457 | + | |
| 22458 | + | |
| 22459 | + | |
| 22460 | + | |
| 22461 | + | |
| 22462 | + | |
| 22463 | + | |
| 22464 | + | |
| 22465 | + | |
| 22466 | + | |
| 22467 | + | |
22441 | 22468 | | |
22442 | 22469 | | |
22443 | 22470 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1966 | 1966 | | |
1967 | 1967 | | |
1968 | 1968 | | |
1969 | | - | |
| 1969 | + | |
1970 | 1970 | | |
1971 | 1971 | | |
1972 | 1972 | | |
| |||
1995 | 1995 | | |
1996 | 1996 | | |
1997 | 1997 | | |
1998 | | - | |
| 1998 | + | |
1999 | 1999 | | |
2000 | 2000 | | |
2001 | 2001 | | |
| |||
0 commit comments