From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | "I(dot) B(dot)" <i(dot)bre(at)live(dot)com> |
Cc: | dalroi(at)solfertje(dot)student(dot)utwente(dot)nl, pgsql-general(at)postgresql(dot)org |
Subject: | Re: Persistence problem |
Date: | 2010-05-13 10:42:09 |
Message-ID: | 20100513104209.GB4554@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)svana(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Thom Brown | 2010-05-13 12:12:11 | Re: pg_dumpall custom format? |
Previous Message | I. B. | 2010-05-13 10:29:24 | Re: Persistence problem |