Re: pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions)
В списке pgsql-hackers по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions) |
| Дата | |
| Msg-id | 22786.959267503@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | pfree() after palloc() in trigger (was: Re: understanding Datum -> char * -> Datum conversions) (Louis-David Mitterrand <cunctator@apartia.ch>) |
| Список | pgsql-hackers |
Louis-David Mitterrand <cunctator@apartia.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
В списке pgsql-hackers по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера