forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit43330cd
committed
Calculate extraUpdatedCols in query rewriter, not parser.
It's unsafe to do this at parse time because addition of generatedcolumns to a table would not invalidate stored rules containingUPDATEs on the table ... but there might now be dependent generatedcolumns that were not there when the rule was made. This also fixesan oversight that rewriteTargetView failed to update extraUpdatedColswhen transforming an UPDATE on an updatable view. (Since the newcalculation is downstream of that, rewriteTargetView doesn't actuallyneed to do anything; but before, there was a demonstrable bug there.)In v13 and HEAD, this leads to easily-visible bugs because (sincecommitc6679e4) we won't recalculate generated columns that aren'tlisted in extraUpdatedCols. In v12 this bitmap is mostly just usedfor trigger-firing decisions, so you'd only notice a problem if atrigger cared whether a generated column had been updated.I'd complained about this back in May, but then forgot about ituntil bug #16671 from Michael Paul Killian revived the issue.Back-patch to v12 where this field was introduced. If existingstored rules contain any extraUpdatedCols values, they'll beignored because the rewriter will overwrite them, so the bug willbe fixed even for existing rules. (But note that if someone wereto update to 13.1 or 12.5, store some rules with UPDATEs on tableshaving generated columns, and then downgrade to a prior minor version,they might observe issues similar to what this patch fixes. Thatseems unlikely enough to not be worth going to a lot of effort to fix.)Discussion:https://postgr.es/m/10206.1588964727@sss.pgh.pa.usDiscussion:https://postgr.es/m/16671-2fa55851859fb166@postgresql.org1 parent93f726c commit43330cd
File tree
9 files changed
+115
-47
lines changed- src
- backend
- optimizer/plan
- parser
- replication/logical
- rewrite
- include
- nodes
- parser
- rewrite
- test/regress
- expected
- sql
9 files changed
+115
-47
lines changedLines changed: 3 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
387 | 387 |
| |
388 | 388 |
| |
389 | 389 |
| |
390 |
| - | |
391 |
| - | |
392 |
| - | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
393 | 393 |
| |
394 | 394 |
| |
395 | 395 |
| |
|
Lines changed: 0 additions & 33 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2287 | 2287 |
| |
2288 | 2288 |
| |
2289 | 2289 |
| |
2290 |
| - | |
2291 | 2290 |
| |
2292 | 2291 |
| |
2293 | 2292 |
| |
| |||
2346 | 2345 |
| |
2347 | 2346 |
| |
2348 | 2347 |
| |
2349 |
| - | |
2350 |
| - | |
2351 | 2348 |
| |
2352 | 2349 |
| |
2353 | 2350 |
| |
2354 |
| - | |
2355 |
| - | |
2356 |
| - | |
2357 |
| - | |
2358 |
| - | |
2359 |
| - | |
2360 |
| - | |
2361 |
| - | |
2362 |
| - | |
2363 |
| - | |
2364 |
| - | |
2365 |
| - | |
2366 |
| - | |
2367 |
| - | |
2368 |
| - | |
2369 |
| - | |
2370 |
| - | |
2371 |
| - | |
2372 |
| - | |
2373 |
| - | |
2374 |
| - | |
2375 |
| - | |
2376 |
| - | |
2377 |
| - | |
2378 |
| - | |
2379 |
| - | |
2380 |
| - | |
2381 |
| - | |
2382 |
| - | |
2383 |
| - | |
2384 | 2351 |
| |
2385 | 2352 |
| |
2386 | 2353 |
| |
|
Lines changed: 2 additions & 3 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
42 | 42 |
| |
43 | 43 |
| |
44 | 44 |
| |
45 |
| - | |
46 |
| - | |
47 | 45 |
| |
48 | 46 |
| |
49 | 47 |
| |
| |||
744 | 742 |
| |
745 | 743 |
| |
746 | 744 |
| |
747 |
| - | |
| 745 | + | |
| 746 | + | |
748 | 747 |
| |
749 | 748 |
| |
750 | 749 |
| |
|
Lines changed: 41 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
30 | 30 |
| |
31 | 31 |
| |
32 | 32 |
| |
| 33 | + | |
33 | 34 |
| |
34 | 35 |
| |
35 | 36 |
| |
| |||
1510 | 1511 |
| |
1511 | 1512 |
| |
1512 | 1513 |
| |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
| 1534 | + | |
| 1535 | + | |
| 1536 | + | |
| 1537 | + | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1513 | 1550 |
| |
1514 | 1551 |
| |
1515 | 1552 |
| |
| |||
1641 | 1678 |
| |
1642 | 1679 |
| |
1643 | 1680 |
| |
| 1681 | + | |
1644 | 1682 |
| |
1645 | 1683 |
| |
1646 | 1684 |
| |
| |||
3617 | 3655 |
| |
3618 | 3656 |
| |
3619 | 3657 |
| |
| 3658 | + | |
| 3659 | + | |
| 3660 | + | |
3620 | 3661 |
| |
3621 | 3662 |
| |
3622 | 3663 |
| |
|
Lines changed: 10 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
937 | 937 |
| |
938 | 938 |
| |
939 | 939 |
| |
940 |
| - | |
941 |
| - | |
942 |
| - | |
943 |
| - | |
944 |
| - | |
945 |
| - | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
| 944 | + | |
| 945 | + | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
| 949 | + | |
946 | 950 |
| |
947 | 951 |
| |
948 | 952 |
| |
|
Lines changed: 0 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
46 | 46 |
| |
47 | 47 |
| |
48 | 48 |
| |
49 |
| - | |
50 |
| - | |
51 | 49 |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
26 | 26 |
| |
27 | 27 |
| |
28 | 28 |
| |
| 29 | + | |
| 30 | + | |
| 31 | + | |
29 | 32 |
| |
30 | 33 |
| |
31 | 34 |
| |
|
Lines changed: 35 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
1467 | 1467 |
| |
1468 | 1468 |
| |
1469 | 1469 |
| |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
| 1499 | + | |
| 1500 | + | |
| 1501 | + | |
| 1502 | + | |
| 1503 | + | |
| 1504 | + | |
1470 | 1505 |
| |
1471 | 1506 |
| |
1472 | 1507 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
697 | 697 |
| |
698 | 698 |
| |
699 | 699 |
| |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
700 | 721 |
| |
701 | 722 |
| |
702 | 723 |
| |
|
0 commit comments
Comments
(0)