Prevent palloc(0) error when parent table has zero columns.
authorTom Lane <[email protected]>
Mon, 21 Apr 2003 15:20:02 +0000 (15:20 +0000)
committerTom Lane <[email protected]>
Mon, 21 Apr 2003 15:20:02 +0000 (15:20 +0000)
src/backend/commands/tablecmds.c

index 9b27780bc584005efc2c731fa9cd358faaef8bf8..02747661a145ce93ce33d4790af78407764599cc 100644 (file)
@@ -576,9 +576,10 @@ MergeAttributes(List *schema, List *supers, bool istemp,
                 * newattno[] will contain the child-table attribute numbers for
                 * the attributes of this parent table.  (They are not the same
                 * for parents after the first one, nor if we have dropped
-                * columns.)
+                * columns.)  +1 is to prevent error if parent has zero columns.
                 */
-               newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber));
+               newattno = (AttrNumber *)
+                       palloc((tupleDesc->natts + 1) * sizeof(AttrNumber));
 
                for (parent_attno = 1; parent_attno <= tupleDesc->natts;
                         parent_attno++)