Beispiel #1
0
/*
 * db_set_add() - This function adds an element to a set or multiset. If the
 *    set is a basic set and the value already exists in the set, a zero is
 *    returned, indicating that no error occurred. If the set is a multiset,
 *    the value will be added even if it already exists. If the set has been
 *    assigned as the value of an attribute, the domain of the value is first
 *    checked against the attribute domain. If they do not match, a zero is
 *    returned, indicating that no error occurred.
 * return : error code
 * set(in): set descriptor
 * value(in): value to add
 *
 * note : you may not make any assumptions about the position of the value
 *    within the set; it will be added wherever the system determines is most
 *    convenient. If you need to have sets with ordered elements, you must use
 *    sequences. Sets and multi-sets cannot contain NULL elements, if the value
 *    has a basic type of DB_TYPE_NULL, an error is returned.
 */
int
db_set_add (DB_SET * set, DB_VALUE * value)
{
  int error = NO_ERROR;

  CHECK_CONNECT_ERROR ();
  CHECK_1ARG_ERROR (set);

  /* Check if modifications are disabled only if the set is owned */
  if (set->owner != NULL)
    {
      CHECK_MODIFICATION_ERROR ();
    }

  if ((value != NULL) && (DB_VALUE_TYPE (value) > DB_TYPE_LAST))
    {
      ERROR_SET (error, ER_OBJ_INVALID_ARGUMENTS);
    }
  else
    {
      error = set_add_element (set, value);
    }

  return (error);
}
Beispiel #2
0
/*
 * db_col_insert() - This function inserts a new element into the sequence at a
 *    position immediately before the indexed element. This function is
 *    normally used with collections of type DB_TYPE_SEQUENCE. If the index is
 *    0, the new element is added to the beginning of the sequence. All
 *    elements in the sequence are moved down to make room for the new element.
 *    The sequence increases in size by one element.
 * return : error status
 * col(in): collection
 * element_index(in): index of new element
 * value(in): value to insert
 */
int
db_col_insert (DB_COLLECTION * col, int element_index, DB_VALUE * value)
{
  int error = NO_ERROR;
  DB_TYPE coltype;

  CHECK_CONNECT_ERROR ();
  CHECK_1ARG_ERROR (col);

  /* Check if modifications are disabled only if the set is owned */
  if (col->owner != NULL)
    {
      CHECK_MODIFICATION_ERROR ();
    }

  coltype = set_get_type (col);
  if (coltype == DB_TYPE_SEQUENCE)
    {
      error = set_insert_element (col, element_index, value);
    }
  else
    {
      error = set_add_element (col, value);
    }

  return error;
}
void		
block_parameter_set_add( block_parameter_set * p_parameter_set, block_parameter * parameter )
{
	if ( p_parameter_set == NULL || parameter == NULL )
		return;
	
	if ( set_add_element( &p_parameter_set->parameter_set, (void *) parameter ) != SUCCESS )
	{
		LOG_ERROR( _module_name, "could not add element" );
	}
	
}
Beispiel #4
0
/*
 * db_col_add() -  This is used to add new elements to a collection.
 *
 * return : error status
 * col(in): collection to extend
 * value(in): value to add
 *
 * note : db_col_add is normally used only with collections of type DB_TYPE_SET
 *   and DB_TYPE_MULTISET.  It can be used with collections of type
 *   DB_TYPE_SEQUENCE but the new elements will always be appended to the end
 *   of the sequence.  If you need more control over the positioning of
 *   elements in a sequence, you may use the db_col_put or db_col_insert
 *   functions.
 */
int
db_col_add (DB_COLLECTION * col, DB_VALUE * value)
{
  int error = NO_ERROR;

  CHECK_CONNECT_ERROR ();
  CHECK_1ARG_ERROR (col);

  /* Check if modifications are disabled only if the set is owned */
  if (col->owner != NULL)
    {
      CHECK_MODIFICATION_ERROR ();
    }

  error = set_add_element (col, value);

  return error;
}
Beispiel #5
0
bool_t var_add_to_definition(var_t *var, u64 el) {
	return var == NULL ? FALSE : set_add_element(var->def, el);
}