- Notifications
You must be signed in to change notification settings - Fork4.9k
Commita90bdd7
committed
Refuse ATTACH of a table referenced by a foreign key
Trying to attach a table as a partition which is already on thereferenced side of a foreign key on the partitioned table that it isbeing attached to, leads to strange behavior: we try to clone theforeign key from the parent to the partition, but this new FK points tothe partition itself, and the mix of pg_constraint rows and triggersdoesn't behave well.Rather than trying to untangle the mess (which might be possible givensufficient time), I opted to forbid the ATTACH. This doesn't seem aproblematic restriction, given that we already fail to create theforeign key if you do it the other way around, that is, having thepartition first and the FK second.Backpatch to all supported branches.Reported-by: Alexander Lakhin <exclusion@gmail.com>Reviewed-by: Tender Wang <tndrwang@gmail.com>Discussion:https://postgr.es/m/18541-628a61bc267cd2d3@postgresql.org1 parent498ee9e commita90bdd7
File tree
3 files changed
+51
-0
lines changed- src
- backend/commands
- test/regress
- expected
- sql
3 files changed
+51
-0
lines changedLines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
10759 | 10759 |
| |
10760 | 10760 |
| |
10761 | 10761 |
| |
| 10762 | + | |
| 10763 | + | |
| 10764 | + | |
| 10765 | + | |
| 10766 | + | |
| 10767 | + | |
| 10768 | + | |
| 10769 | + | |
| 10770 | + | |
| 10771 | + | |
| 10772 | + | |
| 10773 | + | |
| 10774 | + | |
| 10775 | + | |
| 10776 | + | |
| 10777 | + | |
| 10778 | + | |
10762 | 10779 |
| |
10763 | 10780 |
| |
10764 | 10781 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1967 | 1967 |
| |
1968 | 1968 |
| |
1969 | 1969 |
| |
| 1970 | + | |
| 1971 | + | |
| 1972 | + | |
| 1973 | + | |
| 1974 | + | |
| 1975 | + | |
| 1976 | + | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + | |
| 1980 | + | |
| 1981 | + | |
| 1982 | + | |
| 1983 | + | |
| 1984 | + | |
| 1985 | + | |
| 1986 | + | |
1970 | 1987 |
| |
1971 | 1988 |
| |
1972 | 1989 |
| |
|
Lines changed: 17 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1417 | 1417 |
| |
1418 | 1418 |
| |
1419 | 1419 |
| |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
1420 | 1437 |
| |
1421 | 1438 |
| |
1422 | 1439 |
| |
|
0 commit comments
Comments
(0)