Re: C Tigger Function Tuples

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: C Tigger Function Tuples
Дата
Msg-id 3D529AAF.10101@joeconway.com
обсуждение исходный текст
Ответ на C Tigger Function Tuples  ("Kubat, Philip" <philip.kubat@cbetech.com>)
Список pgsql-general
Kubat, Philip wrote:
> I am creating a C function which send inserted records to a file called
> via a after insert trigger. I have attached my code. I have the basic
> functionality working, but I need to understand working with heap
> tuples.  I am using heap_getattr to retrieve the attrs from the
> HeapTuple.  I am planning to loop through the attr and the send then to
> a file.
>
> My question is how do you know what "type" an attr is?  To convert from
> Datum to C type i.e. DataGetInt32, dataGetCString, etc.  (See my dummy
> function GetDatumType.)

Without looking too closely at your code, it sounds like you want to use
the "out" function for each attribute's data type to produce a C-string
representation of it?

Look in execTuples.c and funcapi.c (in CVS, not in 7.2.1) at
TupleDescGetAttInMetadata(), BuildTupleFromCStrings(), and
get_type_metadata() for an example of just the opposite process --
building a tuple from C strings. You should be able to do something
similar with the "out" functions instead of the "in" functions.

I'm sure there are other examples that can be found in the source.
Another likely place to look is the code in copy.c.

HTH,

Joe


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: SQL Comments
Следующее
От: Gregory Seidman
Дата:
Сообщение: Re: increasing FUNC_MAX_ARGS insufficient?