Skip to content

Commit ca944bd

Browse files
committed
Prevent palloc(0) error when parent table has zero columns.
1 parent 185ad7a commit ca944bd

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/backend/commands/tablecmds.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.70 2003/03/21 15:43:02 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.71 2003/04/21 15:19:55 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -591,9 +591,10 @@ MergeAttributes(List *schema, List *supers, bool istemp,
591591
* newattno[] will contain the child-table attribute numbers for
592592
* the attributes of this parent table. (They are not the same
593593
* for parents after the first one, nor if we have dropped
594-
* columns.)
594+
* columns.) +1 is to prevent error if parent has zero columns.
595595
*/
596-
newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber));
596+
newattno = (AttrNumber *)
597+
palloc((tupleDesc->natts + 1) * sizeof(AttrNumber));
597598

598599
for (parent_attno = 1; parent_attno <= tupleDesc->natts;
599600
parent_attno++)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy