DuroDBMS API  1.2
Data Structures | Functions
Table functions

Data Structures

struct  RDB_attr
 

Functions

int RDB_all (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
 
int RDB_any (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
 
int RDB_max (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
 
int RDB_min (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
 
int RDB_sum (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *resultp)
 
int RDB_avg (RDB_object *tbp, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_float *resultp)
 
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_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)
 
RDB_object * RDB_create_table (const char *name, int attrc, const RDB_attr attrv[], int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_object * RDB_create_table_from_type (const char *name, RDB_type *reltyp, int keyc, const RDB_string_vec keyv[], int default_attrc, const RDB_attr default_attrv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_object * RDB_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_drop_table_by_name (const char *tbname, 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_database *dbp, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_table_matching_tuple (RDB_object *tbp, const RDB_object *tplp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
 
int RDB_create_public_table_from_type (const char *name, RDB_type *reltyp, int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_create_public_table (const char *name, int attrc, const RDB_attr attrv[], int keyc, const RDB_string_vec keyv[], RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_map_public_table (const char *name, RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp)
 
RDB_int RDB_move_tuples (RDB_object *dstp, RDB_object *srcp, int flags, 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[], int default_attrc, const RDB_attr *default_attrv, 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)
 
const 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_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)
 
RDB_bool RDB_table_is_stored (const RDB_object *tbp)
 
RDB_bool RDB_table_is_user (const RDB_object *tbp)
 
int RDB_subset (RDB_object *tb1p, RDB_object *tb2p, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resultp)
 
RDB_attrRDB_table_attrs (const RDB_object *tbp, int *attrcp)
 
RDB_object * RDB_expr_to_vtable (RDB_expression *exp, RDB_exec_context *ecp, RDB_transaction *txp)
 

Detailed Description

#include <dli/parse.h>

Function Documentation

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

If dbp is not NULL, RDB_add_table adds the table *tbp to the database *dbp. If dbp is NULL, the table is added to the catalog and 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
no_running_tx_error
txp does not point to a running transaction.
invalid_argument_error
The table does not have a name.
element_exist_error
The table is already associated with the database.
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.

References RDB_raise_invalid_argument(), RDB_raise_no_running_tx(), RDB_raise_not_supported(), RDB_table_is_persistent(), RDB_tx_db(), and RDB_tx_is_running().

int RDB_all ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

RDB_all computes a logical OR over the expression exp of the table specified by tbp and stores the result at the location pointed to by resultp.

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

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

The type of *exp must be BOOLEAN.

Returns

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the attribute is not BOOLEAN.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_bool(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_var_ref().

int RDB_any ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resultp 
)

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

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

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

The type of *exp must be BOOLEAN.

Returns

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the expression is not BOOLEAN.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_bool(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_var_ref().

int RDB_avg ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_float *  resultp 
)

Computes the average over the expression exp of the table specified by tbp and stores the result at the location pointed to by resultp.

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

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

The type of *exp must be numeric.

Returns

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the attribute is not numeric.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)
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.

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_float(), RDB_obj_int(), RDB_obj_type(), RDB_raise_aggregate_undefined(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), RDB_type_is_numeric(), and RDB_var_ref().

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:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
operator_not_found_error
The definition of *tbp refers to a non-existing operator.
invalid_argument_error
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_add_arg(), RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_init_obj(), RDB_obj_int(), RDB_ro_op(), and RDB_table_ref().

Referenced by RDB_call_ro_op_by_name_e().

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:
no_running_tx_error
txp does not point to a running transaction.
type_mismatch_error
The types of the two tables differ.
operator_not_found_error
The definition of the table specified by srcp refers to a non-existing operator.
invalid_argument_error
*srcp or *dstp is a table that does not exist. (e.g. after a rollback)

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

References RDB_multi_assign().

int RDB_create_public_table ( const char *  name,
int  attrc,
const RDB_attr  attrv[],
int  keyc,
const RDB_string_vec  keyv[],
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Create a public table with name name. The table must be mapped to a relational expression before it can be used.

Returns

RDB_OK on success, RDB_ERROR on failure.

References RDB_del_nonscalar_type(), and RDB_new_relation_type().

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

Create a real table with name name in the database the transaction *txp interacts with and return a pointer to the newly created RDB_object structure which represents the table.

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. options is currently ignored, but should be set to zero for compatibility with future versions.

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

A candidate key must 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 be all-key.

To enforce the key constraints, DuroDBMS 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:
no_running_tx_error
txp does not point to a running transaction.
type_mismatch_error
The type of a default value does not match the type of the corresponding attribute.
invalid_argument_error
One or more of the arguments are incorrect. For example, a key attribute does not appear in attrv, etc.
element_exists_error
There is already a database table with name name.

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

References RDB_create_table_from_type(), and RDB_new_relation_type().

RDB_object* RDB_create_table_from_type ( const char *  name,
RDB_type reltyp,
int  keyc,
const RDB_string_vec  keyv[],
int  default_attrc,
const RDB_attr  default_attrv[],
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.

If default_attrc is greater than zero, default_attrv must point to an array of length default_attrc where name is the attribute name and defaultp points to the default value for that attribute. Entries with a defaultp of NULL are ignored. Other fields of RDB_attr are ignored, but options should be set to zero for compatibility with future versions.

References RDB_append_string(), RDB_destroy_obj(), RDB_init_obj(), RDB_obj_string(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_string_to_obj().

Referenced by RDB_create_table().

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.

References RDB_multi_assign().

Referenced by RDB_drop_constraint(), and RDB_drop_db().

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:
no_running_tx_error
The table is global (persistent) and txp does not point to a running transaction.
in_use_error
An existing virtual table depends on the table.
A constraint depends on the table.

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

References RDB_expr_refers(), RDB_raise_in_use(), RDB_raise_no_running_tx(), RDB_table_is_persistent(), and RDB_tx_is_running().

Referenced by RDB_drop_db(), RDB_drop_table_by_name(), RDB_get_dbs(), and RDB_map_public_table().

int RDB_drop_table_by_name ( const char *  tbname,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Drop table by name. This is currently the only way to drop a unmapped public table.

References RDB_drop_table(), and RDB_get_table().

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:
invalid_argument_error
*exp does not define a valid virtual table.
name_error
*exp refers to an undefined attribute.
type_mismatch_error
*exp contains an operator invocation with an argument of a wrong type.
operator_not_found_error
*exp contains an invocation of a non-existing operator.

References RDB_raise_no_memory().

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

Extracts a single tuple from table *tbp and stores its value in *tplp. *tbp must contain exactly one tuple.

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

If *tbp is persistent or its definition refers to a persistent table txp must be a running transaction.

Returns

RDB_OK on success, RDB_ERROR if an error occurred.

Errors:
no_running_tx_error
*tbp is persistent or refers to a persistent table and txp does not point to a running transaction.
not_found_error
The table is empty.
invalid_argument_error
The table contains more than one tuple. The table represented by *tbp does not exist. (e.g. after a rollback)
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.

References RDB_clear_err(), RDB_del_expr(), RDB_destroy_obj(), RDB_get_err(), RDB_init_obj(), RDB_obj_type(), and RDB_raise_invalid_argument().

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

RDB_get_table looks up the real, virtual, or public 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:
no_running_tx_error
txp does not point to a running transaction.
name_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.

If a call failed with a name_error, subsequent attempts to get the same table from the same connection will also fail. This is to prevent costly multiple attempts to resolve variables by searching them as tables in the catalog.

References RDB_db_env(), RDB_get_err(), RDB_obj_type(), RDB_raise_name(), RDB_raise_no_memory(), and RDB_tx_db().

Referenced by Duro_lookup_sym(), RDB_drop_table_by_name(), RDB_drop_table_index(), and RDB_expr_resolve_varnames().

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:
type_mismatch_error
The type of a default value does not match the type of the corresponding attribute.
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.

References RDB_del_nonscalar_type(), RDB_init_table_from_type(), and RDB_new_relation_type().

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

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

If default_attrc is greater than zero, default_attrv must point to an array of length default_attrc where name is the attribute name and defaultp points to the default value for that attribute. Entries with a defaultp of NULL are ignored. Other fields of RDB_attr are ignored, but options should be set to zero for compatibility with future versions.

If it returns with RDB_OK, rtyp is consumed.

Referenced by RDB_init_table(), and RDB_set_init_value().

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.

Calling RDB_insert on virtual tables is only supported for tables defined using the following operators: WHERE, project, remove, RENAME, EXTEND, WRAP, and UNWRAP.

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.

References RDB_multi_assign().

Referenced by RDB_create_ro_op_version(), and RDB_define_subtype().

int RDB_map_public_table ( const char *  name,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Map a public table to a relational expression.

Returns
RDB_OK on success, RDB_ERROR on failure.
Errors:
no_running_tx_error
*txp is not a running transaction.
not_found_error
A public table with name name has not been defined.
type_mismatch_error
The type of *exp does not match the type of the table.
invalid_argument_error
The inferred keys of *exp do not match the keys of the table.

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

References RDB_del_expr(), RDB_del_nonscalar_type(), RDB_drop_table(), RDB_dup_expr(), RDB_expr_type(), RDB_raise_invalid_argument(), RDB_raise_no_running_tx(), RDB_raise_not_found(), RDB_raise_type_mismatch(), RDB_table_is_empty(), RDB_tx_is_running(), and RDB_type_equals().

int RDB_max ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  resultp 
)

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

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

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

The type of exp 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:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the attribute is not numeric.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_float(), RDB_obj_int(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_var_ref().

int RDB_min ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  resultp 
)

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

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

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

The type of *exp 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:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the attribute is not numeric.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_float(), RDB_obj_int(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_mismatch(), and RDB_var_ref().

RDB_int RDB_move_tuples ( RDB_object *  dstp,
RDB_object *  srcp,
int  flags,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Copy all tuples from source table into the destination table. The destination table must be a real table.

Returns
the number of tuples copied on success, RDB_ERROR on failure

References RDB_clear_err(), RDB_del_expr(), RDB_destroy_obj(), RDB_get_err(), RDB_init_obj(), RDB_obj_type(), and RDB_table_is_persistent().

Referenced by RDB_copy_obj_data().

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

References RDB_db_env(), RDB_destroy_obj(), RDB_free(), RDB_get_err(), RDB_init_obj(), RDB_obj_string(), RDB_obj_type(), RDB_raise_internal(), RDB_raise_invalid_argument(), RDB_raise_no_memory(), RDB_table_is_persistent(), and RDB_tx_db().

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:
no_running_tx_error
txp does not point to a running transaction.
type_mismatch_error
The types of the two tables differ.
operator_not_found_error
The definition of one of the tables refers to a non-existing operator.
invalid_argument_error
One of the tables does not exist. (e.g. after a rollback)

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

References RDB_clear_err(), RDB_destroy_obj(), RDB_get_err(), RDB_init_obj(), RDB_obj_type(), RDB_raise_no_running_tx(), RDB_raise_type_mismatch(), RDB_table_contains(), RDB_tx_is_running(), and RDB_type_equals().

int RDB_sum ( RDB_object *  tbp,
RDB_expression *  exp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  resultp 
)

RDB_sum computes the sum over the expression exp 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, exp may be NULL.

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

The type of exp 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:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
name_error
*exp refers to a non-existing attribute.
type_mismatch_error
The type of the attribute is not numeric.
invalid_argument_error
exp is NULL and the table has more than one attribute.
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_expr_type(), RDB_get_err(), RDB_init_obj(), RDB_obj_float(), RDB_obj_int(), RDB_obj_type(), RDB_raise_invalid_argument(), RDB_raise_type_constraint_violation(), RDB_raise_type_mismatch(), and RDB_var_ref().

RDB_attr* RDB_table_attrs ( const RDB_object *  tbp,
int *  attrcp 
)

Returns a pointer to an array of RDB_attr structs describing the attributes of table *tbp and stores the number of attributes in *attrcp.

The pointer returned must no longer be used if the table has been destroyed.

Returns

A pointer to an array of RDB_attr structs or NULL if *tbp is not a table.

References RDB_attr::defaultp, RDB_attr::name, RDB_obj_type(), and RDB_type_attrs().

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

Check if the tuple *tplp is an element of the table *tbp and store 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:
no_running_tx_error
txp does not point to a running transaction.
invalid_argument_error
A table attribute is missing in the tuple.
The table represented by *tbp does not exist. (e.g. after a rollback)
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 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.

References RDB_base_type(), RDB_obj_matches_type(), RDB_obj_type(), RDB_raise_no_running_tx(), RDB_raise_type_mismatch(), RDB_table_matching_tuple(), RDB_tuple_get(), and RDB_tx_is_running().

Referenced by RDB_subset().

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.

Errors:
no_running_tx_error
*tbp is persistent and *txp is not a running transaction.
operator_not_found_error
The definition of *tbp refers to a non-existing operator.
invalid_argument_error
The table represented by *tbp does not exist. (e.g. after a rollback)

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

References RDB_add_arg(), RDB_del_expr(), RDB_destroy_obj(), RDB_evaluate(), RDB_init_obj(), RDB_obj_bool(), RDB_ro_op(), and RDB_table_ref().

Referenced by RDB_call_ro_op_by_name_e(), RDB_drop_db(), and RDB_map_public_table().

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.

Referenced by RDB_add_table(), RDB_copy_obj_data(), RDB_create_table_index(), RDB_drop_table(), RDB_expr_equals(), RDB_move_tuples(), and RDB_set_table_name().

RDB_bool RDB_table_is_real ( const RDB_object *  tbp)

RDB_table_is_real checks if the table *tbp is real or private.

Returns

RDB_TRUE if *tbp is a real or private table, RDB_FALSE if it is not.

Referenced by RDB_table_is_stored().

RDB_bool RDB_table_is_stored ( const RDB_object *  tbp)

RDB_table_is_stored checks if the table *tbp is physically stored.

Returns

RDB_TRUE if *tbp is a physically stored table, RDB_FALSE if it is not.

References RDB_table_is_real().

RDB_bool RDB_table_is_user ( const RDB_object *  tbp)

Check if the table *tbp is a user table.

Returns

RDB_TRUE if *tbp is a user table, RDB_FALSE if it is not.

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

Check if *tbp contains a tuple that matches *tplp and store the result at *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:
no_running_tx_error
txp does not point to a running transaction.
operator_not_found_error
The definition of the table specified by tbp refers to a non-existing operator.
invalid_argument_error
*srcp or *dstp is a table that does not exist. (e.g. after a rollback)

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

Referenced by RDB_table_contains().

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

Referenced by RDB_create_table_index().

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.

References RDB_multi_assign().

Referenced by RDB_implement_type().