[GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Carsten Kropf
Hello everybody, I am quite a novice in using the extension features of the PostgreSQL database. Actually, I have to do this for work at the university. At the moment, I am trying around a little bit with creating my own types using shared objects, written in C. The usage of static types with fi

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Yeb Havinga
Carsten Kropf wrote: The usage of static types with fixed length was actually no problem for me, so I proceeded to variable length types. I created an n-dimensional point structure called "PointND" that contains a field of float8 values of dynamic length. I also put in a int4/int32 field for t

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Carsten Kropf
Actually, I thought, I did this using the int32 variable called "dimension" which should be exactly this field. Unfortunately, it seems, that something is wrong here. I'll look inside the code of cube to determine the things I'm doing wrong, currently. Thanks so far for your advice. My in-method

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Yeb Havinga
Carsten Kropf wrote: Actually, I thought, I did this using the int32 variable called "dimension" which should be exactly this field. yes. in = (PointND *) palloc(sizeof(float8) * dimensions + VARHDRSZ); SET_VARSIZE(in, dimensions); What about len = sizeof(float8) * dimensions + VARHDRSZ; in =

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Carsten Kropf
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? Then it would become pretty much obvious, why this is not supposed to work. I'll try it out then. regards

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread 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

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Carsten Kropf
Thanks for the hint according to the cube, this was actually exactly what I have been looking for. I wanted to do something similar like the cube but I didn't think that it would be implemented in multiple dimension. I just thought, the cube were a 3-d construct, but as I see in the sources, it

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-10 Thread Carsten Kropf
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

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-11 Thread Tom Lane
Carsten Kropf writes: > 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 p

Re: [GENERAL] Extending SQL in C using VARIABLE length type

2010-02-11 Thread Carsten Kropf
Thanks for this hint, I already got it to work in the meantime. My approach now (based on the fact, that PointND is indeed a variable length type) is to have the following structure: struct Range { int vl_len_; struct PointND limits[1]; }; whereas now vl_len_ stores the total size