DuroDBMS API  1.2
Data Structures | Typedefs | Functions
Operator functions

Data Structures

struct  RDB_parameter
 

Typedefs

typedef void RDB_op_cleanup_func (RDB_operator*)
 
typedef struct RDB_parameter RDB_parameter
 

Functions

RDB_parameterRDB_get_parameter (const RDB_operator*op, int idx)
 
const char * RDB_operator_name (const RDB_operator*op)
 
RDB_typeRDB_operator_type (const RDB_operator*op)
 
int RDB_operator_param_count (const RDB_operator*op)
 
RDB_typeRDB_return_type (const RDB_operator*op)
 
void * RDB_operator_u_data (const RDB_operator*op)
 
void RDB_set_operator_u_data (RDB_operator*op, void *u_data)
 
const char * RDB_operator_source (const RDB_operator*op)
 
RDB_object * RDB_operator_creation_time (RDB_operator*op)
 
void RDB_set_op_cleanup_fn (RDB_operator*op, RDB_op_cleanup_func *fp)
 
int RDB_create_ro_op (const char *name, int paramc, RDB_parameter paramv[], RDB_type *rtyp, const char *libname, const char *symname, const char *sourcep, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_create_ro_op_version (const char *name, const char *version, int paramc, RDB_parameter paramv[], RDB_type *rtyp, const char *libname, const char *symname, const char *sourcep, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_create_update_op (const char *name, int paramc, RDB_parameter paramv[], const char *libname, const char *symname, const char *sourcep, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_create_update_op_version (const char *name, const char *version, int paramc, RDB_parameter paramv[], const char *libname, const char *symname, const char *sourcep, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_call_ro_op_by_name (const char *name, int argc, RDB_object *argv[], RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *retvalp)
 
int RDB_call_ro_op_by_name_e (const char *name, int argc, RDB_object *argv[], RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *retvalp)
 
RDB_operator* RDB_get_update_op (const char *name, int argc, RDB_type *argtv[], RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_operator* RDB_get_update_op_by_args (const char *name, int argc, RDB_object *argv[], RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_call_update_op_by_name (const char *name, int argc, RDB_object *argv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_call_update_op (RDB_operator*op, int argc, RDB_object *argv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_drop_op (const char *opname, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_drop_op_version (const char *opname, const char *version, RDB_exec_context *ecp, RDB_transaction *txp)
 

Detailed Description

Typedef Documentation

typedef void RDB_op_cleanup_func(RDB_operator*)

A function which is called when an operator is deleted from memory.

typedef struct RDB_parameter RDB_parameter

Represents a parameter of an operator.

Function Documentation

int RDB_call_ro_op_by_name ( const char *  name,
int  argc,
RDB_object *  argv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  retvalp 
)

RDB_call_ro_op_by_name invokes the read-only operator with the name name, passing the arguments in argc and argv.

The result will be stored at the location pointed to by retvalp.

The arguments must carry type information.

Returns
RDB_OK on success, RDB_ERROR if an error occurred.
Errors:
no_running_tx_error
txp is not NULL and *txp is not a running transaction.
operator_not_found_error
A read-only operator that matches the name and argument types could not be found.
type_mismatch_error
A read-only operator that matches name could be found, but it does not match the argument types.
invalid_argument_error
An invalid argument was passed to the operator. One or more of the arguments is a table that does not exist. (e.g. after a rollback)

If txp is NULL, only built-in operators can be found.

If the user-supplied function which implements the function raises an error, this error is returned in *ecp.

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

References RDB_call_ro_op_by_name_e().

Referenced by RDB_obj_equals().

int RDB_call_ro_op_by_name_e ( const char *  name,
int  argc,
RDB_object *  argv[],
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  retvalp 
)

Same as RDB_call_ro_op_by_name() but with an additional argument envp. If txp is NULL and envp is not, envp is used to look up read-only operators from memory. If txp is not NULL, envp is ignored.

References RDB_bool_to_obj(), RDB_cardinality(), RDB_copy_obj(), RDB_destroy_obj(), RDB_init_obj(), RDB_int_to_obj(), RDB_is_selector(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_table_is_empty().

Referenced by RDB_call_ro_op_by_name(), and RDB_obj_property().

int RDB_call_update_op ( RDB_operator*  op,
int  argc,
RDB_object *  argv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Calls the update operator *op, passing the arguments in argc and argv.

Returns
RDB_OK on success, RDB_ERROR if an error occurred.

If the user-supplied function which implements the operator raises an error, this error is returned in *ecp.

References RDB_raise_operator_not_found().

Referenced by RDB_call_update_op_by_name(), and RDB_obj_set_property().

int RDB_call_update_op_by_name ( const char *  name,
int  argc,
RDB_object *  argv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Invokes the update operator with the name name, passing the arguments in argc and argv.

The arguments must carry type information.

Returns
RDB_OK on success, RDB_ERROR if an error occurred.
Errors:
no_running_tx_error
*txp is not a running transaction.
operator_not_found_error
An update operator that matches the name and arguments could not be found.
invalid_argument_error
One or more of the arguments is a table that does not exist. (e.g. after a rollback)

If the user-supplied function which implements the operator raises an error, this error is returned in *ecp.

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

References RDB_call_update_op(), RDB_get_err(), RDB_get_update_op_by_args(), RDB_obj_type(), and RDB_raise_operator_not_found().

int RDB_create_ro_op ( const char *  name,
int  paramc,
RDB_parameter  paramv[],
RDB_type rtyp,
const char *  libname,
const char *  symname,
const char *  sourcep,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Creates a read-only operator.

To execute the operator, DuroDBMS will execute the function specified by symname from the library specified by libname.

The name of the library must be passed without the file extension.

The function must have the following signature:

int
<sym>(int argc, RDB_object *argv[], RDB_operator *op,
          RDB_exec_context *ecp, RDB_transaction *txp,
          RDB_object *retvalp)

When the function is executed, the operator is passed through op and the arguments are passed through argc and argv.

The function specified by symname must store the result at the location specified by retvalp and return RDB_OK. It can indicate an error condition by storing an error in *ecp (see RDB_raise_err()) and returning RDB_ERROR.

The return type is passed through rtyp.

sourcep may be NULL or a pointer to the source code implementing the operator.

Overloading operators is possible.

Returns
RDB_OK on success, RDB_ERROR if an error occurred.
Parameters
namethe name of the operator.
paramcthe number of parameters.
paramvthe parameters. paramv[i].typ will become the type of the i-th parameter. The update field is ignored.
rtypthe return type.
libnamethe name of a library containing the function which implements the operator.
symnamethe name of the C function which implements the operator.
sourcepa pointer to the source code, if the operator is executed by an interpreter.
ecpa pointer to a RDB_exec_context used to return error information.
txpthe transaction which is used to write to the catalog.
Errors:
no_running_tx_error
*txp is not a running transaction.
element_exists_error
A read-only operator with this name and signature does already exist.

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

References RDB_create_ro_op_version().

int RDB_create_ro_op_version ( const char *  name,
const char *  version,
int  paramc,
RDB_parameter  paramv[],
RDB_type rtyp,
const char *  libname,
const char *  symname,
const char *  sourcep,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Like RDB_create_ro_op, but creates a read-only operator with a version name.

Parameters
versionthe operator version. If it is NULL, the operator is created without a version name.

References RDB_alloc(), RDB_destroy_obj(), RDB_free(), RDB_get_err(), RDB_init_obj(), RDB_insert(), RDB_obj_type(), RDB_raise_element_exists(), RDB_raise_no_running_tx(), RDB_tuple_set(), RDB_tuple_set_string(), RDB_tx_is_running(), and RDB_parameter::typ.

Referenced by RDB_create_ro_op().

int RDB_create_update_op ( const char *  name,
int  paramc,
RDB_parameter  paramv[],
const char *  libname,
const char *  symname,
const char *  sourcep,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_create_update_op creates an update operator.

To execute the operator, DuroDBMS will execute the function specified by symname from the library specified by libname.

The name of the library must be passed without the file extension.

This function must have the following signature:

int
<sym>(int argc, RDB_object *argv[], RDB_operator *op,
        RDB_exec_context *ecp, RDB_transaction *txp)

When the function is executed, the name of the operator is passed through name and the arguments are passed through argc and argv.

On success, the function specified by symname must return RDB_OK. It can indicate an error condition by leaving an error in *ecp (see RDB_raise_err() and related functions) and returning RDB_ERROR.

sourcep may be NULL or a pointer to the source code implementing the operator.

Overloading operators is possible.

Parameters
namethe name of the operator.
paramcthe number of parameters.
paramvthe parameters. paramv[i].typ will become the type of the i-th parameter. paramv[i].update specifies whether the argument is updated.
libnamethe name of a library containing the function which implements the operator.
symnamethe name of the C function which implements the operator.
sourcepa pointer to the source code, if the operator is executed by an interpreter.
ecpa pointer to a RDB_exec_context used to return error information.
txpthe transaction which is used to write to the catalog.
Returns
RDB_OK on success, RDB_ERROR if an error occurred.
Errors:
no_running_tx_error
*txp is not a running transaction.
element_exists_error
An update operator with this name and signature does already exist.

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

int RDB_drop_op ( const char *  opname,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Deletes all read-only operators with the name name, if at least one such operator exists. Otherwise, all update operators with the that name are deleted.

Returns
RDB_OK on success, RDB_ERROR if an error occurred.
Errors:
no_running_tx_error
*txp is not a running transaction.
operator_not_found_error
An operator with the specified name could not be found.

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

References RDB_raise_no_running_tx(), RDB_raise_operator_not_found(), and RDB_tx_is_running().

Referenced by RDB_drop_type(), and RDB_drop_typeimpl_ops().

RDB_parameter * RDB_get_parameter ( const RDB_operator*  op,
int  idx 
)

Returns the idx-th parameter of *op

RDB_operator* RDB_get_update_op ( const char *  name,
int  argc,
RDB_type argtv[],
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Returns a pointer to an update operator with the name name whose signature matches the parameter types given by argc and argtv. A value of NULL in argtv matches any type.

If txp is NULL, envp is used to look up the operator in memory. If txp is not NULL, envp is ignored.

Returns
a pointer to the update operator, or NULL if an error occurred, in which case *ecp carries the error information.
Errors:
invalid_argument_error
Both txp and envp are NULL.
operator_not_found_error
An update operator that matches the name and arguments could not be found.

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

References RDB_clear_err(), RDB_get_err(), RDB_obj_type(), RDB_raise_operator_not_found(), RDB_raise_type_mismatch(), and RDB_tx_db().

Referenced by RDB_obj_set_property().

RDB_operator* RDB_get_update_op_by_args ( const char *  name,
int  argc,
RDB_object *  argv[],
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Returns a pointer to the implemented update operator with the name name which matches the arguments given by argc and argv. A value of NULL in argtv matches any type.

If txp is NULL, envp is used to look up the operator in memory. If txp is not NULL, envp is ignored.

Returns
a pointer to the update operator, or NULL if an error occurred, in which case *ecp carries the error information.
Errors:
invalid_argument_error
Both txp and envp are NULL.
operator_not_found_error
An update operator that matches the name and arguments could not be found.

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

References RDB_clear_err(), RDB_get_err(), RDB_obj_type(), RDB_raise_operator_not_found(), RDB_raise_type_mismatch(), and RDB_tx_db().

Referenced by RDB_call_update_op_by_name().

RDB_object* RDB_operator_creation_time ( RDB_operator*  op)

Returns the time operator *op was created.

Returns
a pointer to the time the operator was created as an RDB_object of type datetime.
const char * RDB_operator_name ( const RDB_operator*  op)

Return the name of *op

Referenced by RDB_is_selector().

int RDB_operator_param_count ( const RDB_operator*  op)

Return number of parameters of operator *op.

const char * RDB_operator_source ( const RDB_operator*  op)

Returns the source code of operator *op.

Returns
a pointer to the source code, or NULL if no source code was specified when the operator was created.

References RDB_obj_string().

RDB_type* RDB_operator_type ( const RDB_operator*  op)

Returns the return type *op.

Returns
the return type, or NULL if the operator is an update operator.
RDB_type * RDB_return_type ( const RDB_operator*  op)

Return the return type of *op if it's a read-only operator. Return NULL if it's an update operator.

void RDB_set_op_cleanup_fn ( RDB_operator*  op,
RDB_op_cleanup_func fp 
)

Set function which is invoked when the *op is deleted from memory