From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | "Kubat, Philip" <philip(dot)kubat(at)cbetech(dot)com> |
Cc: | "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: C Tigger Function Tuples |
Date: | 2002-08-08 16:22:07 |
Message-ID: | 3D529AAF.10101@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Seidman | 2002-08-08 17:09:13 | Re: increasing FUNC_MAX_ARGS insufficient? |
Previous Message | Tom Lane | 2002-08-08 14:37:32 | Re: SQL Comments |