Re: Internal function call from C-language function - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Internal function call from C-language function
Date
Msg-id 20061208095348.GA25912@svana.org
Whole thread Raw
In response to Re: Internal function call from C-language function  (Zoltan Boszormenyi <zboszor@dunaweb.hu>)
List pgsql-general
On Thu, Dec 07, 2006 at 06:01:13PM +0100, Zoltan Boszormenyi wrote:
> >I have just one more question:
> >How can I get an Oid out of a Datum, i.e.
> >how do I know what type I get in a given Datum?
> >DatumGetObjectId() seems to give me an Oid that
> >was specifically stored as a Datum.
>
> I have found the alternative solution.
> If t is HeapTupleHeader then:

<snip>

There is no way to tell what type is in a Datum, it's just that,
nothing else. The information about the actual type can come from
elsewhere, for example:

- If extracting from a tuple, the tuple descriptor has the type (as you found)
- If passed as argument, the fcinfo struct *may* have the type
information
- The SPI interface provide ways to get information also

On the other side, a Datum is abstract, and you can receive a Datum as
argument and pass it to other functions without needing to know what
type it is. But you better so it right because there is no type
checking on that level.

As for the backtrace, you can get gdb to attach to the backend after
you connect. Then when you get the segfault, gdb will catch it and show
you exactly where.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

Attachment

pgsql-general by date:

Previous
From: Stéphane Schildknecht
Date:
Subject: Excluding schema from backup
Next
From: Ragnar
Date:
Subject: Re: How to use outer join in update