|
8 | 8 | * |
9 | 9 | * |
10 | 10 | * IDENTIFICATION |
11 | | - * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.224 2004/05/26 04:41:10 neilc Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/commands/copy.c,v 1.225 2004/06/05 19:48:07 tgl Exp $ |
12 | 12 | * |
13 | 13 | *------------------------------------------------------------------------- |
14 | 14 | */ |
@@ -1158,13 +1158,11 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, |
1158 | 1158 |
|
1159 | 1159 | /* |
1160 | 1160 | * Get info about the columns we need to process. |
1161 | | - * |
1162 | | - * +1's here are to avoid palloc(0) in a zero-column table. |
1163 | 1161 | */ |
1164 | | -out_functions= (FmgrInfo*)palloc((num_phys_attrs+1)*sizeof(FmgrInfo)); |
1165 | | -elements= (Oid*)palloc((num_phys_attrs+1)*sizeof(Oid)); |
1166 | | -isvarlena= (bool*)palloc((num_phys_attrs+1)*sizeof(bool)); |
1167 | | -force_quote= (bool*)palloc((num_phys_attrs+1)*sizeof(bool)); |
| 1162 | +out_functions= (FmgrInfo*)palloc(num_phys_attrs*sizeof(FmgrInfo)); |
| 1163 | +elements= (Oid*)palloc(num_phys_attrs*sizeof(Oid)); |
| 1164 | +isvarlena= (bool*)palloc(num_phys_attrs*sizeof(bool)); |
| 1165 | +force_quote= (bool*)palloc(num_phys_attrs*sizeof(bool)); |
1168 | 1166 | foreach(cur,attnumlist) |
1169 | 1167 | { |
1170 | 1168 | intattnum=lfirst_int(cur); |
@@ -1501,14 +1499,13 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, |
1501 | 1499 | * relation, including the input function, the element type (to pass |
1502 | 1500 | * to the input function), and info about defaults and constraints. |
1503 | 1501 | * (Which input function we use depends on text/binary format choice.) |
1504 | | - * +1's here are to avoid palloc(0) in a zero-column table. |
1505 | 1502 | */ |
1506 | | -in_functions= (FmgrInfo*)palloc((num_phys_attrs+1)*sizeof(FmgrInfo)); |
1507 | | -elements= (Oid*)palloc((num_phys_attrs+1)*sizeof(Oid)); |
1508 | | -defmap= (int*)palloc((num_phys_attrs+1)*sizeof(int)); |
1509 | | -defexprs= (ExprState**)palloc((num_phys_attrs+1)*sizeof(ExprState*)); |
1510 | | -constraintexprs= (ExprState**)palloc0((num_phys_attrs+1)*sizeof(ExprState*)); |
1511 | | -force_notnull= (bool*)palloc((num_phys_attrs+1)*sizeof(bool)); |
| 1503 | +in_functions= (FmgrInfo*)palloc(num_phys_attrs*sizeof(FmgrInfo)); |
| 1504 | +elements= (Oid*)palloc(num_phys_attrs*sizeof(Oid)); |
| 1505 | +defmap= (int*)palloc(num_phys_attrs*sizeof(int)); |
| 1506 | +defexprs= (ExprState**)palloc(num_phys_attrs*sizeof(ExprState*)); |
| 1507 | +constraintexprs= (ExprState**)palloc0(num_phys_attrs*sizeof(ExprState*)); |
| 1508 | +force_notnull= (bool*)palloc(num_phys_attrs*sizeof(bool)); |
1512 | 1509 |
|
1513 | 1510 | for (attnum=1;attnum <=num_phys_attrs;attnum++) |
1514 | 1511 | { |
@@ -1635,8 +1632,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, |
1635 | 1632 | fmgr_info(in_func_oid,&oid_in_function); |
1636 | 1633 | } |
1637 | 1634 |
|
1638 | | -values= (Datum*)palloc((num_phys_attrs+1)*sizeof(Datum)); |
1639 | | -nulls= (char*)palloc((num_phys_attrs+1)*sizeof(char)); |
| 1635 | +values= (Datum*)palloc(num_phys_attrs*sizeof(Datum)); |
| 1636 | +nulls= (char*)palloc(num_phys_attrs*sizeof(char)); |
1640 | 1637 |
|
1641 | 1638 | /* Make room for a PARAM_EXEC value for domain constraint checks */ |
1642 | 1639 | if (hasConstraints) |
|