SPI_modifytuple for varchar - Mailing list pgsql-general

From Alex Guryanow
Subject SPI_modifytuple for varchar
Date
Msg-id 437.000919@nlr.ru
Whole thread Raw
List pgsql-general
Hi,

my query is about using the function SPI_modifytuple for a varchar
field.
I have (for example) a table with a field my_field of type
varchar(100). And I need to create a trigger that adds the phrase
"hello, world" to any value, that user inserts (or updates) in field
my_field. Using SPI_getvalue I can retrive the value that user tries
to insert, I can concatenate this value with my phrase "hello world"
using standard function strcat, but I do not understand what arguments
should I pass to SPI_modifytuple function. Say my_value is the pointer
to the concatenated string:
   char *my_value;

If I use the function

   SPI_modifytuple( rel, newtuple, 1, attnums, my_value, NULL )

then my backend crashes. Can anybody say what I'm doing wrong or give
me an example of modification of varchar value using SPI_* interface?

Best regards,
Alex



pgsql-general by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: binary operators on integers
Next
From: "Christian Aberger"
Date:
Subject: Oracle Conversions Tools