• Peter Eisentraut's avatar
    Fix application of identity values in some cases · 533c5d8b
    Peter Eisentraut authored
    Investigation of 2d2d06b7 revealed that
    identity values were not applied in some further cases, including
    logical replication subscribers, VALUES RTEs, and ALTER TABLE ... ADD
    COLUMN.  To fix all that, apply the identity column expression in
    build_column_default() instead of repeating the same logic at each call
    site.
    
    For ALTER TABLE ... ADD COLUMN ... IDENTITY, the previous coding
    completely ignored that existing rows for the new column should have
    values filled in from the identity sequence.  The coding using
    build_column_default() fails for this because the sequence ownership
    isn't registered until after ALTER TABLE, and we can't do it before
    because we don't have the column in the catalog yet.  So we specially
    remember in ColumnDef the sequence name that we decided on and build a
    custom NextValueExpr using that.
    Reviewed-by: default avatarMichael Paquier <michael.paquier@gmail.com>
    533c5d8b
copy.c 136 KB