Thread: Complex/elaborate user-defined base types
Hi, I am trying to create complex user-defined base types and have some difficulties. I started with the examples (complex, point, path) and I had no problem at all creating similar user-defined types, with fixed or variable length. They perform very good in all my tests (inserts, selects and so on). The problem I have is I need more elaborate types, types containing other previously defined types. I try for example to create and use something like: typedef struct SymbolType { int32 size; bool antialias; char character; bool filled; text *font; int32 gap; text *image; text *name; PathType *points; SymbolStyleType*style; int32 transparent; int32 type; } SymbolType; where PathType and SymbolStyleType are also user-defined type with variable length (PathType is a variable-length type containing a list of PointType elements (x, y) and SymbolStyleType has a variable-length array of integers). I tried several scenarios inside the IN/OUT functions and none of them works 100%. It is either the data overlaps depending on the sizes of the variable-length elements, or I have various memory problems (especially when doing SELECT on a column containing this type). I tried to use an additional "void *data" member at the end, where to dump all the variable contents and retrieve them when needed, but I could not make it work at all. Anybody tried to do do something similar and want to share some thoughts on this one? Best regards, Jean
For some strange reason this message only came from the mailing list 3 days after I sent it. I managed to figure it out on my own (how to do what I asked in the original mail), but I still have a little problem with accessing objects of user-defined base types from Java. I definitely miss something here, since I cannot even get it right for a simple type (not even variable-length one) like: typedef struct ColorType {int red;int green;int blue;int alpha; } ColorType; If I try to access the data as String (with resultSet.getString("columnName") I get the result all right, as it comes out of the de objectTypeOut function), but the type casted getObject() method fails (I tried the type mapping in different ways, but no one seem to work). Thanks in advance for any tip. Jean Jean-Henry Berevoescu wrote: > > Hi, > I am trying to create complex user-defined base types and have some > difficulties. > > I started with the examples (complex, point, path) and I had no > problem at all > creating similar user-defined types, with fixed or variable length. They > perform very good in all my tests (inserts, selects and so on). > > The problem I have is I need more elaborate types, types containing > other > previously defined types. > I try for example to create and use something like: > > typedef struct SymbolType > { > int32 size; > bool antialias; > char character; > bool filled; > text *font; > int32 gap; > text *image; > text *name; > PathType *points; > SymbolStyleType *style; > int32 transparent; > int32 type; > } SymbolType; > > where PathType and SymbolStyleType are also user-defined type with > variable > length (PathType is a variable-length type containing a list of > PointType elements > (x, y) and SymbolStyleType has a variable-length array of integers). > > I tried several scenarios inside the IN/OUT functions and none of them > works 100%. It is either the data overlaps depending on the sizes of > the variable-length > elements, or I have various memory problems (especially when doing > SELECT on > a column containing this type). > I tried to use an additional "void *data" member at the end, where to > dump all the > variable contents and retrieve them when needed, but I could not make > it work at all. > > Anybody tried to do do something similar and want to share some > thoughts on > this one? > > Best regards, > Jean > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >
For some strange reason this message only came from the mailing list 3 days after I sent it. I managed to figure it out on my own (how to do what I asked in the original mail), but I still have a little problem with accessing objects of user-defined base types from Java. I definitely miss something here, since I cannot even get it right for a simple type (not even variable-length one) like: typedef struct ColorType { int red; int green; int blue; int alpha; } ColorType; If I try to access the data as String (with resultSet.getString("columnName") I get the result all right, as it comes out of the de objectTypeOut function), but the type casted getObject() method fails (I tried the type mapping in different ways, but no one seem to work). Thanks in advance for any tip. Jean Jean-Henry Berevoescu wrote: > > Hi, > I am trying to create complex user-defined base types and have some > difficulties. > > I started with the examples (complex, point, path) and I had no > problem at all > creating similar user-defined types, with fixed or variable length. They > perform very good in all my tests (inserts, selects and so on). > > The problem I have is I need more elaborate types, types containing > other > previously defined types. > I try for example to create and use something like: > > typedef struct SymbolType > { > int32 size; > bool antialias; > char character; > bool filled; > text *font; > int32 gap; > text *image; > text *name; > PathType *points; > SymbolStyleType *style; > int32 transparent; > int32 type; > } SymbolType; > > where PathType and SymbolStyleType are also user-defined type with > variable > length (PathType is a variable-length type containing a list of > PointType elements > (x, y) and SymbolStyleType has a variable-length array of integers). > > I tried several scenarios inside the IN/OUT functions and none of them > works 100%. It is either the data overlaps depending on the sizes of > the variable-length > elements, or I have various memory problems (especially when doing > SELECT on > a column containing this type). > I tried to use an additional "void *data" member at the end, where to > dump all the > variable contents and retrieve them when needed, but I could not make > it work at all. > > Anybody tried to do do something similar and want to share some > thoughts on > this one? > > Best regards, > Jean > > > > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org >