forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit1ffa59a
committed
Fix optimization of foreign-key on update actions
In RI_FKey_pk_upd_check_required(), we check among other thingswhether the old and new key are equal, so that we don't need to runcascade actions when nothing has actually changed. This was using theequality operator. But the effect of this is that if a value in theprimary key is changed to one that "looks" different but compares asequal, the update is not propagated. (Examples are float -0 and 0 andcase-insensitive text.) This appears to violate the SQL standard, andit also behaves inconsistently if in a multicolumn key another key isalso updated that would cause the row to compare as not equal.To fix, if we are looking at the PK table in ri_KeysEqual(), then do abytewise comparison similar to record_image_eq() instead of using theequality operators. This only makes a difference for ON UPDATECASCADE, but for consistency we treat all changes to the PK the same. Forthe FK table, we continue to use the equality operators.Discussion:https://www.postgresql.org/message-id/flat/3326fc2e-bc02-d4c5-e3e5-e54da466e89a@2ndquadrant.com1 parentfb58065 commit1ffa59a
File tree
6 files changed
+149
-52
lines changed- src
- backend/utils/adt
- include/utils
- test/regress
- expected
- sql
6 files changed
+149
-52
lines changedLines changed: 57 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
| 45 | + | |
| 46 | + | |
45 | 47 |
| |
46 | 48 |
| |
47 | 49 |
| |
| |||
251 | 253 |
| |
252 | 254 |
| |
253 | 255 |
| |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
254 | 311 |
| |
255 | 312 |
| |
256 | 313 |
| |
|
Lines changed: 27 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
| 45 | + | |
45 | 46 |
| |
46 | 47 |
| |
47 | 48 |
| |
| |||
2402 | 2403 |
| |
2403 | 2404 |
| |
2404 | 2405 |
| |
2405 |
| - | |
2406 | 2406 |
| |
2407 | 2407 |
| |
2408 |
| - | |
2409 | 2408 |
| |
2410 |
| - | |
2411 |
| - | |
2412 | 2409 |
| |
2413 |
| - | |
2414 | 2410 |
| |
2415 |
| - | |
2416 |
| - | |
2417 | 2411 |
| |
2418 | 2412 |
| |
2419 | 2413 |
| |
| |||
2436 | 2430 |
| |
2437 | 2431 |
| |
2438 | 2432 |
| |
2439 |
| - | |
2440 |
| - | |
2441 |
| - | |
2442 |
| - | |
2443 |
| - | |
2444 |
| - | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
2445 | 2459 |
| |
2446 | 2460 |
| |
2447 | 2461 |
| |
|
Lines changed: 2 additions & 39 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
23 | 23 |
| |
24 | 24 |
| |
25 | 25 |
| |
| 26 | + | |
26 | 27 |
| |
27 | 28 |
| |
28 | 29 |
| |
| |||
1671 | 1672 |
| |
1672 | 1673 |
| |
1673 | 1674 |
| |
1674 |
| - | |
1675 |
| - | |
1676 |
| - | |
1677 |
| - | |
1678 |
| - | |
1679 |
| - | |
1680 |
| - | |
1681 |
| - | |
1682 |
| - | |
1683 |
| - | |
1684 |
| - | |
1685 |
| - | |
1686 |
| - | |
1687 |
| - | |
1688 |
| - | |
1689 |
| - | |
1690 |
| - | |
1691 |
| - | |
1692 |
| - | |
1693 |
| - | |
1694 |
| - | |
1695 |
| - | |
1696 |
| - | |
1697 |
| - | |
1698 |
| - | |
1699 |
| - | |
1700 |
| - | |
1701 |
| - | |
1702 |
| - | |
1703 |
| - | |
1704 |
| - | |
1705 |
| - | |
1706 |
| - | |
1707 |
| - | |
1708 |
| - | |
1709 |
| - | |
1710 |
| - | |
1711 |
| - | |
1712 |
| - | |
| 1675 | + | |
1713 | 1676 |
| |
1714 | 1677 |
| |
1715 | 1678 |
| |
|
Lines changed: 9 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
49 | 58 |
| |
50 | 59 |
| |
51 | 60 |
| |
|
Lines changed: 34 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1494 | 1494 |
| |
1495 | 1495 |
| |
1496 | 1496 |
| |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
| 1505 | + | |
| 1506 | + | |
| 1507 | + | |
| 1508 | + | |
| 1509 | + | |
| 1510 | + | |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
1497 | 1531 |
| |
1498 | 1532 |
| |
1499 | 1533 |
| |
|
Lines changed: 20 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1120 | 1120 |
| |
1121 | 1121 |
| |
1122 | 1122 |
| |
| 1123 | + | |
| 1124 | + | |
| 1125 | + | |
| 1126 | + | |
| 1127 | + | |
| 1128 | + | |
| 1129 | + | |
| 1130 | + | |
| 1131 | + | |
| 1132 | + | |
| 1133 | + | |
| 1134 | + | |
| 1135 | + | |
| 1136 | + | |
| 1137 | + | |
| 1138 | + | |
| 1139 | + | |
| 1140 | + | |
| 1141 | + | |
| 1142 | + | |
1123 | 1143 |
| |
1124 | 1144 |
| |
1125 | 1145 |
| |
|
0 commit comments
Comments
(0)