Examples of TypeId


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

    {
      /* When sorting or choosing min/max in the list, if types are not an exact
       * match, we use the left operand's type as the "judge", assuming that they
       * are compatible, as also the case with DB2.
       */
      TypeId judgeTypeId = leftOperand.getTypeServices().getTypeId();
      DataValueDescriptor judgeODV = null//no judge, no argument
      if (! rightOperandList.allSamePrecendence(judgeTypeId.typePrecedence()))
        judgeODV = (DataValueDescriptor) judgeTypeId.getNull();

      //Sort the list in ascending order
      rightOperandList.sortInAscendingOrder(judgeODV);
      isOrdered = true;

View Full Code Here

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

      /*
      ** MIN and MAX may return null
      */
    DataTypeDescriptor dts = new DataTypeDescriptor((DataTypeDescriptor) inputType, true);
    TypeId compType = dts.getTypeId();

    /*
    ** If the class implements NumberDataValue, then we
    ** are in business.  Return type is same as input
    ** type.
    */
    if (compType.orderable(
            lcc.getLanguageConnectionFactory().getClassFactory()))
    {
      aggregatorClass.append(ClassName.MaxMinAggregator);
     
      return dts;
View Full Code Here

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

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

    TypeId  leftType = leftOperand.getTypeId();
    TypeId  rightType = rightOperand.getTypeId();
    DataTypeDescriptor  leftDTS = leftOperand.getTypeServices();
    DataTypeDescriptor  rightDTS = rightOperand.getTypeServices();

    /* Do any implicit conversions from (long) (var)char. */
    if (leftType.isStringTypeId() && rightType.isNumericTypeId())
    {
      boolean nullableResult;
      nullableResult = leftDTS.isNullable() ||
                rightDTS.isNullable();
      /* If other side is decimal/numeric, then we need to diddle
       * with the precision, scale and max width in order to handle
       * computations like:  1.1 + '0.111'
       */
      int precision = rightDTS.getPrecision();
      int scale    = rightDTS.getScale();
      int maxWidth  = rightDTS.getMaximumWidth();

      if (rightType.isDecimalTypeId())
      {
        int charMaxWidth = leftDTS.getMaximumWidth();
        precision += (2 * charMaxWidth);               
        scale += charMaxWidth;               
        maxWidth = precision + 3;
      }

      leftOperand = (ValueNode)
          getNodeFactory().getNode(
            C_NodeTypes.CAST_NODE,
            leftOperand,
            new DataTypeDescriptor(rightType, precision,
                      scale, nullableResult,
                      maxWidth),
            getContextManager());
      ((CastNode) leftOperand).bindCastNodeOnly();
    }
    else if (rightType.isStringTypeId() && leftType.isNumericTypeId())
    {
      boolean nullableResult;
      nullableResult = leftDTS.isNullable() ||
                rightDTS.isNullable();
      /* If other side is decimal/numeric, then we need to diddle
View Full Code Here

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

    if (getTypeServices() == 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 .
        
        }
        /*
         * Derby-1132 : The length for the target type was calculated
         * incorrectly while Char & Varchar functions were used. Thus
         * adding the check for Char & Varchar and calculating the
         * length based on the operand type.
         */
        else if(srcTypeId.isStringTypeId())
        {
          length = opndType.getMaximumWidth();
     
          // Truncate the target type width to the max width of the
          // data type
          if (this.targetCharType == Types.CHAR)
            length = Math.min(length, Limits.DB2_CHAR_MAXWIDTH);
          else if (this.targetCharType == Types.VARCHAR)
            length = Math.min(length, Limits.DB2_VARCHAR_MAXWIDTH);
        }
        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

   * selectivity otherwise.
   */
  protected double booleanSelectivity(Optimizable optTable)
  throws StandardException
  {
    TypeId  typeId = null;
    double        retval = -1.0d;
    int          columnSide;

    columnSide = columnOnOneSide(optTable);

    if (columnSide == LEFT)
      typeId = leftOperand.getTypeId();
    else if (columnSide == RIGHT)
      typeId = rightOperand.getTypeId();

    if (typeId != null && (typeId.getJDBCTypeId() == Types.BIT ||
    typeId.getJDBCTypeId() == JDBC30Translation.SQL_TYPES_BOOLEAN))
      retval = 0.5d;

    return retval;
  }
View Full Code Here

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

  public ResultColumn  getNewAggregatorResultColumn(DataDictionary  dd)
    throws StandardException
  {
    String  className = aggregatorClassName.toString();

    TypeId compTypeId = TypeId.getSQLTypeForJavaType(className);

    /*
    ** Create a null of the right type.  The proper aggregators
    ** are created dynamically by the SortObservers
    */
 
View Full Code Here

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

    /*
    ** Generate a CastNode if necessary and
    ** stick it over the original expression
    */
    TypeId condTypeId = getTypeId();
    TypeId thenTypeId = ((ValueNode) thenElseList.elementAt(0)).getTypeId();
    TypeId elseTypeId = ((ValueNode) thenElseList.elementAt(1)).getTypeId();

    /* Need to generate conversion if thenExpr or elseExpr is not of
     * dominant type.  (At least 1 of them must be of the dominant type.)
     */
    if (thenTypeId.typePrecedence() != condTypeId.typePrecedence())
    {
      ValueNode cast = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.CAST_NODE,
                thenElseList.elementAt(0),
                                getTypeServices()// cast to dominant type
                getContextManager());
      cast = cast.bindExpression(fromList,
                      subqueryList,
                      aggregateVector);
     
      thenElseList.setElementAt(cast, 0);
    }

    else if (elseTypeId.typePrecedence() != condTypeId.typePrecedence())
    {
      ValueNode cast = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.CAST_NODE,
                thenElseList.elementAt(1),
                                getTypeServices()// cast to dominant type
View Full Code Here

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

    /*
    ** Generate a CastNode if necessary and
    ** stick it over the original expression
    */
    TypeId condTypeId = getTypeId();
    TypeId thenTypeId = ((ValueNode) thenElseList.elementAt(0)).getTypeId();
    TypeId elseTypeId = ((ValueNode) thenElseList.elementAt(1)).getTypeId();

    /* Need to generate conversion if thenExpr or elseExpr is not of
     * dominant type.  (At least 1 of them must be of the dominant type.)
     */
    if (thenTypeId.typePrecedence() != condTypeId.typePrecedence())
    {
      ValueNode cast = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.CAST_NODE,
                thenElseList.elementAt(0),
                                getTypeServices()// cast to dominant type
                getContextManager());
      cast = cast.bindExpression(fromList,
                      subqueryList,
                      aggregateVector);
     
      thenElseList.setElementAt(cast, 0);
    }

    else if (elseTypeId.typePrecedence() != condTypeId.typePrecedence())
    {
      ValueNode cast = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.CAST_NODE,
                thenElseList.elementAt(1),
                                getTypeServices()// cast to dominant type
View Full Code Here

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

      if (rightOperand.requiresTypeFromContext()) {
        throw StandardException.newException(
            SQLState.LANG_BINARY_OPERANDS_BOTH_PARMS, operator);
      }

      TypeId leftType;

      /*
       * * A ? on the left gets its type from the right. There are eight *
       * legal types for the concatenation operator: CHAR, VARCHAR, * LONG
       * VARCHAR, CLOB, BIT, BIT VARYING, LONG BIT VARYING, and BLOB. * If
       * the right type is BLOB, set the parameter type to BLOB with max
       * length. * If the right type is one of the other bit types, set
       * the parameter type to * BIT VARYING with maximum length. * * If
       * the right type is CLOB, set parameter type to CLOB with max
       * length. * If the right type is anything else, set it to VARCHAR
       * with * maximum length. We count on the resolveConcatOperation
       * method to * catch an illegal type. * * NOTE: When I added the
       * long types, I could have changed the * resulting parameter types
       * to LONG VARCHAR and LONG BIT VARYING, * but they were already
       * VARCHAR and BIT VARYING, and it wasn't * clear to me what effect
       * it would have to change it. - Jeff
       */
      if (rightOperand.getTypeId().isBitTypeId()) {
        if (rightOperand.getTypeId().isBlobTypeId())
          leftType = TypeId.getBuiltInTypeId(Types.BLOB);
        else
          leftType = TypeId.getBuiltInTypeId(Types.VARBINARY);
      } else {
        if (rightOperand.getTypeId().isClobTypeId())
          leftType = TypeId.getBuiltInTypeId(Types.CLOB);
        else
          leftType = TypeId.getBuiltInTypeId(Types.VARCHAR);
      }

      leftOperand.setType(new DataTypeDescriptor(leftType, true));
      if (rightOperand.getTypeId().isStringTypeId()) {
        //collation of ? operand should be picked from the context
        leftOperand.getTypeServices().setCollationDerivation(
            rightOperand.getTypeServices().getCollationDerivation());
        leftOperand.getTypeServices().setCollationType(
            rightOperand.getTypeServices().getCollationType());
      }
    }

    /*
     * Is there a ? parameter on the right?
     */
    if (rightOperand.requiresTypeFromContext()) {
      TypeId rightType;

      /*
       * * A ? on the right gets its type from the left. There are eight *
       * legal types for the concatenation operator: CHAR, VARCHAR, * LONG
       * VARCHAR, CLOB, BIT, BIT VARYING, LONG BIT VARYING, and BLOB. * If
 
View Full Code Here

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

    // String sqlTypeName = typeId == null ? "OTHER" : typeId.getSQLTypeName();


    String jdbcTypesName = org.apache.derby.impl.jdbc.Util.typeName(sqlType);

    TypeId typeId = TypeId.getBuiltInTypeId(jdbcTypeId);
    String thisTypeName = typeId == null ? declaredClassName : typeId.getSQLTypeName();
       
    StandardException e = StandardException.newException(SQLState.LANG_INVALID_OUT_PARAM_MAP,
          getJDBCParameterNumberStr(),
          jdbcTypesName, thisTypeName);
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.