Implementation overview
eXtremeSQL provides limited support for the dynamic database schema. The dynamic schema is implemented using the mcoddl module and requires specifying limits for the maximum number of classes and indexes in the database.
CREATE TABLE statement
When the xSQL CREATE TABLE statement is executed the runtime creates a definition of the new table using internal SQL API. The the current database dictionary is converted into the DDL format, and a new table is represented using the DDL and added to the existed database schema. The new DDL schema is converted back into the eXtremeDB C-dictionary format and the old dictionary is replaced with the new one. In order to make this possible it is necessary to reserve space for any new dictionary up-front, when allocating the dictionary. Furthermore, since the eXtremeDB database header contains structures associated with classed or indexes, it is necessary to reserve space in the array to add new classes and indexes. Thus the following must be specified for any dynamic schema:
the maximum number of classes in the database
the maximum number of indexes in the database
the maximum size of the dictionary
Note that at runtime applications can redefine the defaults through the mco_db_params_t structure ( max_classes, max_indexes, ddl_dict_size fields) and the xsqlCmd reads these parameters from the configuration file:
db_params {
...
max_classes:100,
max_indexes:1000,
ddl_dict_size 64K,
...
}
These parameters are set to zero by mco_db_params_init() function (in the C API) and McoSqlOpenParameters::McoSqlOpenParameters (in the C++ API). The xsqlcmd utility sets its own set of defaults, which is 100/1000/64K. So, the application must change the defaults in order to use dynamic DDL
CRETE TABLE syntax statement:
create_statement: CREATE TABLE name "(" { column_name data_type [ column constraint [ ... ] ]
| [ CONSTRAINT name ] table_constraint } [ "," ... ] ")"
where
column_constraint:
[ NOT ] NULL
| PRIMARY KEY
| UNIQUE
| USING [ HASH | RTREE ] INDEX
| [ FOREGN KEY ] REFERENCES table_name [ "(" column_name [ "," ... ] ")"
table_constraint:
| UNIQUE "(" column_name [ "," ... ] ")"
eXtremeSQL provides limited support for the dynamic database schema. The dynamic schema is implemented using the mcoddl module and requires specifying limits for the maximum number of classes and indexes in the database.
CREATE TABLE statement
When the xSQL CREATE TABLE statement is executed the runtime creates a definition of the new table using internal SQL API. The the current database dictionary is converted into the DDL format, and a new table is represented using the DDL and added to the existed database schema. The new DDL schema is converted back into the eXtremeDB C-dictionary format and the old dictionary is replaced with the new one. In order to make this possible it is necessary to reserve space for any new dictionary up-front, when allocating the dictionary. Furthermore, since the eXtremeDB database header contains structures associated with classed or indexes, it is necessary to reserve space in the array to add new classes and indexes. Thus the following must be specified for any dynamic schema:
the maximum number of classes in the database
the maximum number of indexes in the database
the maximum size of the dictionary
Note that at runtime applications can redefine the defaults through the mco_db_params_t structure ( max_classes, max_indexes, ddl_dict_size fields) and the xsqlCmd reads these parameters from the configuration file:
db_params {
...
max_classes:100,
max_indexes:1000,
ddl_dict_size 64K,
...
}
These parameters are set to zero by mco_db_params_init() function (in the C API) and McoSqlOpenParameters::McoSqlOpenParameters (in the C++ API). The xsqlcmd utility sets its own set of defaults, which is 100/1000/64K. So, the application must change the defaults in order to use dynamic DDL
CRETE TABLE syntax statement:
create_statement: CREATE TABLE name "(" { column_name data_type [ column constraint [ ... ] ]
| [ CONSTRAINT name ] table_constraint } [ "," ... ] ")"
where
column_constraint:
[ NOT ] NULL
| PRIMARY KEY
| UNIQUE
| USING [ HASH | RTREE ] INDEX
| [ FOREGN KEY ] REFERENCES table_name [ "(" column_name [ "," ... ] ")"
table_constraint:
| UNIQUE "(" column_name [ "," ... ] ")"