Table functions


Data Structures

struct  RDB_attr
struct  RDB_string_vec
struct  RDB_ma_insert
struct  RDB_ma_update
struct  RDB_ma_delete

Functions

RDB_objectRDB_create_table (const char *name, int attrc, const RDB_attr heading[], int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp, RDB_transaction *txp)
RDB_objectRDB_create_table_from_type (const char *name, RDB_type *reltyp, int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp, RDB_transaction *txp)
RDB_objectRDB_get_table (const char *name, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_drop_table (RDB_object *tbp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_set_table_name (RDB_object *tbp, const char *name, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_add_table (RDB_object *tbp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_init_table_from_type (RDB_object *tbp, const char *name, RDB_type *reltyp, int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp)
int RDB_init_table (RDB_object *tbp, const char *name, int attrc, const RDB_attr attrv[], int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp)
int RDB_table_keys (RDB_object *tbp, RDB_exec_context *ecp, RDB_string_vec **keyvp)
char * RDB_table_name (const RDB_object *tbp)
int RDB_copy_table (RDB_object *dstp, RDB_object *srcp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_all (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
int RDB_any (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
int RDB_max (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
int RDB_min (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
int RDB_sum (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
int RDB_avg (RDB_object *tbp, const char *attrname, RDB_exec_context *ecp, RDB_transaction *txp, RDB_float *resultp)
int RDB_extract_tuple (RDB_object *tbp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *tplp)
RDB_bool RDB_table_is_persistent (const RDB_object *tbp)
RDB_bool RDB_table_is_real (const RDB_object *tbp)
int RDB_table_is_empty (RDB_object *tbp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
RDB_int RDB_cardinality (RDB_object *tbp, RDB_exec_context *ecp, RDB_transaction *txp)
int RDB_subset (RDB_object *tb1p, RDB_object *tb2p, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
RDB_objectRDB_expr_to_vtable (RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp)
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_table_contains (RDB_object *tbp, const RDB_object *tplp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)

Function Documentation

int RDB_add_table ( RDB_object tbp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_add_table adds the table specified by tbp to the database the transaction specified by txp interacts with.

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

If the table is a local (transient) table, it is made global (persistent).

The table must have a name.

Currently, RDB_add_table is not supported for local real tables.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_INVALID_ARGUMENT_ERROR
The table does not have a name.
RDB_ELEMENT_EXIST_ERROR
The table is already associated with the database.
RDB_NOT_SUPPORTED_ERROR
The table is a local real table.

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

int RDB_all ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_all computes a logical AND over the attribute attrname of the table specified by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be of type BOOLEAN.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not BOOLEAN.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.

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

int RDB_any ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_any computes a logical OR over the attribute attrname of the table specified by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be of type BOOLEAN.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not BOOLEAN.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.

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

int RDB_avg ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_float *  resultp 
)

RDB_avg computes the average over the attribute attrname of the table specified by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be numeric.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not numeric.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.
RDB_AGGREGATE_UNDEFINED_ERROR
The table is empty.

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

RDB_int RDB_cardinality ( RDB_object tbp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_cardinality returns the number of tuples in the table pointed to by tbp.

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

Returns:
On success, the number of tuples is returned. On failure, (RDB_int)RDB_ERROR is returned. (RDB_int)RDB_ERROR is guaranteed to be lower than zero.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of the table specified by tbp refers to a non-existing operator.

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

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.

int RDB_copy_table ( RDB_object dstp,
RDB_object srcp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_copy_table assigns the table specified by srcp to the value of the table specified by dstp. The two tables must have the same heading.

Currently, virtual target tables are not supported.

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

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_TYPE_MISMATCH_ERROR
The types of the two tables differ.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of the table specified by srcp refers to a non-existing operator.

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

RDB_object* RDB_create_table ( const char *  name,
int  attrc,
const RDB_attr  heading[],
int  keyc,
const RDB_string_vec  keyv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_create_table creates a persistent table with name name in the database the transaction *txp interacts with and returns a pointer to the newly created RDB_object structure.

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

The table will have attrc attributes. The individual attributes are specified by the elements of attrv.

The candidate keys for the table are specified by keyc and keyv.

At least one candidate key must be specified. A candidate key may not be a subset of another. If a single candidate key is specified, that key may be empty (not contain any attributes).

Passing a keyv of NULL is equivalent to specifiying a single key which consists of all attributes, that is, the table will become all-key.

To enforce the key constraints, Duro creates a unique hash index for each key.

Returns:
On success, a pointer to the newly created table is returned. If an error occurred, NULL is returned.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_TYPE_MISMATCH_ERROR
The type of a default value does not match the type of the corresponding attribute.
RDB_INVALID_ARGUMENT_ERROR
One or more of the arguments are incorrect. For example, a key attribute does not appear in attrv, etc.

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

RDB_object* RDB_create_table_from_type ( const char *  name,
RDB_type *  reltyp,
int  keyc,
const RDB_string_vec  keyv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_create_table_from_type acts like RDB_create_table(), except that it takes a RDB_type argument instead of attribute arguments. reltyp must be a relation type and will be managed by the table created.

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:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_INVALID_ARGUMENT_ERROR
exp refers to an attribute which does not exist in the table.
RDB_PREDICATE_VIOLATION_ERROR
Deleting the tuples would result in a table which violates its predicate.
RDB_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.
RDB_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_drop_table ( RDB_object tbp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_drop_table deletes the table specified by tbp and releases all resources associated with that table. If the table is virtual, its unnamed child tables are also deleted.

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

If the table is local, txp may be NULL.

Returns:
On success, RDB_OK is returned. On failure, RDB_ERROR is returned.

Errors:
RDB_NO_RUNNING_TX_ERROR
The table is global (persistent) and txp does not point to a running transaction.

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

RDB_object* RDB_expr_to_vtable ( RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_expr_to_vtable creates a virtual table from the expression *exp.

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

Returns:
A pointer to the newly created table, or NULL if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_INVALID_ARGUMENT_ERROR
*exp does not define a valid virtual table.
RDB_NAME_ERROR
*exp refers to an undefined attribute.
RDB_TYPE_MISMATCH_ERROR
*exp contains an operator invocation with an argument of a wrong type.
RDB_OPERATOR_NOT_FOUND_ERROR
*exp contains an invocation of a non-existing operator.

int RDB_extract_tuple ( RDB_object tbp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object tplp 
)

RDB_extract_tuple extracts a single tuple from a table which contains only one tuple and stores its value in the variable pointed to by tplp.

If an error occurs, the tuple value of the variable pointed to by tplp is undefined and an error value is left in *ecp.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NOT_FOUND_ERROR
The table is empty.
RDB_INVALID_ARGUMENT_ERROR
The table contains more than one tuple.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of the table specified by tbp refers to a non-existing operator.

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

RDB_object* RDB_get_table ( const char *  name,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_get_table looks up the global table with name name in the environment of the database the transaction specified by txp interacts with and returns a pointer to it.

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

Returns:
A pointer to the table, or NULL if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NOT_FOUND_ERROR
A table with the name name could not be found.

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

int RDB_init_table ( RDB_object tbp,
const char *  name,
int  attrc,
const RDB_attr  attrv[],
int  keyc,
const RDB_string_vec  keyv[],
RDB_exec_context *  ecp 
)

Turn *tbp into a transient table. tbp should have been initialized using RDB_init_obj().

For name, attrc, attrv, keyc, keyv, and ecp, the same rules apply as for RDB_create_table().

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_TYPE_MISMATCH_ERROR
The type of a default value does not match the type of the corresponding attribute.
RDB_INVALID_ARGUMENT_ERROR
One or more of the arguments are incorrect. For example, a key attribute does not appear in *attrv, etc.

The call may also fail for a system error.

int RDB_init_table_from_type ( RDB_object tbp,
const char *  name,
RDB_type *  reltyp,
int  keyc,
const RDB_string_vec  keyv[],
RDB_exec_context *  ecp 
)

Like RDB_init_table(), but uses a relation type instead of a RDB_type argument instead of attribute arguments.

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:
RDB_NO_RUNNING_TX_ERROR
The table given by tbp is global and *txp is not a running transaction.
RDB_INVALID_ARGUMENT_ERROR
A table attribute is missing in the tuple and no default value was specified for that attribute.
RDB_ELEMENT_EXIST_ERROR
The tuple was already an element of the table.
RDB_KEY_VIOLATION_ERROR
Inserting the tuple would result in a table which contains a key value twice.
RDB_PREDICATE_VIOLATION_ERROR
Inserting the tuple would result in a table which violates its predicate.
RDB_TYPE_MISMATCH_ERROR
The type of a tuple attribute does not match the type of the corresponding table attribute.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of *tbp refers to a non-existing operator.
RDB_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.

int RDB_max ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object resultp 
)

RDB_max computes the maximum over the attribute attrname of the table specified by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be numeric and the result is of the same type as the attribute.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not numeric.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.

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

int RDB_min ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object resultp 
)

RDB_min computes the minimum over the attribute attrname of the table specified by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be numeric and the result is of the same type as the attribute.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not numeric.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.

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

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:
RDB_NO_RUNNING_TX_ERROR
txp must point to a running transaction (see above) but does not.
RDB_INVALID_ARGUMENT_ERROR
A table appears twice as a target.
RDB_NOT_SUPPORTED_ERROR
A table is both source and target. A virtual table appears as a target in copyv.
RDB_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.

int RDB_set_table_name ( RDB_object tbp,
const char *  name,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

RDB_set_table_name sets the name of the table to name.

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

Returns:
On success, RDB_OK is returned. On failure, RDB_ERROR is returned.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_INVALID_ARGUMENT_ERROR
name is not a valid table name.

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

int RDB_subset ( RDB_object tb1p,
RDB_object tb2p,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_subset checks if the table specified by tb1p is a subset of the table specified by tb2p and stores the result at the location pointed to by resultp.

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

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_TYPE_MISMATCH_ERROR
The types of the two tables differ.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of one of the tables refers to a non-existing operator.

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

int RDB_sum ( RDB_object tbp,
const char *  attrname,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object resultp 
)

RDB_sum computes the sum over the attribute attrname of the table pointed to by tbp and stores the result at the location pointed to by resultp.

If the table has only one attribute, attrname may be NULL.

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

The attribute attrname must be numeric and the result is of the same type as the attribute.

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_NAME_ERROR
The table does not have an attribute attrname.
RDB_TYPE_MISMATCH_ERROR
The type of the attribute is not numeric.
RDB_INVALID_ARGUMENT_ERROR
attrname is NULL and the table has more than one attribute.

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

int RDB_table_contains ( RDB_object tbp,
const RDB_object tplp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_table_contains checks if the tuple specified by tplp is an element of the table specified by tbp and stores the result at the location pointed to by resultp.

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

Returns:
On success, RDB_OK is returned. If an error occurred, RDB_ERROR is returned.

Errors:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.
RDB_INVALID_ARGUMENT_ERROR
A table attribute is missing in the tuple.
RDB_TYPE_MISMATCH_ERROR
The type of a tuple attribute does not match the type of the corresponding table attribute.
RDB_OPERATOR_NOT_FOUND_ERROR
The definition of the table specified by tbp refers to a non-existing operator.

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

int RDB_table_is_empty ( RDB_object tbp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_table_is_empty checks if the table specified by tbp is empty and stores the result of the check at the location pointed to by resultp.

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

Returns:
RDB_OK on success, RDB_ERROR if an error occurred.

RDB_bool RDB_table_is_persistent ( const RDB_object tbp  ) 

RDB_table_is_persistent returns if the table *tbp is persistent.

Returns:
RDB_TRUE if *tbp is persistent, RDB_FALSE if it is transient.

RDB_bool RDB_table_is_real ( const RDB_object tbp  ) 

RDB_table_is_real returns if the table *tbp is real.

Returns:
RDB_TRUE if *tbp is real, RDB_FALSE if it is virtual.

char* RDB_table_name ( const RDB_object tbp  ) 

RDB_table_name returns a pointer to the name of a table.

Returns:
A pointer to the name of the table, or NULL if the table has no name.

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:
RDB_NO_RUNNING_TX_ERROR
txp does not point to a running transaction.

RDB_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.

RDB_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.

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

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

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

RDB_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.

RDB_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.


Generated on Tue Mar 11 23:48:15 2008 for Duro by  doxygen 1.5.1