Re: Persistence problem

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: Persistence problem
Дата
Msg-id 20100513104209.GB4554@svana.org
обсуждение исходный текст
Ответ на Re: Persistence problem  (Alban Hertroys <dalroi@solfertje.student.utwente.nl>)
Ответы Re: Persistence problem  ("I. B." <i.bre@live.com>)
Список pgsql-general
On Thu, May 13, 2010 at 12:04:56PM +0200, I. B. wrote:
>
>
> I'll try to explain with as less code as possible.
> One of the types I wanted to create is called mpoint. This is a part of code:

<snip>

> typedef struct {
>     int4 length;
>     int noOfUnits;
>     void *units; // this is later casted to uPoint *
> } mapping_t;
>

This is not the correct way to handle varlena types. You can create the
datum that way, but if PostgreSQL decides to compress it (as it may
when writing to disk) you won't be able to read it back. Notably, the
"length" part of a varlena type is not always 4 bytes.

Make sure you have fully understood this page:
http://www.postgresql.org/docs/8.4/static/xfunc-c.html
it has a number of examples dealing with variable length types. You
MUST use the VARDATA/VARATT/etc macros to construct and read your data.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patriotism is when love of your own people comes first; nationalism,
> when hate for people other than your own comes first.
>                                       - Charles de Gaulle

Вложения

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

Предыдущее
От: Ivan Voras
Дата:
Сообщение: Re: Authentication method for web app
Следующее
От: Thom Brown
Дата:
Сообщение: Re: pg_dumpall custom format?