Re: invalid memory alloc after insert with c trigger function

Поиск
Список
Период
Сортировка
От Gregory Stark
Тема Re: invalid memory alloc after insert with c trigger function
Дата
Msg-id 87k5una4pd.fsf@oxford.xeocode.com
обсуждение исходный текст
Ответ на Re: invalid memory alloc after insert with c trigger function  (Dudás József <dj1999@freemail.hu>)
Ответы Re: invalid memory alloc after insert with c trigger function  (Dudás József <dj1999@freemail.hu>)
Список pgsql-general
Dudás József <dj1999@freemail.hu> writes:

> Yes! You are right! Now must me find out how to convert char* to numeric datum
> and double to numeric datum and numeric datum to double :)

If you have a char* you can usually call a types input function which is
usally "type_in" or "typein" like:
 DirectFunctionCall1(type_in, str).

However in the case of numeric you need to pass a couple extra parameters:
 DirectFunctionCall3(numeric_in, str, 0, -1 + VARHDRSZ)

To convert to a float8 datum you would use
 DirectFunctionCall1(numeric_float,num).

To convert from a Postgres float8 datum to an actual double you can just call
the macros DatumGetFloat8 and Float8GetDatum. This makes your code depend on
the internal representation of float8 as a C double but it's better than the
alternative.

--
  Gregory Stark
  EnterpriseDB          http://www.enterprisedb.com


В списке pgsql-general по дате отправления:

Предыдущее
От: "Joshua D. Drake"
Дата:
Сообщение: Re: multimaster
Следующее
От: "Simon Riggs"
Дата:
Сообщение: Re: warm standby server stops doingcheckpointsafterawhile