DuroDBMS API  1.7
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

◆ RDB_op_cleanup_func

typedef void RDB_op_cleanup_func(RDB_operator *)

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

◆ RDB_parameter

typedef struct RDB_parameter RDB_parameter

Represents a parameter of an operator.

Function Documentation

◆ RDB_call_ro_op_by_name()

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().

◆ RDB_call_ro_op_by_name_e()

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.

Referenced by RDB_call_ro_op_by_name().

◆ RDB_call_update_op()

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.

◆ RDB_call_update_op_by_name()

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_get_err(), RDB_get_update_op_by_args(), and RDB_obj_type().

◆ RDB_create_ro_op()

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().

◆ 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_free(), and RDB_parameter::typ.

Referenced by RDB_create_ro_op().

◆ RDB_create_update_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.

◆ RDB_drop_op()

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_tx_is_running().

◆ RDB_get_parameter()

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

Returns the idx-th parameter of *op

◆ RDB_get_update_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_get_err(), RDB_obj_type(), and RDB_tx_db().

◆ RDB_get_update_op_by_args()

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_get_err(), RDB_obj_type(), and RDB_tx_db().

Referenced by RDB_call_update_op_by_name().

◆ RDB_operator_creation_time()

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.

◆ RDB_operator_name()

const char * RDB_operator_name ( const RDB_operator *  op)

Return the name of *op

◆ RDB_operator_param_count()

int RDB_operator_param_count ( const RDB_operator *  op)

Return number of parameters of operator *op.

◆ RDB_operator_source()

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_operator_type()

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_return_type()

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.

◆ RDB_set_op_cleanup_fn()

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

References RDB_alloc(), RDB_del_nonscalar_type(), RDB_destroy_obj(), RDB_dup_nonscalar_type(), RDB_free(), RDB_init_obj(), RDB_raise_no_memory(), and RDB_type_is_scalar().