Re: invalid memory alloc after insert with c trigger function

From: Dudás József <dj1999(at)freemail(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: invalid memory alloc after insert with c trigger function
Date: 2007-06-01 19:31:39
Message-ID: 4660741B.7030305@freemail.hu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you and other helpfully peoples the interest about my first steps
in your world. I learned more than I hope.
This function work fine now.
Can you to offer me place where I find these information, because I read
the postgresql source code to find these macros.

Regards,
Josef

> Dudás József <dj1999(at)freemail(dot)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.
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2007-06-01 19:35:31 Re: Slightly OT.
Previous Message Joshua D. Drake 2007-06-01 19:10:14 Re: Slightly OT.