Examples of TypeId


Examples of org.apache.derby.iapi.types.TypeId

    String columnName;
    String defaultID;
    DefaultInfoImpl    defaultInfo = null;
    ColumnDescriptor colDesc;
    BaseTypeIdImpl    typeId;
    TypeId  wrapperTypeId;
    DataValueDescriptor  defaultValue = null;
    UUID        defaultUUID = null;
    UUID        uuid = null;
    UUIDFactory      uuidFactory = getUUIDFactory();
    long autoincStart, autoincInc;

    DataDescriptorGenerator  ddg = dd.getDataDescriptorGenerator();


    /*
    ** We're going to be getting the UUID for this sucka
    ** so make sure it is a UniqueTupleDescriptor.
    */
    if (parentTupleDescriptor != null)
    {
      if (SanityManager.DEBUG)
      {
        if (!(parentTupleDescriptor instanceof UniqueTupleDescriptor))
        {
          SanityManager.THROWASSERT(parentTupleDescriptor.getClass().getName()
              + " not instanceof UniqueTupleDescriptor")
        }
      }
      uuid = ((UniqueTupleDescriptor)parentTupleDescriptor).getUUID();
    }
    else
    {
      /* 1st column is REFERENCEID (char(36)) */
      uuid = uuidFactory.recreateUUID(row.getColumn(SYSCOLUMNS_REFERENCEID).
                          getString());
    }

    /* NOTE: We get columns 5 and 6 next in order to work around
     * a 1.3.0 HotSpot bug.  (#4361550)
     */

    // 5th column is COLUMNDEFAULT (serialiazable)
    Object object = row.getColumn(SYSCOLUMNS_COLUMNDEFAULT).getObject();
    if (object instanceof DataValueDescriptor)
    {
      defaultValue = (DataValueDescriptor) object;
    }
    else if (object instanceof DefaultInfoImpl)
    {
      defaultInfo = (DefaultInfoImpl) object;
      defaultValue = defaultInfo.getDefaultValue();
    }

    /* 6th column is DEFAULTID (char(36)) */
    defaultID = row.getColumn(SYSCOLUMNS_COLUMNDEFAULTID).getString();

    if (defaultID != null)
    {
      defaultUUID = uuidFactory.recreateUUID(defaultID);
    }

    /* 2nd column is COLUMNNAME (varchar(128)) */
    columnName = row.getColumn(SYSCOLUMNS_COLUMNNAME).getString();

    /* 3rd column is COLUMNNUMBER (int) */
    columnNumber = row.getColumn(SYSCOLUMNS_COLUMNNUMBER).getInt();

    /* 4th column is COLUMNDATATYPE */

    /*
    ** What is stored in the column is a TypeDescriptorImpl, which
    ** points to a BaseTypeIdImpl.  These are simple types that are
    ** intended to be movable to the client, so they don't have
    ** the entire implementation.  We need to wrap them in DataTypeServices
    ** and TypeId objects that contain the full implementations for
    ** language processing.
    */
    TypeDescriptorImpl typeDescriptor = (TypeDescriptorImpl) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).
                          getObject();
    typeId = typeDescriptor.getTypeId();

    /*
    ** The BaseTypeIdImpl tells what type of TypeId it is supposed to
    ** be wrapped in.
    */
    wrapperTypeId =
      (TypeId) Monitor.newInstanceFromIdentifier(typeId.wrapperTypeFormatId());
    /* Wrap the BaseTypeIdImpl in a full type id */
    wrapperTypeId.setNestedTypeId(typeId);

    /* Wrap the TypeDescriptorImpl in a full DataTypeDescriptor */
    DataTypeDescriptor dataTypeServices = new DataTypeDescriptor(typeDescriptor,
                          wrapperTypeId);

View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

    String columnName;
    String defaultID;
    DefaultInfoImpl    defaultInfo = null;
    ColumnDescriptor colDesc;
    BaseTypeIdImpl    typeId;
    TypeId  wrapperTypeId;
    DataValueDescriptor  defaultValue = null;
    UUID        defaultUUID = null;
    UUID        uuid = null;
    UUIDFactory      uuidFactory = getUUIDFactory();
    long autoincStart, autoincInc;

    DataDescriptorGenerator  ddg = dd.getDataDescriptorGenerator();


    /*
    ** We're going to be getting the UUID for this sucka
    ** so make sure it is a UniqueTupleDescriptor.
    */
    if (parentTupleDescriptor != null)
    {
      if (SanityManager.DEBUG)
      {
        if (!(parentTupleDescriptor instanceof UniqueTupleDescriptor))
        {
          SanityManager.THROWASSERT(parentTupleDescriptor.getClass().getName()
              + " not instanceof UniqueTupleDescriptor")
        }
      }
      uuid = ((UniqueTupleDescriptor)parentTupleDescriptor).getUUID();
    }
    else
    {
      /* 1st column is REFERENCEID (char(36)) */
      uuid = uuidFactory.recreateUUID(row.getColumn(SYSCOLUMNS_REFERENCEID).
                          getString());
    }

    /* NOTE: We get columns 5 and 6 next in order to work around
     * a 1.3.0 HotSpot bug.  (#4361550)
     */

    // 5th column is COLUMNDEFAULT (serialiazable)
    Object object = row.getColumn(SYSCOLUMNS_COLUMNDEFAULT).getObject();
    if (object instanceof DataValueDescriptor)
    {
      defaultValue = (DataValueDescriptor) object;
    }
    else if (object instanceof DefaultInfoImpl)
    {
      defaultInfo = (DefaultInfoImpl) object;
      defaultValue = defaultInfo.getDefaultValue();
    }

    /* 6th column is DEFAULTID (char(36)) */
    defaultID = row.getColumn(SYSCOLUMNS_COLUMNDEFAULTID).getString();

    if (defaultID != null)
    {
      defaultUUID = uuidFactory.recreateUUID(defaultID);
    }

    /* 2nd column is COLUMNNAME (varchar(128)) */
    columnName = row.getColumn(SYSCOLUMNS_COLUMNNAME).getString();

    /* 3rd column is COLUMNNUMBER (int) */
    columnNumber = row.getColumn(SYSCOLUMNS_COLUMNNUMBER).getInt();

    /* 4th column is COLUMNDATATYPE */

    /*
    ** What is stored in the column is a TypeDescriptorImpl, which
    ** points to a BaseTypeIdImpl.  These are simple types that are
    ** intended to be movable to the client, so they don't have
    ** the entire implementation.  We need to wrap them in DataTypeServices
    ** and TypeId objects that contain the full implementations for
    ** language processing.
    */
    TypeDescriptorImpl typeDescriptor = (TypeDescriptorImpl) row.getColumn(SYSCOLUMNS_COLUMNDATATYPE).
                          getObject();
    typeId = typeDescriptor.getTypeId();

    /*
    ** The BaseTypeIdImpl tells what type of TypeId it is supposed to
    ** be wrapped in.
    */
    wrapperTypeId =
      (TypeId) Monitor.newInstanceFromIdentifier(typeId.wrapperTypeFormatId());
    /* Wrap the BaseTypeIdImpl in a full type id */
    wrapperTypeId.setNestedTypeId(typeId);

    /* Wrap the TypeDescriptorImpl in a full DataTypeDescriptor */
    DataTypeDescriptor dataTypeServices = new DataTypeDescriptor(typeDescriptor,
                          wrapperTypeId);

View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

    methodCall.append(isOldTable ? "getOldRow()" : "getNewRow()");
    methodCall.append(".getObject(");
        methodCall.append(colDesc.getPosition());
        methodCall.append(") AS ");
    DataTypeDescriptor dts = colDesc.getType();
    TypeId typeId = dts.getTypeId();

    /*
    ** getSQLString() returns <typeName>
    ** for user types, so call getSQLTypeName in that
    ** case.
    */
    methodCall.append(
      (typeId.userType() ? typeId.getSQLTypeName() : dts.getSQLstring()));
       
        methodCall.append(") ");

    return methodCall.toString();
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

        // That will set the correct length and perform truncation checks etc.

        ResultColumn  typeCol =
          (ResultColumn) typeColumns.elementAt(index);

        TypeId colTypeId = typeCol.getTypeId();

        if (colTypeId.isStringTypeId()) {

          if (colTypeId.getJDBCTypeId() != java.sql.Types.CHAR) {

            int maxWidth = re.getTypeServices().getMaximumWidth();

            re.setType(new DataTypeDescriptor(colTypeId, true, maxWidth));
          }
        }
        else if (colTypeId.isBitTypeId()) {
          if (colTypeId.getJDBCTypeId() == java.sql.Types.VARBINARY) {
          // then we're trying to cast a char literal into a
          // variable bit column.  We can't change the base
          // type of the table constructor's value from char
          // to bit, so instead, we just change the base type
          // of that value from char to varchar--that way,
          // no padding will be added when we convert to
          // bits later on (Beetle 5306).
            TypeId tId = TypeId.getBuiltInTypeId(java.sql.Types.VARCHAR);
            re.setType(new DataTypeDescriptor(tId, true));
            typeColumns.setElementAt(typeCol, index);
          }
          else if (colTypeId.getJDBCTypeId() == java.sql.Types.LONGVARBINARY) {
            TypeId tId = TypeId.getBuiltInTypeId(java.sql.Types.LONGVARCHAR);
            re.setType(new DataTypeDescriptor(tId, true));
            typeColumns.setElementAt(typeCol, index);
          }
        }

      }
      else if (re instanceof BitConstantNode)
      {
        ResultColumn  typeCol =
          (ResultColumn) typeColumns.elementAt(index);

        TypeId colTypeId = typeCol.getTypeId();

        if (colTypeId.isBitTypeId()) {

          // NOTE: Don't bother doing this if the column type is BLOB,
          // as we don't allow bit literals to be inserted into BLOB
          // columns (they have to be explicitly casted first); beetle 5266.
          if ((colTypeId.getJDBCTypeId() != java.sql.Types.BINARY) &&
            (colTypeId.getJDBCTypeId() != java.sql.Types.BLOB)) {

            int maxWidth = re.getTypeServices().getMaximumWidth();

            re.setType(new DataTypeDescriptor(colTypeId, true, maxWidth));
          }
        }
        else if (colTypeId.isStringTypeId()) {
          if (colTypeId.getJDBCTypeId() == java.sql.Types.VARCHAR) {
          // then we're trying to cast a bit literal into a
          // variable char column.  We can't change the base
          // type of the table constructor's value from bit
          // to char, so instead, we just change the base
          // type of that value from bit to varbit--that way,
          // no padding will be added when we convert to
          // char later on.
            TypeId tId = TypeId.getBuiltInTypeId(java.sql.Types.VARBINARY);
            re.setType(new DataTypeDescriptor(tId, true));
            typeColumns.setElementAt(typeCol, index);
          }
          else if (colTypeId.getJDBCTypeId() == java.sql.Types.LONGVARCHAR) {
            TypeId tId = TypeId.getBuiltInTypeId(java.sql.Types.LONGVARBINARY);
            re.setType(new DataTypeDescriptor(tId, true));
            typeColumns.setElementAt(typeCol, index);
          }
        }
      }
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

    */
    if (SanityManager.DEBUG)
      SanityManager.ASSERT(leftType.getTypeId().isNumericTypeId(),
        "The left type is supposed to be a number because we're resolving an arithmetic operator");

    TypeId leftTypeId = leftType.getTypeId();
    TypeId rightTypeId = rightType.getTypeId();

    boolean supported = true;

    if ( ! (rightTypeId.isNumericTypeId()) )
    {
      supported = false;
    }

    if (TypeCompiler.MOD_OP.equals(operator)) {
      switch (leftTypeId.getJDBCTypeId()) {
      case java.sql.Types.TINYINT:
      case java.sql.Types.SMALLINT:
      case java.sql.Types.INTEGER:
      case java.sql.Types.BIGINT:
        break;
      default:
        supported = false;
        break;
      }
      switch (rightTypeId.getJDBCTypeId()) {
      case java.sql.Types.TINYINT:
      case java.sql.Types.SMALLINT:
      case java.sql.Types.INTEGER:
      case java.sql.Types.BIGINT:
        break;
      default:
        supported = false;
        break;
      }

    }

    if (!supported) {
      throw StandardException.newException(SQLState.LANG_BINARY_OPERATOR_NOT_SUPPORTED,
          operator,
          leftType.getTypeId().getSQLTypeName(),
          rightType.getTypeId().getSQLTypeName()
          );
    }

    /*
    ** Take left as the higher precedence if equal
    */
    if (rightTypeId.typePrecedence() > leftTypeId.typePrecedence())
    {
      higherType = rightType;
      higherTC = (NumericTypeCompiler) getTypeCompiler(rightTypeId);
    }
    else
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

      ** it is syntactically impossible to have a non-Boolean JOIN clause
      ** in that level of the standard.  But we intend to extend the
      ** language to allow Boolean user functions in the JOIN clause,
      ** so we need to test for the error condition.
      */
      TypeId joinTypeId = joinClause.getTypeId();

      /* If the where clause is not a built-in type, then generate a bound
       * conversion tree to a built-in type.
       */
      if (joinTypeId.userType())
      {
        joinClause = joinClause.genSQLJavaSQLTree();
      }

      if (! joinClause.getTypeServices().getTypeId().equals(
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

    throws StandardException
  {
    int precision = 0, scal = 0, maxwidth = 0;
    Boolean isNullable;
    boolean valueInP; // value in Predicate-- if TRUE a value was passed in
    TypeId  typeId = null;
    int typeid = 0;

    if (arg1 instanceof TypeId)
    {
      typeId = (TypeId)arg1;
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

      ** get the type of the first non-? in its column, so it can't
      ** affect the final dominant type.  It's possible that all the
      ** rows for a particular column will have ? parameters - this is
      ** an error condition that will be caught later.
      */
      TypeId thisTypeId = thisExpr.getTypeId();
      if (thisTypeId == null)
        continue;

      TypeId otherTypeId = otherExpr.getTypeId();
      if (otherTypeId == null)
        continue;

      /*
      ** Check type compatability.  We want to make sure that
      ** the types are assignable in either direction
      ** and they are comparable.
      */
      ClassFactory cf = getClassFactory();
      if (
        !thisExpr.getTypeCompiler().storable(otherTypeId, cf) &&
        !otherExpr.getTypeCompiler().storable(thisTypeId, cf))
      {
        throw StandardException.newException(SQLState.LANG_NOT_UNION_COMPATIBLE,
                                                     thisTypeId.getSQLTypeName(),
                                                     otherTypeId.getSQLTypeName(),
                                                     operatorName);
      }

      DataTypeDescriptor resultType = thisExpr.getTypeServices().getDominantType(
                        otherExpr.getTypeServices(),
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

      for (int index = 1; index <= numColumns; index++)
      {
        boolean nullableResult =
          (rsmd.isNullable(index) != ResultSetMetaData.columnNoNulls);

        TypeId cti;

        int jdbcColumnType = rsmd.getColumnType(index);

        switch (jdbcColumnType) {
        case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT:
        case Types.OTHER:
        {
          cti = TypeId.getUserDefinedTypeId(rsmd.getColumnTypeName(index), false);
          break;
        }
        default:
        {
          cti = TypeId.getBuiltInTypeId(jdbcColumnType);
          break;
        }
        }

        // Handle the case where a VTI returns a bad column type
        if (cti == null)
        {
          throw StandardException.newException(SQLState.LANG_BAD_J_D_B_C_TYPE_INFO, Integer.toString(index));
        }

        // Get the maximum byte storage for this column
        int maxWidth;

        /* Get maximum byte storage from rsmd for variable
         * width types, set it to MAXINT for the long types,
         * otherwise get it from the TypeId
         */
        if (cti.variableLength())
        {
          maxWidth = rsmd.getColumnDisplaySize(index);
        }
        else if (jdbcColumnType == Types.LONGVARCHAR ||
             jdbcColumnType == Types.LONGVARBINARY)
        {
          maxWidth = Integer.MAX_VALUE;
        }
        else
        {
          maxWidth = 0;
        }

        int precision = cti.isDecimalTypeId() ? rsmd.getPrecision(index) : 0;
        int scale = cti.isDecimalTypeId() ? rsmd.getScale(index) : 0;
        DataTypeDescriptor dts = new DataTypeDescriptor(cti,
                      precision,
                      scale,
                      nullableResult,
                      maxWidth);
View Full Code Here

Examples of org.apache.derby.iapi.types.TypeId

      ** get the type of the first non-? in its column, so it can't
      ** affect the final dominant type.  It's possible that all the
      ** rows for a particular column will have ? parameters - this is
      ** an error condition that will be caught later.
      */
      TypeId thisTypeId = thisExpr.getTypeId();
      if (thisTypeId == null)
        continue;

      TypeId otherTypeId = otherExpr.getTypeId();
      if (otherTypeId == null)
        continue;

      /*
      ** Check type compatability.  We want to make sure that
      ** the types are assignable in either direction
      ** and they are comparable.
      */
      ClassFactory cf = getClassFactory();
      if (
        !thisExpr.getTypeCompiler().storable(otherTypeId, cf) &&
        !otherExpr.getTypeCompiler().storable(thisTypeId, cf))
      {
        throw StandardException.newException(SQLState.LANG_NOT_UNION_COMPATIBLE,
                                                     thisTypeId.getSQLTypeName(),
                                                     otherTypeId.getSQLTypeName(),
                                                     operatorName);
      }

      DataTypeDescriptor resultType = thisExpr.getTypeServices().getDominantType(
                        otherExpr.getTypeServices(),
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.