DuroDBMS API  1.2
Modules | Data Structures | Enumerations | Functions
Type functions

Modules

 Type implementation functions
 

Data Structures

struct  RDB_possrep
 

Enumerations

enum  { RDB_TYPE_ORDERED = 1, RDB_TYPE_UNION = 2 }
 

Functions

RDB_bool RDB_type_is_numeric (const RDB_type *typ)
 
RDB_bool RDB_type_is_valid (const RDB_type *typ)
 
RDB_bool RDB_type_is_ordered (const RDB_type *typ)
 
RDB_bool RDB_type_depends_type (const RDB_type *typ, const RDB_type *dtyp)
 
RDB_bool RDB_type_has_possreps (const RDB_type *typ)
 
RDB_possrepRDB_type_possreps (const RDB_type *typ, int *possrepcp)
 
RDB_possrepRDB_comp_possrep (const RDB_type *typ, const char *name)
 
RDB_attrRDB_type_property (const RDB_type *typ, const char *propname)
 
RDB_typeRDB_dup_nonscalar_type (RDB_type *typ, RDB_exec_context *ecp)
 
RDB_typeRDB_new_scalar_type (const char *name, RDB_int ireplen, RDB_bool sysimpl, RDB_bool ordered, RDB_exec_context *ecp)
 
RDB_typeRDB_new_tuple_type (int attrc, const RDB_attr attrv[], RDB_exec_context *ecp)
 
RDB_typeRDB_new_relation_type (int attrc, const RDB_attr attrv[], RDB_exec_context *ecp)
 
RDB_typeRDB_new_relation_type_from_base (RDB_type *tpltyp, RDB_exec_context *ecp)
 
RDB_typeRDB_new_array_type (RDB_type *basetyp, RDB_exec_context *ecp)
 
RDB_bool RDB_type_is_scalar (const RDB_type *typ)
 
RDB_bool RDB_type_is_relation (const RDB_type *typ)
 
RDB_bool RDB_type_is_tuple (const RDB_type *typ)
 
RDB_bool RDB_type_is_array (const RDB_type *typ)
 
RDB_typeRDB_base_type (const RDB_type *typ)
 
RDB_attrRDB_type_attrs (RDB_type *typ, int *attrcp)
 
int RDB_del_nonscalar_type (RDB_type *typ, RDB_exec_context *ecp)
 
RDB_bool RDB_type_equals (const RDB_type *typ1, const RDB_type *typ2)
 
char * RDB_type_name (const RDB_type *typ)
 
RDB_bool RDB_is_subtype (const RDB_type *typ1, const RDB_type *typ2)
 
RDB_bool RDB_share_subtype (const RDB_type *typ1, const RDB_type *typ2)
 
void RDB_lock_type (RDB_type *typ)
 
void RDB_set_cleanup (RDB_type *typ, RDB_obj_cleanup_func *cleanup_fp)
 
int RDB_define_type (const char *name, int repc, const RDB_possrep repv[], RDB_expression *constraintp, RDB_expression *initexp, int flags, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_define_subtype (const char *name, int supertypec, RDB_type *supertypev[], int repc, const RDB_possrep repv[], RDB_expression *constraintp, RDB_expression *initexp, int flags, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_drop_type (const char *name, RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_bool RDB_is_selector (const RDB_operator*op)
 
RDB_typeRDB_get_type (const char *name, RDB_exec_context *ecp, RDB_transaction *txp)
 

Detailed Description

Function Documentation

RDB_type* RDB_base_type ( const RDB_type typ)

Return the base type of a relation or array type.

Returns
The base type if typ is a relation or array type, NULL otherwise.

Referenced by RDB_table_contains().

RDB_possrep* RDB_comp_possrep ( const RDB_type typ,
const char *  name 
)

Returns a pointer to a RDB_possrep structure representing the possible representation of type typ containing a component named name. The structure is managed by the type.

Returns
A pointer to the RDB_possrep structure or NULL if the component does not exist.
int RDB_define_subtype ( const char *  name,
int  supertypec,
RDB_type supertypev[],
int  repc,
const RDB_possrep  repv[],
RDB_expression *  constraintp,
RDB_expression *  initexp,
int  flags,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)
int RDB_define_type ( const char *  name,
int  repc,
const RDB_possrep  repv[],
RDB_expression *  constraintp,
RDB_expression *  initexp,
int  flags,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Defines a type with the name name and repc possible representations. The individual possible representations are described by the elements of repv.

If constraintp is not NULL, it specifies the type constraint. When the constraint is evaluated, the value of components are available under the name of the respective component.

initexp specifies the initializer. The expression must be of the type being defined.

flags must be 0 or constructed by bitwise OR-ing one or more of the following values:

RDB_TYPE_ORDERED
The type being defined is an ordered type. If a type is ordered and has more than one possrep, or if the possrep contains a component of a type that is not ordered, a user-defined comparison operator must be provided. (See RDB_implement_type()).
RDB_TYPE_UNION
The type being defined is a union type. Currently, only dummy types can (and must) be union types.
Returns

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
txp does not point to a running transaction.
element_exists_error
There is already a type with name name.
type_mismatch_error
constraintp is not NULL and not of type boolean. constraintp is not NULL and contains an operator invocation where the argument type does not match the parameter type.
name_error
constraintp is not NULL and contains a variable reference that could not be resolved.
operator_not_found_error
constraintp is not NULL and contains an invocation of an operator that has not been defined.
invalid argument error
initexp is not a valid selector invocation.
type_mismatch_error
initexp contains an argument whose type does not match the corresponing selector parameter.

The call may also fail for a system error, in which case the transaction may be implicitly rolled back.

References RDB_define_subtype().

int RDB_del_nonscalar_type ( RDB_type typ,
RDB_exec_context *  ecp 
)
int RDB_drop_type ( const char *  name,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Deletes the user-defined type with name specified by name.

It is not possible to destroy built-in types.

If a selector operator is present, it will be deleted.

Returns

On success, RDB_OK is returned. Any other return value indicates an error.

Errors:
no_running_tx_error
*txp is not a running transaction.
name_error
A type with name name was not found.
invalid_argument_error
The type is not user-defined.

The call may also fail for a system error, in which case the transaction may be implicitly rolled back.

References RDB_clear_err(), RDB_destroy_obj(), RDB_drop_op(), RDB_get_err(), RDB_get_type(), RDB_init_obj(), RDB_obj_string(), RDB_obj_type(), RDB_raise_in_use(), RDB_raise_invalid_argument(), RDB_raise_no_memory(), RDB_raise_no_running_tx(), RDB_tx_is_running(), RDB_type_is_ordered(), and RDB_type_name().

RDB_type* RDB_dup_nonscalar_type ( RDB_type typ,
RDB_exec_context *  ecp 
)

If *typ is non-scalar, RDB_dup_nonscalar_creates a copy of it.

Returns

A pointer to a copy of *typ, if *typ is non-scalar. typ, if *typ is scalar.

If the operation fails, NULL is returned.

References RDB_alloc(), RDB_dup_nonscalar_type(), RDB_free(), and RDB_new_tuple_type().

Referenced by RDB_copy_obj_data(), RDB_dup_nonscalar_type(), RDB_implement_type(), RDB_new_tuple_type(), RDB_obj_property(), RDB_obj_to_expr(), and RDB_set_init_value().

RDB_type* RDB_get_type ( const char *  name,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Returns a pointer to RDB_type structure which represents the type with the name name.

Returns

The pointer to the type on success, or NULL if an error occured.

Errors:
type_not_found_error
A type with the name name could not be found.
The type name is not a built-in type and txp is NULL.

The call may also fail for a system error, in which case the transaction may be implicitly rolled back.

References RDB_destroy_obj(), RDB_evaluate(), RDB_free(), RDB_get_err(), RDB_init_obj(), RDB_obj_type(), RDB_raise_no_memory(), RDB_raise_type_not_found(), and RDB_type_is_ordered().

Referenced by RDB_define_subtype(), RDB_drop_type(), and RDB_implement_type().

RDB_bool RDB_is_selector ( const RDB_operator*  op)

Determines if the operator *op is a selector.

References RDB_operator_name().

Referenced by RDB_call_ro_op_by_name_e().

RDB_bool RDB_is_subtype ( const RDB_type typ1,
const RDB_type typ2 
)

Determines if *typ1 is a subtype of *typ2. Note that the subtype relationship is reflexive.

References RDB_is_subtype(), RDB_type_equals(), and RDB_attr::typ.

Referenced by RDB_is_subtype(), RDB_share_subtype(), and RDB_type_depends_type().

void RDB_lock_type ( RDB_type typ)

Mark *typ as locked. If a scalar type is locked its memory is not freed.

RDB_type* RDB_new_array_type ( RDB_type basetyp,
RDB_exec_context *  ecp 
)

Creates a RDB_type struct for an array type. The base type is specified by typ.

Returns

A pointer to a RDB_type structure for the new array type, or NULL if the creation failed.

References RDB_alloc().

RDB_type* RDB_new_relation_type ( int  attrc,
const RDB_attr  attrv[],
RDB_exec_context *  ecp 
)

Creates a RDB_type struct for a relation type and returns a pointer to it. The attributes are specified by attrc and attrv. The fields defaultp and options of RDB_attr are ignored.

Returns

On success, a pointer to the RDB_type struct. On failure, NULL is returned.

Errors:
invalid_argument_error
attrv contains two attributes with the same name.

The call may also fail for a system error.

References RDB_new_relation_type_from_base(), and RDB_new_tuple_type().

Referenced by RDB_copy_obj_data(), RDB_create_public_table(), RDB_create_table(), and RDB_init_table().

RDB_type* RDB_new_relation_type_from_base ( RDB_type tpltyp,
RDB_exec_context *  ecp 
)

Creates a RDB_type struct for a relation type from a tuple type.

Returns

On success, a pointer to the RDB_type struct. On failure, NULL is returned.

Errors:

The call may fail for a system error.

References RDB_alloc().

Referenced by RDB_new_relation_type().

RDB_type* RDB_new_scalar_type ( const char *  name,
RDB_int  ireplen,
RDB_bool  sysimpl,
RDB_bool  ordered,
RDB_exec_context *  ecp 
)

Create a RDB_type struct for a scalar type and returns a pointer to it.

References RDB_alloc(), RDB_free(), and RDB_raise_no_memory().

RDB_type* RDB_new_tuple_type ( int  attrc,
const RDB_attr  attrv[],
RDB_exec_context *  ecp 
)

Creates a RDB_type struct for a tuple type and returns a pointer to it. The attributes are specified by attrc and attrv. The fields defaultp and options of RDB_attr are ignored.

Returns

A pointer to the RDB_type struct, or NULL if an error occured.

Errors:
invalid_argument_error
attrv contains two attributes with the same name.

The call may also fail for a system error.

References RDB_attr::name, RDB_alloc(), RDB_del_nonscalar_type(), RDB_dup_nonscalar_type(), RDB_free(), RDB_raise_invalid_argument(), RDB_raise_no_memory(), RDB_type_is_scalar(), and RDB_attr::typ.

Referenced by RDB_dup_nonscalar_type(), RDB_implement_type(), and RDB_new_relation_type().

void RDB_set_cleanup ( RDB_type typ,
RDB_obj_cleanup_func *  cleanup_fp 
)

Sets a function which is invoked when an RDB_object with this type is destroyed

RDB_bool RDB_share_subtype ( const RDB_type typ1,
const RDB_type typ2 
)

Determines if there is a type which is a subtype of both *typ1 and *typ2.

References RDB_is_subtype(), RDB_share_subtype(), and RDB_type_is_scalar().

Referenced by RDB_share_subtype().

RDB_attr* RDB_type_attrs ( RDB_type typ,
int *  attrcp 
)

RDB_type_attrs returns a pointer to an array of RDB_attr structs describing the attributes of the tuple or relation type specified by *typ and stores the number of attributes in attrcp.

The pointer returned must no longer be used if the RDB_type structure has been destroyed.

Returns

A pointer to an array of RDB_attr structs or NULL if the type is not a tuple or relation type.

Referenced by RDB_table_attrs().

RDB_bool RDB_type_depends_type ( const RDB_type typ,
const RDB_type dtyp 
)

Determines if *typ depends on *dtyp.

References RDB_is_subtype(), and RDB_type_depends_type().

Referenced by RDB_type_depends_type().

RDB_bool RDB_type_equals ( const RDB_type typ1,
const RDB_type typ2 
)

Check if two types are equal.

Nonscalar types are equal if their definition is the same.

Returns

RDB_TRUE if the types are equal, RDB_FALSE otherwise.

References RDB_type_equals().

Referenced by RDB_is_subtype(), RDB_map_public_table(), RDB_obj_property(), RDB_obj_set_property(), RDB_subset(), and RDB_type_equals().

RDB_bool RDB_type_has_possreps ( const RDB_type typ)

Check if a type is a scalar type with possreps.

RDB_bool RDB_type_is_array ( const RDB_type typ)

Checks if a type is an array type.

Returns
RDB_TRUE if *typ is an array type, RDB_FALSE if not.

Referenced by RDB_is_array().

RDB_bool RDB_type_is_numeric ( const RDB_type typ)

Check if a type is numeric.

Returns
RDB_TRUE if the type is integer or float, RDB_FALSE otherwise.

Referenced by RDB_avg().

RDB_bool RDB_type_is_ordered ( const RDB_type typ)

Determines if a scalar type is ordered.

Returns
RDB_TRUE if *typ is a scalar ordered type, RDB_FALSE otherwise.

References RDB_type_is_scalar().

Referenced by RDB_drop_type(), RDB_get_type(), RDB_implement_type(), RDB_table_to_array(), and RDB_type_is_valid().

RDB_bool RDB_type_is_relation ( const RDB_type typ)

Checks if a type is a relation type.

Returns

RDB_TRUE if *typ is a relation type, RDB_FALSE if not.

Referenced by RDB_obj_property(), and RDB_set_init_value().

RDB_bool RDB_type_is_scalar ( const RDB_type typ)

RDB_type_is_scalar checks if a type is scalar.

Returns

RDB_TRUE if *typ is scalar, RDB_FALSE if not.

Referenced by RDB_define_subtype(), RDB_del_nonscalar_type(), RDB_destroy_obj(), RDB_drop_typeimpl_ops(), RDB_irep_to_obj(), RDB_new_tuple_type(), RDB_obj_property(), RDB_obj_set_typeinfo(), RDB_share_subtype(), and RDB_type_is_ordered().

RDB_bool RDB_type_is_tuple ( const RDB_type typ)

Checks if a type is a tuple type.

Returns

RDB_TRUE if *typ is a tuple type, RDB_FALSE if not.

Referenced by RDB_is_tuple().

RDB_bool RDB_type_is_valid ( const RDB_type typ)

Determines if a type is valid, that is, if it can be used for declaring variables. A scalar type is valid if it is implemented (either a built-in type or a user-defined type on which RDB_implement_type() has been called successfully). A non-scalar type is valid if its base/attribute types are valid.

Returns
RDB_TRUE if the type is valid, RDB_FALSE otherwise.

References RDB_type_is_ordered(), and RDB_type_is_valid().

Referenced by RDB_type_is_valid().

char* RDB_type_name ( const RDB_type typ)

Returns the name of a type.

Returns

A pointer to the name of the type or NULL if the type has no name.

Referenced by Duro_print_error_f(), RDB_define_subtype(), and RDB_drop_type().

RDB_possrep* RDB_type_possreps ( const RDB_type typ,
int *  possrepcp 
)

Returns a pointer to the possible represenations of a scalar type.

RDB_attr* RDB_type_property ( const RDB_type typ,
const char *  propname 
)

Return a pointer to the RDB_attr structure describing a property, or NULL if the property does not exist