• Peter Eisentraut's avatar
    Fix CREATE TABLE LIKE INCLUDING GENERATED column order issue · e92e4a2b
    Peter Eisentraut authored
    CREATE TABLE LIKE INCLUDING GENERATED would fail if a generated column
    referred to a column with a higher attribute number.  This is because
    the column mapping mechanism created the mapping incrementally as
    columns are added.  This was sufficient for previous uses of that
    mechanism (omitting dropped columns), and it also happened to work if
    generated columns only referred to columns with lower attribute
    numbers, but here it failed.
    
    This fix is to build the attribute mapping in a separate loop before
    processing the columns in detail.
    
    Bug: #16342
    Reported-by: default avatarEthan Waldo <ewaldo@healthetechs.com>
    Reviewed-by: default avatarTom Lane <tgl@sss.pgh.pa.us>
    e92e4a2b
create_table_like.out 17.2 KB