Пример #1
0
void Parameter::setType(PgSQLType type)
{
	if(!type.isArrayType() && is_variadic)
		throw Exception(ERR_INV_USE_VARIADIC_PARAM_MODE ,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	this->type=type;
}
Пример #2
0
bool PgSQLType::isEquivalentTo(PgSQLType type)
{
  unsigned this_idx=0, type_idx=0;
  static vector<QStringList> types={ {QString("int2"),QString("smallint")},
                                     {QString("int4"),QString("integer")},
                                     {QString("int8"),QString("bigint")},
                                     {QString("decimal"),QString("numeric")},
                                     {QString("character varying"),QString("varchar")},
                                     {QString("character"), QString("char")},
                                     {QString("bit varying"),QString("varbit")} };

  //If the types are equal there is no need to perform further operations
  if(*this==type)
    return(true);

  //Getting the index which the this type is in
  for(QStringList list : types)
  {
    if(list.contains(~(*this))) break;
    this_idx++;
  }

  //Getting the index which 'type' is in
  for(QStringList list : types)
  {
    if(list.contains(~type)) break;
    type_idx++;
  }

  return(this_idx < types.size() && type_idx < types.size() &&
         this_idx==type_idx &&
         this->isArrayType()==type.isArrayType());
}
Пример #3
0
void Type::setElement(PgSQLType elem)
{
	if(PgSQLType::getUserTypeIndex(this->getName(true), this) == !elem)
		throw Exception(Exception::getErrorMessage(ERR_USER_TYPE_SELF_REFERENCE).arg(this->getName(true)),
						ERR_USER_TYPE_SELF_REFERENCE,__PRETTY_FUNCTION__,__FILE__,__LINE__);
	else if(elem!=QString("\"any\"") &&
			(elem.isOIDType() || elem.isPseudoType() ||
			 elem.isUserType() || elem.isArrayType()))
		throw Exception(Exception::getErrorMessage(ERR_ASG_INV_ELEMENT_TYPE).arg(this->getName(true)),
						ERR_ASG_INV_ELEMENT_TYPE,__PRETTY_FUNCTION__,__FILE__,__LINE__);

	setCodeInvalidated(element != elem);
	this->element=elem;
}