Make the system-attributes loop in AddNewAttributeTuples depend on
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Oct 2008 23:27:40 +0000 (23:27 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 14 Oct 2008 23:27:40 +0000 (23:27 +0000)
lengthof(SysAtt) not FirstLowInvalidHeapAttributeNumber, for consistency with
the other uses of the SysAtt array, and to make it clearer that it doesn't
walk off the end of that array.

src/backend/catalog/heap.c

index 49442644c27508444e16cc1d74e62ba2db889a38..c299837f413c259f17dddfa37b3d60d9aad3918f 100644 (file)
@@ -551,7 +551,7 @@ AddNewAttributeTuples(Oid new_rel_oid,
        if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE)
        {
                dpp = SysAtt;
-               for (i = 0; i < -1 - FirstLowInvalidHeapAttributeNumber; i++)
+               for (i = 0; i < (int) lengthof(SysAtt); i++, dpp++)
                {
                        if (tupdesc->tdhasoid ||
                                (*dpp)->attnum != ObjectIdAttributeNumber)
@@ -587,7 +587,6 @@ AddNewAttributeTuples(Oid new_rel_oid,
 
                                heap_freetuple(tup);
                        }
-                       dpp++;
                }
        }