User Defined Datatypes

The MonetDB kernel supports creation of user defined types, e.g. complex types.

Relationship between SQL and MAL world is expressed using an external name.

CREATE TYPE [schema_name '.'] type_name EXTERNAL NAME type_identification

DROP TYPE [schema_name '.'] type_name [RESTRICT | CASCADE]

Example

CREATE TYPE xml EXTERNAL NAME xml;

SELECT * FROM sys.types WHERE sqlname = 'xml';
-- returns 1 row for the new type: xml

CREATE TABLE msgs (msg xml);

SELECT * FROM msgs;

DROP TYPE xml CASCADE;
-- note: this drop type will also drop the created table because CASCADE is specified

The C code implementation of new atomary types is best postponed until there is no other performance-wise acceptable solution. Addition of an atomary type in the kernel would be beneficial if it is also complemented with bulk-operations for fast bulk processing, functions which accept the new type as argument and type specific optimizers which could exploit their semantics.