Examples of TypeId


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

                getNodeFactory().doJoinOrderOptimization(),
                getContextManager()),
              (SubqueryList) null,
              (Vector) null);

      TypeId columnTypeId = getType().getTypeId();
      TypeId defaultTypeId = defaultTree.getTypeId();

      // Check for 'invalid default' errors (42894)
      // before checking for 'not storable' errors (42821).
      if (!defaultTypeIsValid(columnTypeId, getType(),
          defaultTypeId, defaultTree, defaultNode.getDefaultText()))
      {
          throw StandardException.newException(
            SQLState.LANG_DB2_INVALID_DEFAULT_VALUE,
            this.name);
      }

      // Now check 'not storable' errors.
      if (! getTypeCompiler(columnTypeId).
                storable(defaultTypeId, getClassFactory()))
      {
        throw StandardException.newException(SQLState.LANG_NOT_STORABLE,
          columnTypeId.getSQLTypeName(),
          defaultTypeId.getSQLTypeName() );
      }

      // Save off the default text
      // RESOLVEDEFAULT - Convert to constant if possible
      defaultInfo = new DefaultInfoImpl(false,
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 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

  public ValueNode bindExpression(
    FromList  fromList, SubqueryList subqueryList,
    Vector  aggregateVector)
      throws StandardException
  {
    TypeId  operandType;

    super.bindExpression(fromList, subqueryList,
        aggregateVector);

    /*
    ** Check the type of the operand - this function is allowed only on
    ** string value (char and bit) types.
    */
    operandType = operand.getTypeId();

    switch (operandType.getJDBCTypeId())
    {
        case Types.CHAR:
        case Types.VARCHAR:
        case Types.LONGVARCHAR:
        case Types.CLOB:
          break;
        case org.apache.derby.iapi.reference.JDBC20Translation.SQL_TYPES_JAVA_OBJECT:
        case Types.OTHER: 
        {
          throw StandardException.newException(SQLState.LANG_UNARY_FUNCTION_BAD_TYPE,
                    methodName,
                    operandType.getSQLTypeName());
        }

        default:
          operand =  (ValueNode)
            getNodeFactory().getNode(
View Full Code Here

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

    {
      bindSQRTABS();
    }
    else if (operatorType == UNARY_PLUS || operatorType == UNARY_MINUS)
    {
      TypeId operandType = operand.getTypeId();

      if ( ! operandType.isNumericTypeId())
      {
     
        throw StandardException.newException(SQLState.LANG_UNARY_ARITHMETIC_BAD_TYPE,
          (operatorType == UNARY_PLUS) ? "+" : "-",
          operandType.getSQLTypeName());
      }
    }
    /*
    ** The result type of a +, -, SQRT, ABS is the same as its operand.
    */
 
View Full Code Here

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

   * @exception StandardException    Thrown on error
   */
  private void bindSQRTABS()
      throws StandardException
  {
    TypeId  operandType;
    int   jdbcType;

    /*
    ** Check the type of the operand
    */
    operandType = operand.getTypeId();

    /*
      * If the operand is not a build-in type, generate a bound conversion
     * tree to build-in types.
     */
    if (operandType.userType() )
    {
      operand = operand.genSQLJavaSQLTree();
    }
    /* DB2 doesn't cast string types to numeric types for numeric functions  */

    jdbcType = operandType.getJDBCTypeId();

    /* Both SQRT and ABS are only allowed on numeric types */
    if (!operandType.isNumericTypeId())
      throw StandardException.newException(
            SQLState.LANG_UNARY_FUNCTION_BAD_TYPE,
            getOperatorString(), operandType.getSQLTypeName());

    /* For SQRT, if operand is not a DOUBLE, convert it to DOUBLE */
    if (operatorType == SQRT && jdbcType != Types.DOUBLE)
    {
      operand = (ValueNode) getNodeFactory().getNode(
View Full Code Here

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

      throws StandardException
  {
        ValueNode boundExpression = super.bindExpression( fromList, subqueryList, aggregateVector);

        // This operator is not allowed on XML types.
        TypeId operandType = operand.getTypeId();
        if (operandType.isXMLTypeId()) {
            throw StandardException.newException(SQLState.LANG_UNARY_FUNCTION_BAD_TYPE,
                                    getOperatorString(),
                                    operandType.getSQLTypeName());
        }

        setType( new DataTypeDescriptor( TypeId.getBuiltInTypeId( Types.INTEGER),
                                         operand.getTypeServices().isNullable()));
        return boundExpression;
View Full Code Here

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

    if (castTarget == null)   //CHAR or VARCHAR function without specifying target length
    {
      DataTypeDescriptor opndType = castOperand.getTypeServices();
      int length = -1;
      TypeId srcTypeId = opndType.getTypeId();
      if (opndType != null)
      {
        if (srcTypeId.isNumericTypeId())
        {
          length = opndType.getPrecision() + 1; // 1 for the sign
          if (opndType.getScale() > 0)
            length += 1;               // 1 for the decimal .
        
        }
        else
        {
          TypeId typeid = opndType.getTypeId();
          if (length < 0)
            length = DataTypeUtilities.getColumnDisplaySize(typeid.getJDBCTypeId(),-1);

        }
      }
      if (length < 0)
        length = 1// same default as in parser
View Full Code Here

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

   *
   */
  public void compatible(ValueNode leftOperand) throws StandardException
  {
    int       size = size();
    TypeId  leftType;
    ValueNode    valueNode;
    TypeCompiler leftTC;

    leftType = leftOperand.getTypeId();
    leftTC = leftOperand.getTypeCompiler();

    for (int index = 0; index < size; index++)
    {
      valueNode = (ValueNode) elementAt(index);
      if (valueNode.requiresTypeFromContext())
        continue;


      /*
      ** Are the types compatible to each other?  If not, throw an exception.
      */
      if (! leftTC.compatible(valueNode.getTypeId()))
      {
        throw StandardException.newException(SQLState.LANG_DB2_COALESCE_DATATYPE_MISMATCH,
            leftType.getSQLTypeName(),
            valueNode.getTypeId().getSQLTypeName()
            );
      }
    }
  }
View Full Code Here

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

   * @exception StandardException    Thrown on error
   */
  public void comparable(ValueNode leftOperand) throws StandardException
  {
    int       size = size();
    TypeId  leftType;
    ValueNode    valueNode;
    TypeCompiler leftTC;

    leftType = leftOperand.getTypeId();
    leftTC = leftOperand.getTypeCompiler();

    for (int index = 0; index < size; index++)
    {
      valueNode = (ValueNode) elementAt(index);

      /*
      ** Can the types be compared to each other?  If not, throw an
      ** exception.
      */
      if (! leftTC.comparable(valueNode.getTypeId(),
                  false,
                  getClassFactory()))
      {
        throw StandardException.newException(SQLState.LANG_NOT_COMPARABLE,
            leftType.getSQLTypeName(),
            valueNode.getTypeId().getSQLTypeName()
            );
      }
    }
  }
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.