• Robert Haas's avatar
    Teach ALTER TABLE .. SET DATA TYPE to avoid some table rewrites. · d31e2a49
    Robert Haas authored
    When the old type is binary coercible to the new type and the using
    clause does not change the column contents, we can avoid a full table
    rewrite, though any indexes on the affected columns will still need
    to be rebuilt.  This applies, for example, when changing a varchar
    column to be of type text.
    
    The prior coding assumed that the set of operations that force a
    rewrite is identical to the set of operations that must be propagated
    to tables making use of the affected table's rowtype.  This is
    no longer true: even though the tuples in those tables wouldn't
    need to be modified, the data type change invalidate indexes built
    using those composite type columns.  Indexes on the table we're
    actually modifying can be invalidated too, of course, but the
    existing machinery is sufficient to handle that case.
    
    Along the way, add some debugging messages that make it possible
    to understand what operations ALTER TABLE is actually performing
    in these cases.
    
    Noah Misch and Robert Haas
    d31e2a49
alter_table.sgml 38.6 KB