Remove ancient special case code for adding oid columns
authorPeter Eisentraut <peter@eisentraut.org>
Wed, 12 Jul 2023 14:12:34 +0000 (16:12 +0200)
committerPeter Eisentraut <peter@eisentraut.org>
Wed, 12 Jul 2023 14:13:40 +0000 (16:13 +0200)
The special handling of negative attribute numbers in
ATExecAddColumn() was introduced to support SET WITH OIDS (commit
6d1e361852).  But that feature doesn't exist anymore, so we can revert
to the previous, simpler version.  In passing, also remove an obsolete
comment about OID support.

Reviewed-by: Alvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://www.postgresql.org/message-id/flat/52a125e4-ff9a-95f5-9f61-b87cf447e4da@eisentraut.org

src/backend/commands/tablecmds.c

index 8fff036b73d1c878e0a685b8c42767cd643f00b1..a9e2a1a1ad2d3a22449efdcb301a21f1e76e61d1 100644 (file)
@@ -2450,8 +2450,7 @@ MergeAttributes(List *schema, List *supers, char relpersistence,
 
    /*
     * Scan the parents left-to-right, and merge their attributes to form a
-    * list of inherited attributes (inhSchema).  Also check to see if we need
-    * to inherit an OID column.
+    * list of inherited attributes (inhSchema).
     */
    child_attno = 0;
    foreach(entry, supers)
@@ -6945,7 +6944,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
    attribute.attrelid = myrelid;
    namestrcpy(&(attribute.attname), colDef->colname);
    attribute.atttypid = typeOid;
-   attribute.attstattarget = (newattnum > 0) ? -1 : 0;
+   attribute.attstattarget = -1;
    attribute.attlen = tform->typlen;
    attribute.attnum = newattnum;
    if (list_length(colDef->typeName->arrayBounds) > PG_INT16_MAX)
@@ -7068,7 +7067,7 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
     * is certainly not going to touch them.  System attributes don't have
     * interesting defaults, either.
     */
-   if (RELKIND_HAS_STORAGE(relkind) && attribute.attnum > 0)
+   if (RELKIND_HAS_STORAGE(relkind))
    {
        /*
         * For an identity column, we can't use build_column_default(),