Re: difficulty extracting variable-sized field on triggered row

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: difficulty extracting variable-sized field on triggered row
Дата
Msg-id 20071204154350.GB19536@svana.org
обсуждение исходный текст
Ответ на Re: difficulty extracting variable-sized field on triggered row  ("Glen W. Mabey" <Glen.Mabey@swri.org>)
Список pgsql-general
On Tue, Dec 04, 2007 at 09:26:46AM -0600, Glen W. Mabey wrote:
> On Tue, Dec 04, 2007 at 09:10:21AM -0600, Pavel Stehule wrote:
> > use macro DatumGetPointer(datum)
>
> When I do that, I get the following compiler warning:
>
>     warning: assignment from incompatible pointer type

Well yes, you're getting a (void*) which you need to cast to a (text*).
It's the generic cast for indirect types.

> Using DatumGetPointer also seg faults ...

What actually segfault? Not DatumGetPointer() since that's just a cast.

> Is there somewhere that I am not adequately checking for an error?

Depends what you're doing. Remember, a (text*) is a varlena object so
you need to use the VAR_DATA,VAR_LEN macros to access it. The string is
not nul-terminated for example. If you want to get a plain C-string,
use textout or DatumToCString or something similar.

However, DETOAST is the right step, because if you don't do that you
might be handed a toasted string.

Have a nice day,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Those who make peaceful revolution impossible will make violent revolution inevitable.
>  -- John F Kennedy

Вложения

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: difficulty extracting variable-sized field on triggered row
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: WAL shipping question