Thread

  1. Re: let ALTER TABLE DROP COLUMN drop whole-row referenced object

    jian he <jian.universality@gmail.com> — 2025-12-23T01:49:26Z

    Hi,
    
    I have consolidated the work into two patches.
    0001 handles indexes and CHECK constraints that contain whole-row references.
    0002 handles policies that contain whole-row references.
    
    The difference is that, for policy objects, we cannot use pull_varattnos to find
    whole-row references, since we need recurse to Sublink node, Also, a policy’s
    whole-row reference may point to an arbitrary relation, while index, check
    constraint can only reference the relation it is associated with.
    
    so the previous v5-0003 scans pg_policy.polrelid to find out whether it's safe
    to drop one relation is wrong, we should use pg_depend.
    
    
    summary:
    For objects (indexes, constraints, policies) that contain whole-row references:
    ALTER TABLE DROP COLUMN will drop these objects too.
    
    ALTER COLUMN SET DATA TYPE will error out, saying that the data type cannot be
    changed because whole-row–dependent objects exist.
    
    
    --
    jian
    https://www.enterprisedb.com/