Re: pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ldm(at)apartia(dot)com
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions)
Date: 2000-05-25 15:11:43
Message-ID: 22786.959267503@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Louis-David Mitterrand <cunctator(at)apartia(dot)ch> writes:
> Can I do

> double result = 10.5; /* for example */
> SPI_modifytuple(relation, tupdesc, &attnum,Float32GetDatum(&result),NULL);
> ^^^

I think you could get away with that in this example. The critical
question of course is whether the Datum pointer will continue to
be used after your routine exits. But SPI_modifytuple should have
created the new tuple (and copied the values of pass-by-reference
items, such as float8s, into it) before returning.

BTW you should be using Float64GetDatum. There's no real difference
in those two macros at the moment, but it's a type error that might
bite you someday (like as soon as you need to convert this code to
the new fmgr ;-)).

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ed Loehr 2000-05-25 15:35:13 Timezone discrepancies
Previous Message Tom Lane 2000-05-25 14:55:05 Re: understanding Datum -> char * -> Datum conversions