DuroDBMS API  1.7
Functions
Type implementation functions

Functions

void * RDB_obj_irep (RDB_object *valp, size_t *lenp)
 
int RDB_irep_to_obj (RDB_object *valp, RDB_type *typ, const void *datap, size_t len, RDB_exec_context *ecp)
 
int RDB_implement_type (const char *name, RDB_type *arep, RDB_int areplen, RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_bool RDB_is_getter (const RDB_operator *op)
 
RDB_bool RDB_is_setter (const RDB_operator *op)
 
RDB_bool RDB_is_comparer (const RDB_operator *op)
 
int RDB_drop_typeimpl_ops (const RDB_type *typ, RDB_exec_context *ecp, RDB_transaction *txp)
 

Detailed Description

#include <rel/typeimpl.h>

Function Documentation

◆ RDB_drop_typeimpl_ops()

int RDB_drop_typeimpl_ops ( const RDB_type typ,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Deletes selector, getter, and setter operators.

References RDB_type_is_scalar().

◆ RDB_implement_type()

int RDB_implement_type ( const char *  name,
RDB_type arep,
RDB_int  areplen,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Implements the user-defined type with name name. The type must have been defined previously using RDB_define_type(). After RDB_implement_type was inkoved successfully, this type may be used for local variables and table attributes.

If arep is not NULL, it must point to a type which is used as the physical representation. The getter, setter, and selector operators must be provided by the caller.

If arep is NULL and areplen is not RDB_SYS_REP, areplen specifies the length, in bytes, of the physical representation, which then is a fixed-length array of bytes. The getter, setter, and selector operators must be provided by the caller. RDB_irep_to_obj() can be used by the selector to assign a value to an RDB_object. RDB_obj_irep() can be used by setters and getters to access the actual representation.

If arep is NULL and areplen is RDB_SYS_REP, the getter and setter operators and the selector operator are provided by Duro. In this case, the type must have exactly one possible representation. If this representation has exactly one component, the type of this component will become the physical representation. Otherwise the type will be represented by a tuple type with one attribute for each component.

For user-provided setters, getters, and selectors, the following conventions apply:

Selectors
A selector is a read-only operator whose name is is the name of a possible representation. It takes one argument for each component.
Getters
A getter is a read-only operator whose name consists of the type and a component name, separated by RDB_GETTER_INFIX (_get_). It takes one argument. The argument must be of the user-defined type in question. The return type must be the component type.
Setters
A setter is an update operator whose name consists of the type and a component name, separated by RDB_SETTER_INFIX (_set_). It takes two arguments. The first argument is an update argument and must be of the user-defined type in question. The second argument is read-only and must be of the type of the component.

If the type is ordered, a user-defined comparison operator returning an integer may be supplied. The comparison operator must be a read-only operator whose name consists of the type name and RDB_COMPARER_SUFFIX (_cmp). It takes two arguments, both of the user-defined type in question.

It must return a value lower than, equal to, or greater than zero if the first argument is lower than, equal to, or greater than the second argument, respectively.

If the operator has been defined, it will be called by the built-in comparison operators =, <>, <= etc.

If the operator has not been provided for an ordered type that has only one possible representation consisting of components of ordered types, the built-in comparison operators =, <>, <= are implemented by DuroDBMS based on that possible representation. Otherwise, if the type is ordered but does not have only one possible representation consisting of components of ordered types, the comparison operator must be provided.

Invoking comparison operators on user-implemented types may fail when there is no running transaction because a running transaction may be required to access the user-defined property getter operator.

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.
not_found_error
The type has not been previously defined.
invalid_argument_error
arep is NULL and areplen is RDB_SYS_REP, and the type was defined with more than one possible representation.

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

References RDB_tx_is_running().

◆ RDB_irep_to_obj()

int RDB_irep_to_obj ( RDB_object *  valp,
RDB_type typ,
const void *  datap,
size_t  len,
RDB_exec_context *  ecp 
)

Initializes the value pointed to by valp with the internal representation given by datap and len.

len The length of the internal represenation in bytes. datap A pointer to the internal representation. If datap is NULL, len bytes are allocated but the internal representation is undefined.

Returns

RDB_OK on success, RDB_ERROR on failure.

References RDB_destroy_obj(), RDB_init_obj(), and RDB_type_is_scalar().

◆ RDB_is_comparer()

RDB_bool RDB_is_comparer ( const RDB_operator *  op)

Determines if the operator *op is a comparison operator returning int.

◆ RDB_is_getter()

RDB_bool RDB_is_getter ( const RDB_operator *  op)

Determines if the operator *op is a getter operator.

◆ RDB_is_setter()

RDB_bool RDB_is_setter ( const RDB_operator *  op)

Determines if the operator *op is a setter operator.

◆ RDB_obj_irep()

void* RDB_obj_irep ( RDB_object *  valp,
size_t *  lenp 
)

RDB_obj_irep returns a pointer to the binary internal representation of the variable specified by valp. If lenp is not NULL, the size of the internal representation is stored at the location pointed to by lenp.

RDB_obj_irep only works for types with a binary internal representation. These are built-in scalar types and user-defined types which use a built-in scalar type or a byte array as physical representation.

Returns

A pointer to the internal representation.