Thanks a lot so far. I adopted my structures and am now storing two fields (v_len_ and dimensions) and the storage is now working properly. If I now would try to combine two of these points to a range (like cube) including an upper and a lower bound n-dimensional point structure, I don't get the point how to achieve this. I tried around a little bit and ended up with a structure like the following: /** * basic structure definition for a range containing an upper and a lower point (in multiple dimensions) */ struct Range { int32 v_len_; /** * the upper limit in each dimension */ struct PointND * upper; /** * the lower limit in each dimension */ struct PointND * lower; }; However, the problem is again, how to put this range into a table. Actually, I don't know exactly, how to do this, I tried the following: len = VARSIZE(upper) + VARSIZE(lower) + VARHDRSZ + 2 * sizeof(struct Point *); result = (Range *) palloc0(len); // result->upper = upper; // result->lower = lower; memcpy((void *) result->upper, (void *) upper, VARSIZE(upper)); memcpy((void *) result->lower, (void *) lower, VARSIZE(lower));
// set the var size SET_VARSIZE(result, len); But this didn't do the trick. I did not yet find sth in the code of postgres, how to build such a combined type, unfortunately (or I did not look at the right places until now). How would one do this? Thanks in advance regards Carsten Kropf Am 10.02.2010 um 12:20 schrieb Yeb Havinga: > Carsten Kropf wrote: >> Oh, I see, does the VARSIZE length field have to be the total number of >> bytes occupied (including VARHDRSZ and the size of the structure) or only >> the size that is used by "my" datatype? > Yes >> Then it would become pretty much obvious, why this is not supposed to work. >> I'll try it out then. >> > My €0,02: rename the dimensions to vl_len_ to avoid confusion and get > compiler errors where you now use 'dimension'. Add a macro that converts a > pointnd structure to dimension int by taking the VARSIZE_ANY_EXHDR / > sizeof(float8) and use it where dimension is used now. Or if your database is > small you could keep dimension in the structure. > > > -- > Sent via pgsql-general mailing list (pgsql-general@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general