Forum OpenACS Q&A: what is the proper way to add a data type?

I am building a route reporting db, it wil have lots of networks and ips in it. What is the proper way to add a datatype to open acs?

is it as simple as:

 
insert into acs_datatypes
  (datatype, max_n_values)
 values
  (''inet'', null);
and 
insert into acs_datatypes
  (datatype, max_n_values)
 values
  (''cidr'', null);

The comments for acs_datatypes say no to this idea.

If this is true how do I use the objct system with the inet and cidr types in postgresql. I am going to try the simple answer and will see if it works. The main reason I am asking this is just because it apears to work does not mean it is the right thing to do.

thanks

Collapse
Posted by James Thornton on
Is the verdict still out on this? It would be great if we could add custom ADTs -- will doing so break any code?
Collapse
Posted by Marc Spitzer on
Do not know yet.
Collapse
Posted by Don Baccus on
The object system isn't really fully fleshed out and I'm not sure how far forward we're going to carry it.  We're looking to streamline, not further complexify, the datamodel.  The original idea was to separate out the logical types defined by the object system from database types, but that doesn't mean they can't match.  It just means the object system's not limited to SQL datatypes.

It also means that in theory you should be defining types that can be modelled in both PG and Oracle, so in theory you shouldn't be defining PG datatypes.

In practice, though, you're probably writing some custom thing that's not going to be generalized in a way that's going to be a standard part of the toolkit.  In which case you can flush theory in the toilet.

But if there's some chance you're thinking of turning your work into something that can fit into the toolkit in a general way, then you'll want to figure out just how you'll map the PG types to Oracle.

Collapse
Posted by Marc Spitzer on
Thanks Don for the reply.

for the first release I am going to make this postgresql specific.  If I continue to develope this I would like to deliver a IPv4 api with the back end as 64 bit integer, top netmask and bottom ip.  And it will be for internal use at work.

Right now I just want it working and done.

Does oracle have an int8 type?

Collapse
Posted by Don Baccus on
It has numeric, slower for math than int8 but for this kind of thing probably OK.  I don't know if it has int8 ...