forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3f9b962
committed
Ensure that pg_amop/amproc entries depend on their lefttype/righttype.
Usually an entry in pg_amop or pg_amproc does not need a dependency onits amoplefttype/amoprighttype/amproclefttype/amprocrighttype types,because there is an indirect dependency via the argument types of itsreferenced operator or procedure, or via the opclass it belongs to.However, for some support procedures in some index AMs, the argumenttypes of the support procedure might not mention the column data typeat all. Also, the amop/amproc entry might be treated as "loose" inthe opfamily, in which case it lacks a dependency on any particularopclass; or it might be a cross-type entry having a reference to adatatype that is not its opclass' opcintype.The upshot of all this is that there are cases where a datatype canbe dropped while leaving behind amop/amproc entries that mention it,because there is no path in pg_depend showing that those entriesdepend on that type. Such entries are harmless in normal activity,because they won't get used, but they cause problems for maintenanceactions such as dropping the operator family. They also cause pg_dumpto produce bogus output. The previous commit put a band-aid on theDROP OPERATOR FAMILY failure, but a real fix is needed.To fix, add pg_depend entries showing that a pg_amop/pg_amproc entrydepends on its lefttype/righttype. To avoid bloating pg_depend toomuch, skip this if the referenced operator or function has that typeas an input type. (I did not bother with considering the possibleindirect dependency via the opclass' opcintype; at least in thereported case, that wouldn't help anyway.)Probably, the reason this has escaped notice for so long is thatadd-on datatypes and relevant opclasses/opfamilies are usuallypackaged as extensions nowadays, so that there's no way to dropa type without dropping the referencing opclasses/opfamilies too.Still, in the absence of pg_depend entries there's nothing thatconstrains DROP EXTENSION to drop the opfamily entries before thedatatype, so it seems possible for a DROP failure to occur anyway.The specific case that was reported doesn't fail in v13, becausev13 prefers to attach the support procedure to the opclass not theopfamily. But it's surely possible to construct other edge casesthat do fail in v13, so patch that too.Per report from Yoran Heling. Back-patch to all supported branches.Discussion:https://postgr.es/m/Z1MVCOh1hprjK5Sf@gmai0211 parentc820037 commit3f9b962
2 files changed
+102
-0
lines changedLines changed: 98 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
65 | 65 |
| |
66 | 66 |
| |
67 | 67 |
| |
| 68 | + | |
68 | 69 |
| |
69 | 70 |
| |
70 | 71 |
| |
| |||
1507 | 1508 |
| |
1508 | 1509 |
| |
1509 | 1510 |
| |
| 1511 | + | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
| 1527 | + | |
| 1528 | + | |
| 1529 | + | |
| 1530 | + | |
| 1531 | + | |
| 1532 | + | |
| 1533 | + | |
1510 | 1534 |
| |
1511 | 1535 |
| |
1512 | 1536 |
| |
| |||
1608 | 1632 |
| |
1609 | 1633 |
| |
1610 | 1634 |
| |
| 1635 | + | |
| 1636 | + | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
| 1640 | + | |
| 1641 | + | |
| 1642 | + | |
| 1643 | + | |
| 1644 | + | |
| 1645 | + | |
| 1646 | + | |
| 1647 | + | |
| 1648 | + | |
| 1649 | + | |
| 1650 | + | |
| 1651 | + | |
| 1652 | + | |
| 1653 | + | |
| 1654 | + | |
| 1655 | + | |
| 1656 | + | |
| 1657 | + | |
1611 | 1658 |
| |
1612 | 1659 |
| |
1613 | 1660 |
| |
| |||
1616 | 1663 |
| |
1617 | 1664 |
| |
1618 | 1665 |
| |
| 1666 | + | |
| 1667 | + | |
| 1668 | + | |
| 1669 | + | |
| 1670 | + | |
| 1671 | + | |
| 1672 | + | |
| 1673 | + | |
| 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 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1619 | 1717 |
| |
1620 | 1718 |
| |
1621 | 1719 |
| |
|
Lines changed: 4 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
76 | 76 |
| |
77 | 77 |
| |
78 | 78 |
| |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
79 | 83 |
| |
80 | 84 |
| |
81 | 85 |
| |
|
0 commit comments
Comments
(0)