99 *
1010 *
1111 * 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 $
1313 *
1414 * NOTES
1515 * The old interface functions have been converted to macros
@@ -173,13 +173,11 @@ heap_attisnull(HeapTuple tup, int attnum)
173173case MinCommandIdAttributeNumber :
174174case MaxTransactionIdAttributeNumber :
175175case MaxCommandIdAttributeNumber :
176+ /* these are never null */
176177break ;
177178
178- case 0 :
179- elog (ERROR ,"heap_attisnull: zero attnum disallowed" );
180-
181179default :
182- elog (ERROR ,"heap_attisnull: undefined negative attnum" );
180+ elog (ERROR ,"invalid attnum: %d" , attnum );
183181}
184182
185183return 0 ;
@@ -457,7 +455,7 @@ heap_getsysattr(HeapTuple tup, int attnum, bool *isnull)
457455result = ObjectIdGetDatum (tup -> t_tableOid );
458456break ;
459457default :
460- elog (ERROR ,"heap_getsysattr: invalid attnum %d" ,attnum );
458+ elog (ERROR ,"invalid attnum: %d" ,attnum );
461459result = 0 ;/* keep compiler quiet */
462460break ;
463461}
@@ -581,8 +579,10 @@ heap_formtuple(TupleDesc tupleDescriptor,
581579int numberOfAttributes = tupleDescriptor -> natts ;
582580
583581if (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 )));
586586
587587for (i = 0 ;i < numberOfAttributes ;i ++ )
588588{
@@ -666,14 +666,11 @@ heap_modifytuple(HeapTuple tuple,
666666 * allocate and fill *value and *nulls arrays from either the tuple or
667667 * the repl information, as appropriate.
668668 */
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 ) );
671671
672- for (attoff = 0 ;
673- attoff < numberOfAttributes ;
674- attoff += 1 )
672+ for (attoff = 0 ;attoff < numberOfAttributes ;attoff ++ )
675673{
676-
677674if (repl [attoff ]== ' ' )
678675{
679676value [attoff ]= heap_getattr (tuple ,
@@ -683,13 +680,13 @@ heap_modifytuple(HeapTuple tuple,
683680nulls [attoff ]= (isNull ) ?'n' :' ' ;
684681
685682}
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+ {
690685value [attoff ]= replValue [attoff ];
691686nulls [attoff ]= replNull [attoff ];
692687}
688+ else
689+ elog (ERROR ,"unrecognized replace flag: %d" , (int )repl [attoff ]);
693690}
694691
695692/*
@@ -699,6 +696,9 @@ heap_modifytuple(HeapTuple tuple,
699696value ,
700697nulls );
701698
699+ pfree (value );
700+ pfree (nulls );
701+
702702/*
703703 * copy the identification info of the old tuple: t_ctid, t_self, and
704704 * OID (if any)