DuroDBMS API  0.17
Data Structures | Functions
Scalar and generic functions

Data Structures

struct  RDB_ma_insert
struct  RDB_ma_update
struct  RDB_ma_delete

Functions

RDB_int RDB_multi_assign (int insc, const RDB_ma_insert insv[], int updc, const RDB_ma_update updv[], int delc, const RDB_ma_delete delv[], int copyc, const RDB_ma_copy copyv[], RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_copy_obj (RDB_object *dstvalp, const RDB_object *srcvalp, RDB_exec_context *ecp)
int RDB_insert (RDB_object *tbp, const RDB_object *objp, RDB_exec_context *ecp, RDB_transaction *txp)
RDB_int RDB_update (RDB_object *tbp, RDB_expression *condp, int updc, const RDB_attr_update updv[], RDB_exec_context *ecp, RDB_transaction *txp)
RDB_int RDB_delete (RDB_object *tbp, RDB_expression *condp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_apply_constraints (int insc, const RDB_ma_insert insv[], int updc, const RDB_ma_update updv[], int delc, const RDB_ma_delete delv[], int copyc, const RDB_ma_copy copyv[], RDB_apply_constraint_fn *applyfnp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_obj_equals (const RDB_object *val1p, const RDB_object *val2p, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resp)
void RDB_init_obj (RDB_object *valp)
int RDB_destroy_obj (RDB_object *objp, RDB_exec_context *ecp)
void RDB_bool_to_obj (RDB_object *valp, RDB_bool v)
void RDB_int_to_obj (RDB_object *valp, RDB_int v)
void RDB_float_to_obj (RDB_object *valp, RDB_float v)
int RDB_string_to_obj (RDB_object *valp, const char *str, RDB_exec_context *ecp)
int RDB_string_n_to_obj (RDB_object *valp, const char *str, size_t n, RDB_exec_context *ecp)
int RDB_append_string (RDB_object *objp, const char *str, RDB_exec_context *ecp)
int RDB_obj_comp (const RDB_object *valp, const char *compname, RDB_object *compvalp, RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_obj_set_comp (RDB_object *valp, const char *compname, const RDB_object *compvalp, RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp)
RDB_bool RDB_obj_bool (const RDB_object *valp)
RDB_int RDB_obj_int (const RDB_object *valp)
RDB_float RDB_obj_float (const RDB_object *valp)
char * RDB_obj_string (const RDB_object *valp)
int RDB_binary_set (RDB_object *valp, size_t pos, const void *srcp, size_t len, RDB_exec_context *ecp)
int RDB_binary_get (const RDB_object *objp, size_t pos, size_t len, RDB_exec_context *ecp, void **pp, size_t *alenp)
size_t RDB_binary_length (const RDB_object *objp)
int RDB_binary_resize (RDB_object *objp, size_t len, RDB_exec_context *ecp)
RDB_type * RDB_obj_type (const RDB_object *objp)
void RDB_obj_set_typeinfo (RDB_object *objp, RDB_type *typ)

Function Documentation

int RDB_append_string ( RDB_object *  objp,
const char *  str,
RDB_exec_context *  ecp 
)

Append the string str to *objp.

objp must be of type string.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:

The call may fail for a system error.

int RDB_apply_constraints ( int  insc,
const RDB_ma_insert  insv[],
int  updc,
const RDB_ma_update  updv[],
int  delc,
const RDB_ma_delete  delv[],
int  copyc,
const RDB_ma_copy  copyv[],
RDB_apply_constraint_fn *  applyfnp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Get expressions that would have been evaluated by an invocation of RDB_multi_assign() and invoke *applyfn with the optimized expression as argument. Stop if the invocation returns a value different from RDB_OK.

int RDB_binary_get ( const RDB_object *  objp,
size_t  pos,
size_t  len,
RDB_exec_context *  ecp,
void **  pp,
size_t *  alenp 
)

RDB_binary_get obtains a pointer to len bytes starting at position pos of the RDB_object pointed to by valp and stores this pointer at the location pointed to by pp. If the sum of pos and len exceeds the length of the object, the length of the byte block will be lower than requested.

If alenp is not NULL, the actual length of the byte block is stored at the location pointed to by alenp.

valp must point to a RDB_object of type BINARY.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:

The call may fail for a system error.

size_t RDB_binary_length ( const RDB_object *  objp)

RDB_binary_length returns the number of bytes stored in the RDB_object pointed to by objp. The RDB_object must be of type BINARY.

Returns:

The length of the RDB_object.

int RDB_binary_resize ( RDB_object *  objp,
size_t  len,
RDB_exec_context *  ecp 
)

RDB_binary_resize sets the returns the number of bytes stored in the RDB_object pointed to by objp to len. If len is greater than the original length, the value of the bytes added is undefined.

Returns:

The length of the RDB_object.

int RDB_binary_set ( RDB_object *  valp,
size_t  pos,
const void *  srcp,
size_t  len,
RDB_exec_context *  ecp 
)

RDB_binary_set copies len bytes from srcp to the position pos in the RDB_object pointed to by valp. valp must point either to a new initialized RDB_object or to a RDB_object of type BINARY.

If an error occurs, an error value is left in *ecp.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:

The call may fail for a system error.

void RDB_bool_to_obj ( RDB_object *  valp,
RDB_bool  v 
)

RDB_bool_to_obj sets the RDB_object pointed to by valp to the boolean value specified by v.

The RDB_object must either be newly initialized or of type BOOLEAN.

int RDB_copy_obj ( RDB_object *  dstvalp,
const RDB_object *  srcvalp,
RDB_exec_context *  ecp 
)

RDB_copy_obj copies the value of the RDB_object pointed to by srcvalp to the RDB_object pointed to by dstvalp.

The source RDB_object must either be newly initialized or of the same type as the destination.

If both the source and the target are a table, the tuples are copied from the source to the target. In this case, both tables must be local, because otherwise a transaction would be required. RDB_copy_table() or RDB_multi_assign() can be used to copy global tables.

Currently, RDB_copy_obj is not supported for targets which hold a virtual table.

If an error occurs, an error value is left in *ecp.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
rdb_type_mismatch_error
*dstvalp is not newly initialized and its type does not match the type of the RDB_object specified by srcvalp.

The call may also fail for a system error.

RDB_int RDB_delete ( RDB_object *  tbp,
RDB_expression *  condp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_delete deletes all tuples from the table specified by tbp for which the expression specified by exp evaluates to true. If exp is NULL, all tuples are deleted.

If an error occurs, an error value is left in *ecp.

Currently, RDB_delete is not supported for virtual tables except PROJECT, WHERE, RENAME, and EXTEND.

Returns:

The number of deleted tuples, if no error occurred. A call which did not delete any tuple because no tuple matched the condition is considered a successful call and returns zero. If an error occurred, (RDB_int)RDB_ERROR is returned.

Errors:
no_running_tx_error
txp does not point to a running transaction.
invalid_argument_error
exp refers to an attribute which does not exist in the table.
predicate_violation_error
Deleting the tuples would result in a table which violates its predicate.
operator_not_found_error
The definition of the table specified by tbp refers to a non-existing operator. The expression specified by exp refers to a non-existing operator.
not_supported_error
RDB_delete is not supported for this type of table.

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

int RDB_destroy_obj ( RDB_object *  objp,
RDB_exec_context *  ecp 
)

RDB_destroy_obj releases all resources associated with a RDB_object structure.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

void RDB_float_to_obj ( RDB_object *  valp,
RDB_float  v 
)

RDB_float_to_obj sets the RDB_object pointed to by valp to the RDB_float value specified by v.

The RDB_object must either be newly initialized or of type FLOAT.

void RDB_init_obj ( RDB_object *  valp)

RDB_init_obj initializes the RDB_object structure pointed to by valp. RDB_init_obj must be called before any other operation can be performed on a RDB_object variable.

int RDB_insert ( RDB_object *  tbp,
const RDB_object *  objp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_insert inserts the tuple or relation specified by objp into the table specified by tbp.

If an error occurs, an error value is left in *ecp.

Currently, RDB_insert is not supported for virtual tables which are the result of a UNION, MINUS, SEMIMINUS, INTERSECT, JOIN, SEMIJOIN, SUMMARIZE, DIVIDE, GROUP, or UNGROUP.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
The table given by tbp is global and *txp is not a running transaction.
invalid_argument_error
A table attribute is missing in the tuple and no default value was specified for that attribute.
element_exist_error
The tuple was already an element of the table.
key_violation_error
Inserting the tuple would result in a table which contains a key value twice.
predicate_violation_error
Inserting the tuple would result in a table which violates its predicate.
type_mismatch_error
The type of a tuple attribute does not match the type of the corresponding table attribute.
operator_not_found_error
The definition of *tbp refers to a non-existing operator.
not_supported_error
RDB_insert is not supported for this type of table.

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

void RDB_int_to_obj ( RDB_object *  valp,
RDB_int  v 
)

RDB_int_to_obj sets the RDB_object pointed to by valp to the integer value specified by v.

The RDB_object must either be newly initialized or of type INTEGER.

RDB_int RDB_multi_assign ( int  insc,
const RDB_ma_insert  insv[],
int  updc,
const RDB_ma_update  updv[],
int  delc,
const RDB_ma_delete  delv[],
int  copyc,
const RDB_ma_copy  copyv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Perform a number of insert, update, delete, and copy operations in a single call.

For each of the RDB_ma_insert elements given by insc and insv, the tuple or relation *insv[i]->objp is inserted into *insv[i]->tbp.

For each of the RDB_ma_update elements given by updc and updv, the attributes given by updv[i]->updc and updv[i]->updv of the tuples of *updv[i]->tbp for which *updv[i]->condp evaluates to RDB_TRUE are updated.

For each of the RDB_ma_delete elements given by delc and delv, the tuples for which *delv[i]->condp evaluates to RDB_TRUE are deleted from *delv[i]->tbp.

For each of the RDB_ma_copy elements given by copyc and copyv, copyv[i]->scrp is copied to *copyv[i]->dstp.

A RDB_multi_assign call is atomic with respect to constraint checking; a constraint violation error can only occur if the result of all operations violates a constraint.

A table may not appear twice as a target in the arguments to RDB_multi_assign(), and it may not appear as a source if it appears as a target in a previous assignment.

This means that an assignment like the following:

UPDATE S WHERE S# = S#('S2') STATUS := 15, UPDATE S WHERE S# = S#('S3') STATUS := 25;

(taken from TTM, chapter 6) cannot be performed directly. It can, however, be converted to an equivalent form like the following:

UPDATE S WHERE (S# = S#('S2')) OR (S# = S#('S3')) STATUS := IF (S# = S#('S2')) THEN 15 ELSE 25;

The restrictions of RDB_insert(), RDB_update(), RDB_delete(), and RDB_copy_obj() regarding virtual target tables apply to RDB_multi_assign, too.

txp must point to a running transaction if a persistent table is involved.

Returns:

On success, the number of tuples inserted, deleted, and updated due to insc, insv, updc, updv, delc and delv arguments, plus objc. If an error occurred, (RDB_int) RDB_ERROR is returned.

Errors:
no_running_tx_error
txp must point to a running transaction (see above) but does not.
invalid_argument_error
A table appears twice as a target.
not_supported_error
A table is both source and target. A virtual table appears as a target in copyv.
predicate_violation_error
A constraint has been violated.

The errors that can be raised by RDB_insert(), RDB_update(), RDB_delete() and RDB_copy_obj() can also be raised.

RDB_bool RDB_obj_bool ( const RDB_object *  valp)

RDB_obj_bool returns the value of the RDB_object pointed to by valp as a RDB_bool. The RDB_object must be of type BOOLEAN.

Returns:

The value of the RDB_object.

int RDB_obj_comp ( const RDB_object *  valp,
const char *  compname,
RDB_object *  compvalp,
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_obj_comp copies the value of component compname of a possible representation of the variable pointed to by valp to the variable pointed to by comp.

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

If an error occurs, an error value is left in *ecp.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
invalid_argument_error
The type of *valp is not scalar, or it does not have a possible representation with a component compname.
operator_not_found_error
The getter method for component compname has not been created.

RDB_obj_comp may also raise an error raised by a user-provided getter function.

The call may also fail for a system error.

int RDB_obj_equals ( const RDB_object *  val1p,
const RDB_object *  val2p,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resp 
)

RDB_obj_equals checks two RDB_object variables for equality and stores the result in the variable pointed to by resp.

If an error occurs, an error value is left in *ecp.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

RDB_float RDB_obj_float ( const RDB_object *  valp)

RDB_obj_float returns the value of the RDB_object pointed to by valp as a RDB_float. The RDB_object must be of type FLOAT.

Returns:

The value of the RDB_object.

RDB_int RDB_obj_int ( const RDB_object *  valp)

RDB_obj_int returns the value of the RDB_object pointed to by valp as a RDB_int. The RDB_object must be of type INTEGER.

Returns:

The value of the RDB_object.

int RDB_obj_set_comp ( RDB_object *  valp,
const char *  compname,
const RDB_object *  compvalp,
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_obj_set_comp sets the the value of component compname of a possible representation of the RDB_object specified to by valp to the value of the variable pointed to by comp.

The RDB_object must be of a type which has a component compname.

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

If an error occurs, an error value is left in *ecp.

Returns:

RDB_OK on success, RDB_ERROR if an error occurred.

void RDB_obj_set_typeinfo ( RDB_object *  objp,
RDB_type *  typ 
)

Set the type information for *objp. This should be used only for tuples and arrays, which, unlike scalars and tables, do not to carry explicit type information by default. The caller must manage the type; it is not automatically destroyed when *objp is destroyed (except if *objp is embedded in an expression, in which case the expression takes responsibility for destroying the type).

char* RDB_obj_string ( const RDB_object *  valp)

RDB_obj_string returns a pointer to the value of the RDB_object pointed to by valp as a char *. The RDB_object must be of type string.

Returns:

The string value of the RDB_object.

RDB_type* RDB_obj_type ( const RDB_object *  objp)

RDB_obj_type returns a pointer to the type of *objp.

Returns:

A pointer to the type of the RDB_object.

int RDB_string_n_to_obj ( RDB_object *  valp,
const char *  str,
size_t  n,
RDB_exec_context *  ecp 
)

Set *valp to the string that begins at str limited to a length of n bytes. valp must either be newly initialized or of type STRING.

int RDB_string_to_obj ( RDB_object *  valp,
const char *  str,
RDB_exec_context *  ecp 
)

RDB_string_to_obj sets the RDB_object pointed to by valp to the string value specified by str.

The RDB_object must either be newly initialized or of type STRING.

RDB_int RDB_update ( RDB_object *  tbp,
RDB_expression *  condp,
int  updc,
const RDB_attr_update  updv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_update updates all tuples from the table specified by tbp for which the expression specified by exp evaluates to true. If exp is NULL, all tuples are updated.

If an error occurs, an error value is left in *ecp.

The attributes to be updated are specified by the updv array. The attribute specified by the field name is set to the value obtained by evaluating the expression specified by the field exp.

Currently, RDB_update is not supported for virtual tables except PROJECT.

Returns:

The number of updated tuples in real tables if the call was successful. A call which did not modify any tuple because no tuple matched the condition is considered a successful call and returns zero. If an error occurred, (RDB_int)RDB_ERROR is returned.

Errors:
no_running_tx_error

txp does not point to a running transaction.

name_error

One of the attributes in updv does not exist in the table. One of the expressions specified in updv refers to an attribute which does not exist in the table.

element_exist_error

The update operation would update a tuple so that it would be equal to a tuple which is already an element of the table.

key_violation_error

The update operation would result in a table which contains a key value twice.

predicate_violation_error

The update operation would result in a table which violates its predicate.

type_mismatch_error

The type of one of the expressions in updv is not the same as the type of the corresponding table attribute.

operator_not_found_error

The definition of the table specified by tbp refers to a non-existing operator. The expression specified by exp refers to a non-existing operator. One of the expressions specified in updv refers to a non-existing operator.

not_supported_error
RDB_update is not supported for this type of table.

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