Variable length custom data types help

From: "Morgan Kita" <mkita(at)verseon(dot)com>
To: <pgsql-novice(at)postgresql(dot)org>
Subject: Variable length custom data types help
Date: 2005-04-01 03:45:12
Message-ID: 08B420FF5BF7BC42A064212C2EB768801C1091@neutron.verseon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ok I am creating some important custom data types for my DB. The data should be stored as an array of strucs, which themselves contain a few different data fields. Anyways I wrote the input function in C when I realized I had a problem.

The arrays will not always contain the same number of structures, and as such should be variable length. I read the pages in the manual on custom data type creation, and I noticed that you can do this by setting the first word of the stored bytes to be the total length in bytes of the stored object. So my question is, given that this is a typed array, what is the best way to represent this in the c code? In the end I am returning a pointer correct? What is the type of the pointer I should be returning? I guess I really don't understand how the memory returned by the pointer is going to be parsed by Postgres. I thought of making the first member of the array a dummy structure whose first data field would contain the length. However, that doesn't sound implementation independant and I think it would be better if I actually understood how the DB will actually parse the pointer that my function returns.

Also I have a related question... from what I read in the manual; by creating the type as variable length that automatically makes it toasted in the DB. Is that the case, and if so, do I have to do anything else other than untoast it in my output function?

Thanks,
Morgan

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message operationsengineer1 2005-04-01 05:20:45 Handling Time
Previous Message Ennio-Sr 2005-03-31 23:40:21 Re: how to ignore accents?