aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-04-21 15:20:02 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-04-21 15:20:02 +0000
commita72fd0d60ea527a225972c481c7dd02f75dac653 (patch)
treea2c6e6307b1ee32e4d2357fa7fd22e269717f80f
parent9ccfbe254a32fb95ca99e2facb95053a0d9c8db8 (diff)
downloadpostgresql-a72fd0d60ea527a225972c481c7dd02f75dac653.tar.gz
postgresql-a72fd0d60ea527a225972c481c7dd02f75dac653.zip
Prevent palloc(0) error when parent table has zero columns.
-rw-r--r--src/backend/commands/tablecmds.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c
index 46d9b709398..2823355faf0 100644
--- a/src/backend/commands/tablecmds.c
+++ b/src/backend/commands/tablecmds.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.51.2.1 2002/12/16 18:39:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.51.2.2 2003/04/21 15:20:02 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -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++)