Re: Internal function call from C-language function

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Internal function call from C-language function
Дата
Msg-id 20061208095348.GA25912@svana.org
обсуждение исходный текст
Ответ на Re: Internal function call from C-language function  (Zoltan Boszormenyi <zboszor@dunaweb.hu>)
Список 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.

Вложения

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

Предыдущее
От: Stéphane Schildknecht
Дата:
Сообщение: Excluding schema from backup
Следующее
От: Ragnar
Дата:
Сообщение: Re: How to use outer join in update