Beispiel #1
0
/*
 * 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;
}
Beispiel #2
0
/*
 * pt_get_src_domain() -  compute & return the source domain of an expression
 *   return:  source domain of the given expression
 *   parser(in): the parser context
 *   s(in): an expression representing a select_list item
 *   specs(in): the list of specs to which s was resolved
 */
static SM_DOMAIN *
pt_get_src_domain (PARSER_CONTEXT * parser, const PT_NODE * s, const PT_NODE * specs)
{
  SM_DOMAIN *result;
  PT_NODE *spec, *entity_names, *leaf = (PT_NODE *) s;
  UINTPTR spec_id;

  result = regu_domain_db_alloc ();
  if (result == NULL)
    {
      return result;
    }

  /* if s is not a path expression then its source domain is DB_TYPE_NULL */
  result->type = PR_TYPE_FROM_ID (DB_TYPE_NULL);

  /* make leaf point to the last leaf name node */
  if (s->node_type == PT_DOT_)
    {
      leaf = s->info.dot.arg2;
    }

  /* s's source domain is the domain of leaf's resolvent(s) */
  if (leaf->node_type == PT_NAME && (spec_id = leaf->info.name.spec_id)
      && (spec = pt_find_entity (parser, specs, spec_id)) && (entity_names = spec->info.spec.flat_entity_list))
    {
      pt_set_domain_class_list (result, entity_names, entity_names->info.name.virt_object);
    }

  return result;
}
Beispiel #3
0
/*
 * pt_set_domain_class() -  set SM_DOMAIN's class field
 *   return:  none
 *   dom(out): an SM_DOMAIN
 *   nam(in): an entity name
 *   virt(in):
 */
static void
pt_set_domain_class (SM_DOMAIN * dom, const PT_NODE * nam, const DB_OBJECT * virt)
{
  if (!dom || !nam || nam->node_type != PT_NAME)
    return;

  dom->type = PR_TYPE_FROM_ID (DB_TYPE_OBJECT);
  if (virt != NULL)
    {
      dom->class_mop = (DB_OBJECT *) virt;
    }
  else
    {
      if (nam->info.name.db_object != NULL)
	{
	  dom->class_mop = nam->info.name.db_object;
	  COPY_OID (&dom->class_oid, &(dom->class_mop->oid_info.oid));
	}
      else
	{
	  dom->class_mop = db_find_class (nam->info.name.original);
	  if (dom->class_mop != NULL)
	    {
	      COPY_OID (&dom->class_oid, &(dom->class_mop->oid_info.oid));
	    }
	}
    }
}
Beispiel #4
0
/*
 * pt_find_size_from_dbtype () -  return bytesize of memory representation of
 *                               a given primitive DB_TYPE
 *   return:  the bytesize of dt's memory representation
 *   T_type(in): a DB_TYPE
 */
static int
pt_find_size_from_dbtype (const DB_TYPE db_type)
{
  PRIM type;
  int size = 0;

  if (db_type != DB_TYPE_NULL)
    {
      type = PR_TYPE_FROM_ID (db_type);
      if (type && !(type->variable_p))
	{
	  size = pr_mem_size (type);
	}
    }

  return size;
}