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

◆ RDB_add_arg()

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_table_is_empty(), and RDB_tuple_attr().

◆ RDB_bool_to_expr()

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.

◆ RDB_del_expr()

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_cardinality(), RDB_drop_constraint(), RDB_expr_is_table_ref(), RDB_expr_property(), RDB_expr_refers(), RDB_expr_resolve_varname_expr(), RDB_extract_tuple(), RDB_parse_del_node(), RDB_table_is_empty(), and RDB_tuple_attr().

◆ RDB_dup_expr()

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

Return a copy of an expression, copying child expressions.

Referenced by RDB_create_constraint(), and RDB_expr_resolve_varname_expr().

◆ RDB_eq()

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

◆ RDB_evaluate()

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_cardinality(), RDB_extend_tuple(), and RDB_table_is_empty().

◆ RDB_expr_attr_qid()

int RDB_expr_attr_qid ( const RDB_expression *  exp,
RDB_object *  idobjp,
RDB_exec_context *  ecp 
)

Extract qualified id from '.' operator expression

References RDB_expr_kind(), RDB_expr_op_args(), RDB_expr_var_name(), and RDB_string_to_obj().

◆ RDB_expr_equals()

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

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.

References RDB_expr_kind().

◆ RDB_expr_is_op()

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

RDB_bool RDB_expr_is_string ( const RDB_expression *  exp)

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

◆ RDB_expr_is_table_ref()

RDB_bool RDB_expr_is_table_ref ( const RDB_expression *  exp)

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

References RDB_del_expr(), RDB_del_nonscalar_type(), RDB_destroy_obj(), RDB_dup_nonscalar_type(), RDB_expr_kind(), RDB_free(), and RDB_type_is_scalar().

◆ RDB_expr_kind()

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_expr_is_const(), and RDB_expr_is_table_ref().

◆ RDB_expr_obj()

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

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

◆ RDB_expr_op_name()

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

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

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_del_expr(), RDB_eq(), RDB_expr_refers(), RDB_string_to_expr(), and RDB_var_ref().

Referenced by RDB_expr_refers().

◆ RDB_expr_resolve_varname_expr()

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

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.

◆ RDB_expr_type()

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

◆ RDB_expr_var_name()

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(), and RDB_expr_resolve_varname_expr().

◆ RDB_float_to_expr()

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

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.

◆ RDB_obj_to_expr()

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.

◆ RDB_ro_op()

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.

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

◆ RDB_set_expr_type()

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

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.

Referenced by RDB_drop_constraint(), and RDB_expr_refers().

◆ RDB_table_ref()

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(), and RDB_table_is_empty().

◆ RDB_tuple_attr()

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

Referenced by RDB_drop_constraint(), RDB_expr_property(), RDB_expr_refers(), and RDB_tuple_attr().