/* * cursor_copy_vobj_to_dbvalue - The given tuple set value which is in disk * representation form is copied to the db_value structure * return: NO_ERROR on all ok, ER status( or ER_FAILED) otherwise * buf(in) : Pointer to set disk representation * db_value(out) : Set to the set value */ int cursor_copy_vobj_to_dbvalue (OR_BUF * buffer_p, DB_VALUE * value_p) { int rc; DB_VALUE vobj_dbval; DB_OBJECT *object_p; PR_TYPE *pr_type; pr_type = PR_TYPE_FROM_ID (DB_TYPE_VOBJ); if (pr_type == NULL) { return ER_FAILED; } if (db_value_domain_init (&vobj_dbval, pr_type->id, 0, 0) != NO_ERROR) { return ER_FAILED; } if ((*(pr_type->readval)) (buffer_p, &vobj_dbval, NULL, -1, true, NULL, 0) != NO_ERROR) { return ER_FAILED; } /* convert the vobj into a vmop */ rc = vid_vobj_to_object (&vobj_dbval, &object_p); DB_MAKE_OBJECT (value_p, object_p); pr_clear_value (&vobj_dbval); return rc; }
/* * cursor_fixup_vobjs () - * return: NO_ERROR on all ok, ER status( or ER_FAILED) otherwise * value(in/out): a db_value * Note: if value is an OID then turn it into an OBJECT type value * if value is a VOBJ then turn it into a vmop * if value is a set/seq then do same fixups on its elements */ static int cursor_fixup_vobjs (DB_VALUE * value_p) { DB_OBJECT *obj; int rc; switch (DB_VALUE_DOMAIN_TYPE (value_p)) { case DB_TYPE_OID: rc = vid_oid_to_object (value_p, &obj); DB_MAKE_OBJECT (value_p, obj); break; case DB_TYPE_VOBJ: if (DB_IS_NULL (value_p)) { db_value_clear (value_p); db_value_domain_init (value_p, DB_TYPE_OBJECT, DB_DEFAULT_PRECISION, DB_DEFAULT_SCALE); rc = NO_ERROR; } else { rc = vid_vobj_to_object (value_p, &obj); pr_clear_value (value_p); DB_MAKE_OBJECT (value_p, obj); } break; case DB_TYPE_SET: case DB_TYPE_MULTISET: case DB_TYPE_SEQUENCE: /* fixup any set/seq of vobjs into a set/seq of vmops */ rc = cursor_fixup_set_vobjs (value_p); break; default: rc = NO_ERROR; break; } return rc; }
/* * cursor_get_tuple_value_to_dbvalue () - The given tuple value which is in disk * representation form is copied/peeked to the db_value structure * return: NO_ERROR on all ok, ER status( or ER_FAILED) otherwise * buf(in) : Pointer to the tuple value * dom(in) : Domain for the tpl column * val_flag(in) : Flag to indicate if tuple value is bound * db_value(out) : Set to the tuple value * copy(in) : Indicator for copy/peek */ static int cursor_get_tuple_value_to_dbvalue (OR_BUF * buffer_p, TP_DOMAIN * domain_p, QFILE_TUPLE_VALUE_FLAG value_flag, DB_VALUE * value_p, bool is_copy) { PR_TYPE *pr_type; DB_TYPE type; pr_type = domain_p->type; if (pr_type == NULL) { return ER_FAILED; } type = pr_type->id; if (value_flag == V_UNBOUND) { db_value_domain_init (value_p, type, domain_p->precision, domain_p->scale); return NO_ERROR; } /* VOBJs must be handled separately */ if (type == DB_TYPE_VOBJ) { return cursor_copy_vobj_to_dbvalue (buffer_p, value_p); } /* for all other types, we can use the prim routines */ if ((*(pr_type->readval)) (buffer_p, value_p, domain_p, -1, is_copy, NULL, 0) != NO_ERROR) { return ER_FAILED; } /* * OIDs must be turned into objects. * VOBJs must be turned into vmops. */ return cursor_fixup_vobjs (value_p); }
/* * vt_api_init_domain - * return: * impl(): * index(): * value(): */ static int vt_api_init_domain (void *impl, int index, DB_VALUE * value) { OBJECT_RESULTSET *or = (OBJECT_RESULTSET *) impl; DB_ATTRIBUTE *attr; DB_DOMAIN *domain; DB_TYPE dbt; int p, s; int res; assert (or != NULL); attr = or->attr_index[index]; assert (attr != NULL); domain = db_attribute_domain (attr); assert (domain != NULL); dbt = TP_DOMAIN_TYPE (domain); p = db_domain_precision (domain); s = db_domain_scale (domain); res = db_value_domain_init (value, dbt, p, s); return NO_ERROR; }