9
9
*
10
10
*
11
11
* IDENTIFICATION
12
- * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.83 2002/09/27 15:04:08 tgl Exp $
12
+ * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.84 2003/07/21 20:29:37 tgl Exp $
13
13
*
14
14
* NOTES
15
15
* The old interface functions have been converted to macros
@@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
173
173
case MinCommandIdAttributeNumber :
174
174
case MaxTransactionIdAttributeNumber :
175
175
case MaxCommandIdAttributeNumber :
176
+ /* these are never null */
176
177
break ;
177
178
178
- case 0 :
179
- elog (ERROR ,"heap_attisnull: zero attnum disallowed" );
180
-
181
179
default :
182
- elog (ERROR ,"heap_attisnull: undefined negative attnum" );
180
+ elog (ERROR ,"invalid attnum: %d" , attnum );
183
181
}
184
182
185
183
return 0 ;
@@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
457
455
result = ObjectIdGetDatum (tup -> t_tableOid );
458
456
break ;
459
457
default :
460
- elog (ERROR ,"heap_getsysattr: invalid attnum %d" ,attnum );
458
+ elog (ERROR ,"invalid attnum: %d" ,attnum );
461
459
result = 0 ;/* keep compiler quiet */
462
460
break ;
463
461
}
@@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
581
579
int numberOfAttributes = tupleDescriptor -> natts ;
582
580
583
581
if (numberOfAttributes > MaxTupleAttributeNumber )
584
- elog (ERROR ,"heap_formtuple: numberOfAttributes %d exceeds limit %d" ,
585
- numberOfAttributes ,MaxTupleAttributeNumber );
582
+ ereport (ERROR ,
583
+ (errcode (ERRCODE_TOO_MANY_COLUMNS ),
584
+ errmsg ("number of attributes %d exceeds limit, %d" ,
585
+ numberOfAttributes ,MaxTupleAttributeNumber )));
586
586
587
587
for (i = 0 ;i < numberOfAttributes ;i ++ )
588
588
{
@@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
666
666
* allocate and fill *value and *nulls arrays from either the tuple or
667
667
* the repl information, as appropriate.
668
668
*/
669
- value = (Datum * )palloc (numberOfAttributes * sizeof * value );
670
- nulls = (char * )palloc (numberOfAttributes * sizeof * nulls );
669
+ value = (Datum * )palloc (numberOfAttributes * sizeof ( Datum ) );
670
+ nulls = (char * )palloc (numberOfAttributes * sizeof ( char ) );
671
671
672
- for (attoff = 0 ;
673
- attoff < numberOfAttributes ;
674
- attoff += 1 )
672
+ for (attoff = 0 ;attoff < numberOfAttributes ;attoff ++ )
675
673
{
676
-
677
674
if (repl [attoff ]== ' ' )
678
675
{
679
676
value [attoff ]= heap_getattr (tuple ,
@@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
683
680
nulls [attoff ]= (isNull ) ?'n' :' ' ;
684
681
685
682
}
686
- else if (repl [attoff ]!= 'r' )
687
- elog (ERROR ,"heap_modifytuple: repl is \\%3d" ,repl [attoff ]);
688
- else
689
- {/* == 'r' */
683
+ else if (repl [attoff ]== 'r' )
684
+ {
690
685
value [attoff ]= replValue [attoff ];
691
686
nulls [attoff ]= replNull [attoff ];
692
687
}
688
+ else
689
+ elog (ERROR ,"unrecognized replace flag: %d" , (int )repl [attoff ]);
693
690
}
694
691
695
692
/*
@@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
699
696
value ,
700
697
nulls );
701
698
699
+ pfree (value );
700
+ pfree (nulls );
701
+
702
702
/*
703
703
* copy the identification info of the old tuple: t_ctid, t_self, and
704
704
* OID (if any)