"Jason Nerothin" <jasonnerothin@xxxxxxxxx> writes: > PG_FUNCTION_INFO_V1(par); > Datum par(PG_FUNCTION_ARGS) // pete and repeat! takes text struct pointer > { > text *t = PG_GETARG_TEXT_P(0); > text *new_t = (text*) palloc(VARSIZE(t)); > VARATT_SIZEP(new_t) = VARSIZE(t); > memcpy((void*) VARDATA(new_t),(void*)VARDATA(t),VARSIZE(t) - VARHDRSZ); > char *ptr = (char*) VARDATA(new_t); > *ptr = 'Q'; // NO EFFECT > PG_RETURN_TEXT(new_t); > } That looks correct to me (well aside from it being an error to define ptr in the middle of a block in C and replacing the first character with Q will be wrong if the string is 0-bytes or the first byte is a multibyte character). > The "no effect" comment applies to trying to rewrite to the same memory, > write from some static type I define, etc, etc. I think you've simplified away the mistake in your code. Have you actually tried the above code? Send an actual example and describe what actually happens. The only thing I wonder about is whether you're compiling with optimizations and without -fno-strict-aliasing which may be necessary for Postgres's code style to compile correctly. What compiler are you compiling with? -- Gregory Stark EnterpriseDB http://www.enterprisedb.com