- Notifications
You must be signed in to change notification settings - Fork4.9k
Commit5e6e97f
committed
Repair misbehavior with duplicate entries in FK SET column lists.
Since v15 we've had an option to apply a foreign key constraint'sON DELETE SET DEFAULT or SET NULL action to just some of thereferencing columns. There was not a check for duplicate entries inthe list of columns-to-set, though. That caused a potential memorystomp in CreateConstraintEntry(), which incautiously assumed thatthe list of columns-to-set couldn't be longer than the number of keycolumns. Even after fixing that, the case doesn't work because youget an error like "multiple assignments to same column" from the SQLcommand that is generated to do the update.We could either raise an error for duplicate columns or silentlysuppress the dups, and after a bit of thought I chose to do thelatter. This is motivated by the fact that duplicates in the FKcolumn list are legal, so it's not real clear why duplicatesin the columns-to-set list shouldn't be. Of course there's noneed to actually set the column more than once.I left in the fix in CreateConstraintEntry() too, just becauseit didn't seem like such low-level code ought to be makingassumptions about what it's handed.Bug: #18879Reported-by: Yu Liang <luy70@psu.edu>Author: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/18879-259fc59d072bd4d7@postgresql.orgBackpatch-through: 151 parent6526d07 commit5e6e97f
File tree
4 files changed
+34
-10
lines changed- src
- backend
- catalog
- commands
- test/regress
- expected
- sql
4 files changed
+34
-10
lines changedLines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
| 121 | + | |
121 | 122 |
| |
122 |
| - | |
| 123 | + | |
123 | 124 |
| |
124 | 125 |
| |
125 | 126 |
| |
|
Lines changed: 28 additions & 7 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
512 | 512 |
| |
513 | 513 |
| |
514 | 514 |
| |
515 |
| - | |
516 |
| - | |
| 515 | + | |
| 516 | + | |
517 | 517 |
| |
518 | 518 |
| |
519 | 519 |
| |
| |||
9716 | 9716 |
| |
9717 | 9717 |
| |
9718 | 9718 |
| |
9719 |
| - | |
9720 |
| - | |
9721 |
| - | |
| 9719 | + | |
| 9720 | + | |
| 9721 | + | |
| 9722 | + | |
9722 | 9723 |
| |
9723 | 9724 |
| |
9724 | 9725 |
| |
| |||
10039 | 10040 |
| |
10040 | 10041 |
| |
10041 | 10042 |
| |
| 10043 | + | |
| 10044 | + | |
| 10045 | + | |
10042 | 10046 |
| |
10043 |
| - | |
| 10047 | + | |
10044 | 10048 |
| |
10045 |
| - | |
| 10049 | + | |
10046 | 10050 |
| |
10047 | 10051 |
| |
| 10052 | + | |
| 10053 | + | |
10048 | 10054 |
| |
10049 | 10055 |
| |
10050 | 10056 |
| |
10051 | 10057 |
| |
10052 | 10058 |
| |
| 10059 | + | |
10053 | 10060 |
| |
10054 | 10061 |
| |
10055 | 10062 |
| |
| |||
10067 | 10074 |
| |
10068 | 10075 |
| |
10069 | 10076 |
| |
| 10077 | + | |
| 10078 | + | |
| 10079 | + | |
| 10080 | + | |
| 10081 | + | |
| 10082 | + | |
| 10083 | + | |
| 10084 | + | |
| 10085 | + | |
| 10086 | + | |
| 10087 | + | |
| 10088 | + | |
| 10089 | + | |
10070 | 10090 |
| |
| 10091 | + | |
10071 | 10092 |
| |
10072 | 10093 |
| |
10073 | 10094 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
772 | 772 |
| |
773 | 773 |
| |
774 | 774 |
| |
775 |
| - | |
| 775 | + | |
| 776 | + | |
776 | 777 |
| |
777 | 778 |
| |
778 | 779 |
| |
|
Lines changed: 2 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
473 | 473 |
| |
474 | 474 |
| |
475 | 475 |
| |
476 |
| - | |
| 476 | + | |
| 477 | + | |
477 | 478 |
| |
478 | 479 |
| |
479 | 480 |
| |
|
0 commit comments
Comments
(0)