- Notifications
You must be signed in to change notification settings - Fork5k
Commiteec0040
committed
Add support for NOT ENFORCED in foreign key constraints
This expands the NOT ENFORCED constraint flag, previously onlysupported for CHECK constraints (commitca87c41), to foreign keyconstraints.Normally, when a foreign key constraint is created on a table, actionand check triggers are added to maintain data integrity. With thispatch, if a constraint is marked as NOT ENFORCED, integrity checks areno longer required, making these triggers unnecessary. Consequently,when creating a NOT ENFORCED foreign key constraint, triggers will notbe created, and the constraint will be marked as NOT VALID.Similarly, if an existing foreign key constraint is changed to NOTENFORCED, the associated triggers will be dropped, and the constraintwill also be marked as NOT VALID. Conversely, if a NOT ENFORCEDforeign key constraint is changed to ENFORCED, the necessary triggerswill be created, and the will be changed to VALID by performingnecessary validation.Since not-enforced foreign key constraints have no triggers, theshortcut used for example in psql and pg_dump to skip looking forforeign keys if the relation is known not to have triggers no longerapplies. (It already didn't work for partitioned tables.)Author: Amul Sul <sulamul@gmail.com>Reviewed-by: Joel Jacobson <joel@compiler.org>Reviewed-by: Andrew Dunstan <andrew@dunslane.net>Reviewed-by: Peter Eisentraut <peter@eisentraut.org>Reviewed-by: jian he <jian.universality@gmail.com>Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>Reviewed-by: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>Reviewed-by: Isaac Morland <isaac.morland@gmail.com>Reviewed-by: Alexandra Wang <alexandra.wang.oss@gmail.com>Tested-by: Triveni N <triveni.n@enterprisedb.com>Discussion:https://www.postgresql.org/message-id/flat/CAAJ_b962c5AcYW9KUt_R_ER5qs3fUGbe4az-SP-vuwPS-w-AGA@mail.gmail.com1 parent327d987 commiteec0040
File tree
19 files changed
+885
-274
lines changed- doc/src/sgml
- ref
- src
- backend
- catalog
- commands
- optimizer/util
- parser
- utils/cache
- bin
- pg_dump
- psql
- include
- nodes
- utils
- test/regress
- expected
- sql
19 files changed
+885
-274
lines changedLines changed: 0 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2620 | 2620 |
| |
2621 | 2621 |
| |
2622 | 2622 |
| |
2623 |
| - | |
2624 | 2623 |
| |
2625 | 2624 |
| |
2626 | 2625 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
58 | 58 |
| |
59 | 59 |
| |
60 | 60 |
| |
61 |
| - | |
| 61 | + | |
62 | 62 |
| |
63 | 63 |
| |
64 | 64 |
| |
| |||
589 | 589 |
| |
590 | 590 |
| |
591 | 591 |
| |
592 |
| - | |
| 592 | + | |
| 593 | + | |
593 | 594 |
| |
594 | 595 |
| |
595 | 596 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1409 | 1409 |
| |
1410 | 1410 |
| |
1411 | 1411 |
| |
1412 |
| - | |
| 1412 | + | |
1413 | 1413 |
| |
1414 | 1414 |
| |
1415 | 1415 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
100 | 100 |
| |
101 | 101 |
| |
102 | 102 |
| |
103 |
| - | |
104 |
| - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
105 | 106 |
| |
106 | 107 |
| |
107 | 108 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
281 | 281 |
| |
282 | 282 |
| |
283 | 283 |
| |
284 |
| - | |
| 284 | + | |
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
|
0 commit comments
Comments
(0)