DuroDBMS API  1.2
Functions
Expression functions

Functions

RDB_bool RDB_expr_is_const (const RDB_expression *exp)
 
enum RDB_expr_kind RDB_expr_kind (const RDB_expression *exp)
 
int RDB_expr_resolve_varname_expr (RDB_expression **expp, const char *varname, RDB_expression *texp, RDB_exec_context *ecp)
 
const char * RDB_expr_op_name (const RDB_expression *exp)
 
RDB_expr_list * RDB_expr_op_args (RDB_expression *exp)
 
const char * RDB_expr_var_name (const RDB_expression *exp)
 
RDB_expression * RDB_bool_to_expr (RDB_bool v, RDB_exec_context *ecp)
 
RDB_expression * RDB_int_to_expr (RDB_int v, RDB_exec_context *ecp)
 
RDB_expression * RDB_float_to_expr (RDB_float v, RDB_exec_context *ecp)
 
RDB_expression * RDB_string_to_expr (const char *v, RDB_exec_context *ecp)
 
RDB_expression * RDB_obj_to_expr (const RDB_object *objp, RDB_exec_context *ecp)
 
RDB_expression * RDB_table_ref (RDB_object *tbp, RDB_exec_context *ecp)
 
RDB_expression * RDB_var_ref (const char *attrname, RDB_exec_context *ecp)
 
RDB_expression * RDB_ro_op (const char *opname, RDB_exec_context *ecp)
 
void RDB_add_arg (RDB_expression *exp, RDB_expression *argp)
 
RDB_expression * RDB_eq (RDB_expression *arg1, RDB_expression *arg2, RDB_exec_context *ecp)
 
RDB_expression * RDB_tuple_attr (RDB_expression *arg, const char *attrname, RDB_exec_context *ecp)
 
int RDB_expr_attr_qid (const RDB_expression *exp, RDB_object *idobjp, RDB_exec_context *ecp)
 
RDB_expression * RDB_expr_property (RDB_expression *arg, const char *compname, RDB_exec_context *ecp)
 
int RDB_del_expr (RDB_expression *exp, RDB_exec_context *ecp)
 
RDB_expression * RDB_dup_expr (const RDB_expression *exp, RDB_exec_context *ecp)
 
RDB_object * RDB_expr_obj (RDB_expression *exp)
 
void RDB_set_expr_type (RDB_expression *exp, RDB_type *typ)
 
RDB_bool RDB_expr_is_string (const RDB_expression *exp)
 
RDB_bool RDB_expr_is_op (const RDB_expression *exp, const char *name)
 
RDB_bool RDB_expr_op_is_noarg (const RDB_expression *exp)
 
RDB_bool RDB_expr_is_table_ref (const RDB_expression *exp)
 
int RDB_evaluate (RDB_expression *exp, RDB_getobjfn *getfnp, void *getdata, RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_object *valp)
 
int RDB_evaluate_bool (RDB_expression *exp, RDB_getobjfn *getfnp, void *getdata, RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resp)
 
RDB_expression * RDB_expr_resolve_varnames (RDB_expression *exp, RDB_getobjfn *getfnp, void *getdata, RDB_exec_context *ecp, RDB_transaction *txp)
 
int RDB_expr_equals (const RDB_expression *ex1p, const RDB_expression *ex2p, RDB_exec_context *ecp, RDB_transaction *txp, RDB_bool *resp)
 
RDB_bool RDB_expr_refers (const RDB_expression *exp, const RDB_object *tbp)
 
RDB_typeRDB_expr_type (RDB_expression *exp, RDB_gettypefn *getfnp, void *getarg, RDB_environment *envp, RDB_exec_context *ecp, RDB_transaction *txp)
 

Detailed Description

Function Documentation

void RDB_add_arg ( RDB_expression *  exp,
RDB_expression *  argp 
)

RDB_add_arg adds the child expression *argp to the expression *exp. exp must represent a read-only operator invocation. RDB_ro_op() should be used to create such an expression.

To obtain a valid expression representing a read-only operator invocation, RDB_add_arg must be called once for each argument of the operator.

Referenced by RDB_cardinality(), RDB_eq(), RDB_expr_property(), RDB_expr_resolve_varname_expr(), RDB_expr_resolve_varnames(), RDB_implement_type(), RDB_table_is_empty(), and RDB_tuple_attr().

RDB_expression* RDB_bool_to_expr ( RDB_bool  v,
RDB_exec_context *  ecp 
)

RDB_bool_to_expr creates a constant expression of type BOOLEAN.

Returns
A pointer to the newly created expression, of NULL if the creation failed.

Referenced by RDB_implement_type().

int RDB_del_expr ( RDB_expression *  exp,
RDB_exec_context *  ecp 
)

Destroy the expression specified to by exp (including all subexpressions) and frees all resources associated with it.

Returns

RDB_OK on success, RDB_ERROR on failure.

Errors:

The call may fail for a system error.

References RDB_free().

Referenced by RDB_all(), RDB_any(), RDB_avg(), RDB_cardinality(), RDB_create_constraint(), RDB_drop_constraint(), RDB_expr_property(), RDB_expr_resolve_varname_expr(), RDB_expr_resolve_varnames(), RDB_extract_tuple(), RDB_implement_type(), RDB_map_public_table(), RDB_max(), RDB_min(), RDB_move_tuples(), RDB_parse_del_node(), RDB_sum(), RDB_table_is_empty(), and RDB_tuple_attr().

RDB_expression* RDB_dup_expr ( const RDB_expression *  exp,
RDB_exec_context *  ecp 
)

Return a copy of an expression, copying child expressions.

References RDB_obj_to_expr(), RDB_table_ref(), and RDB_var_ref().

Referenced by RDB_create_constraint(), RDB_expr_resolve_varname_expr(), and RDB_map_public_table().

RDB_expression* RDB_eq ( RDB_expression *  arg1,
RDB_expression *  arg2,
RDB_exec_context *  ecp 
)

RDB_eq creates an expression that represents an "is equal" operator. If one of the arguments is NULL, NULL is returned.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_add_arg(), and RDB_ro_op().

Referenced by RDB_drop_constraint(), and RDB_drop_db().

int RDB_evaluate ( RDB_expression *  exp,
RDB_getobjfn *  getfnp,
void *  getdata,
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_object *  valp 
)

Evaluates *exp and stores the result in *valp. If *exp is the invocation of a relational operator, *valp will become a transient virtual table.

Errors:
no_running_tx_error
txp is not NULL and *txp is not a running transaction.
name_error
A variable reference could not be resolved.
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 the name could be found, but it does not match the argument types.
invalid_argument_error
An invalid argument was passed to the operator. Evaluating the expression involved accessing a table that does not exist. (e.g. after a rollback)

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

If evaluating the expression involves calling a user-defined operator which 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_copy_obj(), and RDB_copy_obj_data().

Referenced by RDB_all(), RDB_any(), RDB_avg(), RDB_cardinality(), RDB_extend_tuple(), RDB_get_type(), RDB_implement_type(), RDB_max(), RDB_min(), RDB_sum(), and RDB_table_is_empty().

int RDB_expr_attr_qid ( const RDB_expression *  exp,
RDB_object *  idobjp,
RDB_exec_context *  ecp 
)
int RDB_expr_equals ( const RDB_expression *  ex1p,
const RDB_expression *  ex2p,
RDB_exec_context *  ecp,
RDB_transaction *  txp,
RDB_bool *  resp 
)

Compare the two expression *ex1p and *ex2p and store RDB_TRUE in *resp if they are equal, otherwise RDB_FALSE.

References RDB_expr_equals(), RDB_obj_equals(), and RDB_table_is_persistent().

Referenced by RDB_expr_equals().

RDB_bool RDB_expr_is_const ( const RDB_expression *  exp)

RDB_expr_is_const returns if the expression is a constant expression.

Returns

RDB_TRUE if the expression is a constant expression, RDB_FALSE otherwise.

RDB_bool RDB_expr_is_op ( const RDB_expression *  exp,
const char *  name 
)

Return RDB_TRUE if *exp is an invocation of the operator given by name name, otherwise RDB_FALSE.

RDB_bool RDB_expr_is_string ( const RDB_expression *  exp)

Return RDB_TRUE if *exp is of type string, otherwise RDB_FALSE.

RDB_bool RDB_expr_is_table_ref ( const RDB_expression *  exp)

Return RDB_TRUE if *op is a table reference, otherwise RDB_FALSE

enum RDB_expr_kind RDB_expr_kind ( const RDB_expression *  exp)

Return the kind of which expresion *exp is.

Referenced by RDB_expr_attr_qid().

RDB_object* RDB_expr_obj ( RDB_expression *  exp)

RDB_expr_obj returns a pointer to RDB_object embedded in an expression.

Returns

A pointer to the embedded RDB_object or NULL if the expression does not represent a RDB_object.

RDB_expr_list* RDB_expr_op_args ( RDB_expression *  exp)

Return a pointer to the argument list of a read-only operator expression.

Referenced by RDB_expr_attr_qid().

const char* RDB_expr_op_name ( const RDB_expression *  exp)

Return operator name for read-only operator expressions.

Returns
The operator name if the expression is a read-only operator invocation, or NULL if it is not.
RDB_expression* RDB_expr_property ( RDB_expression *  arg,
const char *  compname,
RDB_exec_context *  ecp 
)

RDB_expr_property creates an expression which evaluates to a possible representation component.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_add_arg(), RDB_del_expr(), RDB_ro_op(), and RDB_var_ref().

RDB_bool RDB_expr_refers ( const RDB_expression *  exp,
const RDB_object *  tbp 
)

Returns RDB_TRUE if *exp refers to *tbp, RDB_FALSE otherwise.

References RDB_expr_refers().

Referenced by RDB_drop_table(), and RDB_expr_refers().

int RDB_expr_resolve_varname_expr ( RDB_expression **  expp,
const char *  varname,
RDB_expression *  texp,
RDB_exec_context *  ecp 
)

Replace all occurrences of variable name varname by a copy of expression *texp. Replacement is performed in-place if possible.

References RDB_add_arg(), RDB_del_expr(), RDB_dup_expr(), RDB_expr_resolve_varname_expr(), and RDB_expr_var_name().

Referenced by RDB_expr_resolve_varname_expr().

RDB_expression* RDB_expr_resolve_varnames ( RDB_expression *  exp,
RDB_getobjfn *  getfnp,
void *  getdata,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Return a new expression in which all variable names for which *getfnp() or RDB_get_table() return an RDB_object have been replaced by this object. Table names are replaced by table refs.

References RDB_add_arg(), RDB_clear_err(), RDB_del_expr(), RDB_expr_resolve_varnames(), RDB_get_table(), RDB_obj_to_expr(), RDB_ro_op(), RDB_table_ref(), and RDB_var_ref().

Referenced by RDB_expr_resolve_varnames().

RDB_type* RDB_expr_type ( RDB_expression *  exp,
RDB_gettypefn *  getfnp,
void *  getarg,
RDB_environment *  envp,
RDB_exec_context *  ecp,
RDB_transaction *  txp 
)

Get the type of an expression. The type is managed by the expression. After RDB_expr_type() has been called once, future calls will return the same type.

If txp is NULL, envp will be used to look up operators from the cache. If txp is not NULL, envp is ignored.

Returns
The type of the expression, or NULL on failure.

References RDB_expr_var_name(), RDB_obj_type(), and RDB_raise_not_found().

Referenced by RDB_all(), RDB_any(), RDB_avg(), RDB_define_subtype(), RDB_map_public_table(), RDB_max(), RDB_min(), and RDB_sum().

const char* RDB_expr_var_name ( const RDB_expression *  exp)

Return variable name for expressions referring to variables.

Returns
The variable name if the expression is a read-only variable reference, or NULL if it is not.

Referenced by RDB_expr_attr_qid(), RDB_expr_resolve_varname_expr(), and RDB_expr_type().

RDB_expression* RDB_float_to_expr ( RDB_float  v,
RDB_exec_context *  ecp 
)

RDB_float_to_expr creates a constant expression of type float.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

RDB_expression* RDB_int_to_expr ( RDB_int  v,
RDB_exec_context *  ecp 
)

RDB_int_to_expr creates a constant expression of type INTEGER.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

Referenced by RDB_implement_type().

RDB_expression* RDB_obj_to_expr ( const RDB_object *  objp,
RDB_exec_context *  ecp 
)

RDB_obj_to_expr creates a constant expression from a RDB_object.

Passing an objp of NULL is equivalent to passing a pointer to a RDB_object which has been newly initialized using RDB_init_obj().

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_copy_obj(), RDB_dup_nonscalar_type(), RDB_free(), and RDB_init_obj().

Referenced by RDB_dup_expr(), RDB_expr_resolve_varnames(), and RDB_implement_type().

RDB_expression* RDB_ro_op ( const char *  opname,
RDB_exec_context *  ecp 
)

RDB_ro_op creates an expression which represents the invocation of a readonly operator.

Use RDB_add_arg() to add arguments.

Returns

On success, a pointer to the newly created expression is returned. If the expression could not be created due to insufficient memory, NULL is returned and an error is left in *ecp.

References RDB_free(), and RDB_raise_no_memory().

Referenced by RDB_cardinality(), RDB_eq(), RDB_expr_property(), RDB_expr_resolve_varnames(), RDB_implement_type(), RDB_table_is_empty(), and RDB_tuple_attr().

void RDB_set_expr_type ( RDB_expression *  exp,
RDB_type typ 
)

Set the type of expression *exp to *typ. Only used for special purposes, such as specifying the type of relation selectors.

RDB_expression* RDB_string_to_expr ( const char *  v,
RDB_exec_context *  ecp 
)

RDB_string_to_expr creates a constant expression of type string.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_free(), and RDB_raise_no_memory().

Referenced by RDB_drop_constraint(), RDB_drop_db(), and RDB_implement_type().

RDB_expression* RDB_table_ref ( RDB_object *  tbp,
RDB_exec_context *  ecp 
)

RDB_table_ref creates an expression which refers to a table.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

Referenced by RDB_cardinality(), RDB_dup_expr(), RDB_expr_resolve_varnames(), and RDB_table_is_empty().

RDB_expression* RDB_tuple_attr ( RDB_expression *  arg,
const char *  attrname,
RDB_exec_context *  ecp 
)

RDB_tuple_attr creates an expression that represents a tuple attribute extraction.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_add_arg(), RDB_del_expr(), RDB_ro_op(), and RDB_var_ref().

RDB_expression* RDB_var_ref ( const char *  attrname,
RDB_exec_context *  ecp 
)

RDB_var_ref creates an expression that refers to a variable.

Returns

A pointer to the newly created expression, of NULL if the creation failed.

References RDB_free(), and RDB_raise_no_memory().

Referenced by RDB_all(), RDB_any(), RDB_avg(), RDB_drop_constraint(), RDB_drop_db(), RDB_dup_expr(), RDB_expr_property(), RDB_expr_resolve_varnames(), RDB_implement_type(), RDB_max(), RDB_min(), RDB_sum(), and RDB_tuple_attr().