Package org.apache.derby.iapi.sql.compile

Examples of org.apache.derby.iapi.sql.compile.TypeCompiler


    /*
     * If either the left or right operands are non-string, non-bit types,
     * then we generate an implicit cast to VARCHAR.
     */
    TypeCompiler tc = leftOperand.getTypeCompiler();
    if (!(leftOperand.getTypeId().isStringTypeId() || leftOperand
        .getTypeId().isBitTypeId())) {
      DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(
          Types.VARCHAR, true, tc
          .getCastToCharWidth(leftOperand              .getTypeServices()))

            leftOperand = new CastNode(leftOperand, dtd, getContextManager());

      // DERBY-2910 - Match current schema collation for implicit cast as we do for
      // explicit casts per SQL Spec 6.12 (10)     
      leftOperand.setCollationUsingCompilationSchema();
           
      ((CastNode) leftOperand).bindCastNodeOnly();
    }
    tc = rightOperand.getTypeCompiler();
    if (!(rightOperand.getTypeId().isStringTypeId() || rightOperand
        .getTypeId().isBitTypeId())) {
      DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(
          Types.VARCHAR, true, tc
              .getCastToCharWidth(rightOperand
                  .getTypeServices()));

            rightOperand = new CastNode(rightOperand, dtd, getContextManager());
     
      // DERBY-2910 - Match current schema collation for implicit cast as we do for
      // explicit casts per SQL Spec 6.12 (10)         
      rightOperand.setCollationUsingCompilationSchema();
     
      ((CastNode) rightOperand).bindCastNodeOnly();
    }

    /*
     * * Set the result type of this operator based on the operands. * By
     * convention, the left operand gets to decide the result type * of a
     * binary operator.
     */
    tc = leftOperand.getTypeCompiler();
    setType(resolveConcatOperation(leftOperand.getTypeServices(),
        rightOperand.getTypeServices()));

    /*
     * * Make sure the maximum width set for the result doesn't exceed the
     * result type's maximum width
     */
    if (SanityManager.DEBUG) {
      if (getTypeServices().getMaximumWidth() > getTypeId()
          .getMaximumMaximumWidth()) {
        SanityManager
            .THROWASSERT("The maximum length "
                + getTypeServices().getMaximumWidth()
                + " for the result type "
                + getTypeId().getSQLTypeName()
                + " can't be greater than it's maximum width of result's typeid"
                + getTypeId().getMaximumMaximumWidth());
      }
    }

    /*
     * * Now that we know the target interface type, set it. This assumes *
     * that both operands have the same interface type, which is a safe *
     * assumption for the concatenation operator.
     */
    this.setLeftRightInterfaceType(tc.interfaceName());

        // Finally, fold constants so that for example LIKE optimization is
        // able to take advantage of concatenated literals like 'ab' || '%'.
        return this.evaluateConstantExpressions();
  }
View Full Code Here


  }

  /* cast arg to a varchar */
  protected ValueNode castArgToString(ValueNode vn) throws StandardException
  {
    TypeCompiler vnTC = vn.getTypeCompiler();
    if (! vn.getTypeId().isStringTypeId())
    {
      DataTypeDescriptor dtd = DataTypeDescriptor.getBuiltInDataTypeDescriptor(Types.VARCHAR, true,
                  vnTC.getCastToCharWidth(
                        vn.getTypeServices()));

            ValueNode newNode = new CastNode(vn, dtd, getContextManager());
           
            // DERBY-2910 - Match current schema collation for implicit cast as we do for
View Full Code Here

   */
    @Override
    void generateExpression(ExpressionClassBuilder acb, MethodBuilder mb)
                  throws StandardException {

    TypeCompiler    tc = getTypeCompiler();
        String fieldType = tc.interfaceName();

    /*
    ** NOTE: DO NOT CALL THE CONSTRUCTOR TO GENERATE ANYTHING.  IT HAS
    ** A DIFFERENT value FIELD.
    */
 
View Full Code Here

            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.REAL:
            case java.sql.Types.DOUBLE:
              TypeCompiler tc = getTypeCompiler(returnTypeId);
              requiredType = tc.getCorrespondingPrimitiveTypeName();
              if (!routineInfo.calledOnNullInput() && routineInfo.getParameterCount() != 0)
              {
                promoteName = returnTypeId.getCorrespondingJavaTypeName();
              }
              break;
View Full Code Here

       
          // how about the primitive name
      if ((paramTypeId.isNumericTypeId() && !paramTypeId.isDecimalTypeId())
          || paramTypeId.isBooleanTypeId())
      {
        TypeCompiler tc = getTypeCompiler(paramTypeId);
        if (type.equals(tc.getCorrespondingPrimitiveTypeName()))
        {
               signatureTypes[count - 1] = type;
              continue;         
        }
      }
View Full Code Here

                            TypeId  ctid = mapToTypeID( jsqlTyp );

              if ((ctid.isNumericTypeId() && !ctid.isDecimalTypeId()) || ctid.isBooleanTypeId())
              {
                TypeCompiler tc = getTypeCompiler(ctid);
                primParmTypeNames[i] = tc.getCorrespondingPrimitiveTypeName();
                if ( castToPrimitiveAsNecessary) { methodParms[i].castToPrimitive(true); }
              }
              else { primParmTypeNames[i] = ctid.getCorrespondingJavaTypeName(); }
            }
View Full Code Here

    bindOperand(fromList, subqueryList,
        aggregateVector);

    opTypeId = operand.getTypeId();
    operandType = opTypeId.getJDBCTypeId();
    TypeCompiler tc = operand.getTypeCompiler();

    /*
    ** Cast the operand, if necessary, - this function is allowed only on
    ** date/time types.  By default, we cast to DATE if extracting
    ** YEAR, MONTH or DAY and to TIME if extracting HOUR, MINUTE or
    ** SECOND.
    */
    if (opTypeId.isStringTypeId())
    {
      int castType = (extractField < 3) ? Types.DATE : Types.TIME;
      operand =  (ValueNode)
        getNodeFactory().getNode(
          C_NodeTypes.CAST_NODE,
          operand,
          DataTypeDescriptor.getBuiltInDataTypeDescriptor(castType, true,
                    tc.getCastToCharWidth(
                        operand.getTypeServices())),
          getContextManager());
      ((CastNode) operand).bindCastNodeOnly();

      opTypeId = operand.getTypeId();
View Full Code Here

            case java.sql.Types.SMALLINT:
            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.REAL:
            case java.sql.Types.DOUBLE:
              TypeCompiler tc = getTypeCompiler(returnTypeId);
              requiredType = tc.getCorrespondingPrimitiveTypeName();
              if (!routineInfo.calledOnNullInput() && routineInfo.getParameterCount() != 0)
              {
                promoteName = returnTypeId.getCorrespondingJavaTypeName();
              }
              break;
View Full Code Here

       
          // how about the primitive name
      if ((paramTypeId.isNumericTypeId() && !paramTypeId.isDecimalTypeId())
          || paramTypeId.isBooleanTypeId())
      {
        TypeCompiler tc = getTypeCompiler(paramTypeId);
        if (type.equals(tc.getCorrespondingPrimitiveTypeName()))
        {
               signatureTypes[count - 1] = type;
              continue;         
        }
      }
View Full Code Here

            case java.sql.Types.INTEGER:
            case java.sql.Types.BIGINT:
            case java.sql.Types.REAL:
            case java.sql.Types.DOUBLE:
              if (routineInfo != null) {
                TypeCompiler tc = getTypeCompiler(ctid);
                return tc.getCorrespondingPrimitiveTypeName();
              }
              // fall through
            default:
              return ctid.getCorrespondingJavaTypeName();
            }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.compile.TypeCompiler

Copyright © 2018 www.massapicom. 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.