On Tue, 28 Oct 2008, Zdenek Kotala wrote:

Kris Jurka napsal(a):

Here's a patch that changes everything over to the the new API and implements the old API by calling the new API.

It seems to me OK. I have only one comment. I prefer to pfree allocated memory for temporary nulls array. I think that caller could call old API many times without memory context cleanup.


Here's an incremental patch to add the suggested pfreeing.

Kris Jurka
*** a/src/backend/access/common/heaptuple.c
--- b/src/backend/access/common/heaptuple.c
***************
*** 801,806 **** heap_formtuple(TupleDesc tupleDescriptor,
--- 801,808 ----
  
        tuple = heap_form_tuple(tupleDescriptor, values, boolNulls);
  
+       pfree(boolNulls);
+ 
        return tuple;
  }
  
***************
*** 894,899 **** heap_modifytuple(HeapTuple tuple,
--- 896,902 ----
  {
        int                     numberOfAttributes = tupleDesc->natts;
        int                     attnum;
+       HeapTuple       result;
        bool       *replNulls = (bool *) palloc(numberOfAttributes * 
sizeof(bool));
        bool       *replActions = (bool *) palloc(numberOfAttributes * 
sizeof(bool));
  
***************
*** 903,909 **** heap_modifytuple(HeapTuple tuple,
                replActions[attnum] = replCharActions[attnum] == 'r';
        }
  
!       return heap_modify_tuple(tuple, tupleDesc, replValues, replNulls, 
replActions);
  }
  
  /*
--- 906,917 ----
                replActions[attnum] = replCharActions[attnum] == 'r';
        }
  
!       result = heap_modify_tuple(tuple, tupleDesc, replValues, replNulls, 
replActions);
! 
!       pfree(replNulls);
!       pfree(replActions);
! 
!       return result;
  }
  
  /*
***************
*** 1051,1056 **** heap_deformtuple(HeapTuple tuple,
--- 1059,1066 ----
                charNulls[attnum] = boolNulls[attnum] ? 'n' : ' ';
        }
  
+       pfree(boolNulls);
+ 
  }
  
  /*
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to