forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit84ac126
committed
Fix ON CONFLICT UPDATE bug breaking AFTER UPDATE triggers.
ExecOnConflictUpdate() passed t_ctid of the to-be-updated tuple toExecUpdate(). That's problematic primarily because of two reason: Firstand foremost t_ctid could point to a different tuple. Secondly, andthat's what triggered the complaint by Stanislav, t_ctid is changed byheap_update() to point to the new tuple version. The behavior of AFTERUPDATE triggers was therefore broken, with NEW.* and OLD.* tuplesspuriously identical within AFTER UPDATE triggers.To fix both issues, pass a pointer to t_self of a on-stack HeapTupleinstead.Fixing this bug lead to one change in regression tests, which previouslyfailed due to the first issue mentioned above. There's a reasonableexpectation that test fails, as it updates one row repeatedly within oneINSERT ... ON CONFLICT statement. That is only possible if the secondupdate is triggered via ON CONFLICT ... SET, ON CONFLICT ... WHERE, orby a WITH CHECK expression, as those are executed afterExecOnConflictUpdate() does a visibility check. That could easily beprohibited, but given it's allowed for plain UPDATEs and a rare cornercase, it doesn't seem worthwhile.Reported-By: Stanislav GrozevAuthor: Andres Freund and Peter GeogheganDiscussion: CAA78GVqy1+LisN-8DygekD_Ldfy=BJLarSpjGhytOsgkpMavfQ@mail.gmail.comBackpatch: 9.5, where ON CONFLICT was introduced1 parente3f4cfc commit84ac126
File tree
5 files changed
+25
-11
lines changed- src
- backend/executor
- test/regress
- expected
- sql
5 files changed
+25
-11
lines changedLines changed: 10 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1181 | 1181 |
| |
1182 | 1182 |
| |
1183 | 1183 |
| |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
1184 | 1193 |
| |
1185 |
| - | |
| 1194 | + | |
1186 | 1195 |
| |
1187 | 1196 |
| |
1188 | 1197 |
| |
|
Lines changed: 4 additions & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1703 | 1703 |
| |
1704 | 1704 |
| |
1705 | 1705 |
| |
1706 |
| - | |
| 1706 | + | |
1707 | 1707 |
| |
1708 | 1708 |
| |
1709 | 1709 |
| |
| |||
1724 | 1724 |
| |
1725 | 1725 |
| |
1726 | 1726 |
| |
1727 |
| - | |
| 1727 | + | |
1728 | 1728 |
| |
1729 | 1729 |
| |
1730 | 1730 |
| |
| |||
1734 | 1734 |
| |
1735 | 1735 |
| |
1736 | 1736 |
| |
1737 |
| - | |
| 1737 | + | |
1738 | 1738 |
| |
1739 | 1739 |
| |
1740 | 1740 |
| |
| |||
1744 | 1744 |
| |
1745 | 1745 |
| |
1746 | 1746 |
| |
1747 |
| - | |
| 1747 | + | |
1748 | 1748 |
| |
1749 | 1749 |
| |
1750 | 1750 |
| |
|
Lines changed: 7 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1875 | 1875 |
| |
1876 | 1876 |
| |
1877 | 1877 |
| |
1878 |
| - | |
1879 |
| - | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
1880 | 1881 |
| |
1881 | 1882 |
| |
1882 | 1883 |
| |
| |||
1886 | 1887 |
| |
1887 | 1888 |
| |
1888 | 1889 |
| |
1889 |
| - | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
1890 | 1894 |
| |
1891 | 1895 |
| |
1892 | 1896 |
| |
|
Lines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1215 | 1215 |
| |
1216 | 1216 |
| |
1217 | 1217 |
| |
1218 |
| - | |
| 1218 | + | |
1219 | 1219 |
| |
1220 | 1220 |
| |
1221 | 1221 |
| |
|
Lines changed: 3 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
838 | 838 |
| |
839 | 839 |
| |
840 | 840 |
| |
841 |
| - | |
842 |
| - | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
843 | 844 |
| |
844 | 845 |
| |
845 | 846 |
| |
|
0 commit comments
Comments
(0)