m w <[EMAIL PROTECTED]> writes: > If I write a function that does a 'tolower()' on each > character of a parameter passed into my function, do I > have to allocate a new text object and initialize it > and copy the data, or can I modify that object in > place and return it? You must NEVER alter a pass-by-reference parameter, of text or any other data type. If you do, you are probably altering data in a disk buffer, thus changing the content of a tuple. > Secondly, if I modify the data length of an object, > as: VARDATA(field) = nn, making sure that 'nn' is > smaller than the origial length, with this affect the > memory management? In a palloc'd temp object it's OK if the allocated size is more than what you end up using, so yes you can set VARSIZE() to less than what you allocated. Some of the built-in functions do things this way to simplify calculation of the palloc request size, IIRC. Again, you cannot scribble on a source object. In 7.1, for toastable data types there are GETARG macros that guarantee to return a writable copy, see PG_GETARG_TEXT_P_COPY etc. I believe tolower() and similar functions use this already. regards, tom lane