Package org.apache.derby.catalog

Examples of org.apache.derby.catalog.TypeDescriptor


/*
* <A NAME="parameterTypeList">parameterTypeList</A>
*/
  final public List parameterTypeList() throws ParseException, StandardException {
    ArrayList list = new ArrayList();
    TypeDescriptor type;
    if (jj_2_80(1)) {
      type = catalogType();
            list.add(type);
      label_41:
      while (true) {
View Full Code Here


    Compare if two TypeDescriptors are exactly the same
    @param object the dataTypeDescriptor to compare to.
    */
  public boolean equals(Object object)
  {
    TypeDescriptor typeDescriptor = (TypeDescriptor)object;

    if(!this.getTypeName().equals(typeDescriptor.getTypeName()) ||
       this.precision != typeDescriptor.getPrecision() ||
       this.scale != typeDescriptor.getScale() ||
       this.isNullable != typeDescriptor.isNullable() ||
       this.maximumWidth != typeDescriptor.getMaximumWidth())
       return false;
      else
      {
      switch (typeId.getJDBCTypeId()) {
      case Types.CHAR:
      case Types.VARCHAR:
      case Types.LONGVARCHAR:
      case Types.CLOB:
        //if we are dealing with character types, then we should
        //also compare the collation information on them.
        if(this.collationType != typeDescriptor.getCollationType())
          return false;
        else
          return true;
      default:
        //no collation checking required if we are dealing with
View Full Code Here

    TransactionController tc = lcc.getTransactionExecute();
        RoutineAliasInfo      aliasInfo = (RoutineAliasInfo) ad.getAliasInfo();
        HashMap               addUdtMap = new HashMap();
        HashMap               dropUdtMap = new HashMap();
        HashMap               udtMap = adding ? addUdtMap : dropUdtMap;
        TypeDescriptor        rawReturnType = aliasInfo.getReturnType();

        if ( rawReturnType != null )
        {
            AliasDescriptor       returnTypeAD = dd.getAliasDescriptorForUDT
                ( tc, DataTypeDescriptor.getType( rawReturnType ) );

            if ( returnTypeAD != null ) { udtMap.put( returnTypeAD.getObjectID().toString(), returnTypeAD ); }
        }

        // table functions can have udt columns. track those dependencies.
        if ( (rawReturnType != null) && rawReturnType.isRowMultiSet() )
        {
            TypeDescriptor[] columnTypes = rawReturnType.getRowTypes();
            int columnCount = columnTypes.length;

            for ( int i = 0; i < columnCount; i++ )
            {
                AliasDescriptor       columnTypeAD = dd.getAliasDescriptorForUDT
View Full Code Here

    if (routineInfo != null)
    {
      if (methodParms != null)
        optimizeDomainValueConversion();
     
      TypeDescriptor returnType = routineInfo.getReturnType();

            // create type dependency if return type is an ANSI UDT
            if ( returnType != null ) { createTypeDependency( DataTypeDescriptor.getType( returnType ) ); }

      if ( returnType != null && !returnType.isRowMultiSet() && !returnType.isUserDefinedType() )
      {
        TypeId returnTypeId = TypeId.getBuiltInTypeId(returnType.getJDBCTypeId());

        if (returnTypeId.variableLength()) {
          // Cast the return using a cast node, but have to go
          // into the SQL domain, and back to the Java domain.

          DataTypeDescriptor returnValueDtd = new DataTypeDescriptor(
                returnTypeId,
                returnType.getPrecision(),
                returnType.getScale(),
                returnType.isNullable(),
                returnType.getMaximumWidth()
              );
             

          ValueNode returnValueToSQL = (ValueNode) getNodeFactory().getNode(
                C_NodeTypes.JAVA_TO_SQL_VALUE_NODE,
                this,
                getContextManager());

          ValueNode returnValueCastNode = (ValueNode) getNodeFactory().getNode(
                  C_NodeTypes.CAST_NODE,
                  returnValueToSQL,
                  returnValueDtd,
                  getContextManager());
                   
                    // DERBY-2972  Match the collation of the RoutineAliasInfo
                    returnValueCastNode.setCollationInfo(
                            returnType.getCollationType(),
                            StringDataValue.COLLATION_DERIVATION_IMPLICIT);


          JavaValueNode returnValueToJava = (JavaValueNode) getNodeFactory().getNode(
                    C_NodeTypes.SQL_TO_JAVA_VALUE_NODE,
                    returnValueCastNode,
                    getContextManager());
          returnValueToJava.setCollationType(returnType.getCollationType());
          return returnValueToJava.bindExpression(fromList, subqueryList, aggregateVector);
        }

      }
    }
View Full Code Here

      signature = new JSQLType[sigParameterCount];
      for (int p = 0; p < parameterCount; p++) {

        // find the declared type.

        TypeDescriptor td = parameterTypes[p];

        TypeId typeId = TypeId.getTypeId(td);

        TypeId parameterTypeId = typeId;


        // if it's an OUT or INOUT parameter we need an array.
        int parameterMode = rai.getParameterModes()[ getRoutineArgIdx( rai, p ) ];

        if (parameterMode != JDBC30Translation.PARAMETER_MODE_IN) {

          String arrayType;
          switch (typeId.getJDBCTypeId()) {
            case java.sql.Types.BOOLEAN:
            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:
              arrayType = getTypeCompiler(typeId).getCorrespondingPrimitiveTypeName().concat("[]");
              break;
            default:
              arrayType = typeId.getCorrespondingJavaTypeName().concat("[]");
              break;
          }

          typeId = TypeId.getUserDefinedTypeId(arrayType);
        }

        // this is the type descriptor of the require method parameter
        DataTypeDescriptor methoddtd = new DataTypeDescriptor(
            typeId,
            td.getPrecision(),
            td.getScale(),
            td.isNullable(),
            td.getMaximumWidth()
          );

        signature[p] = new JSQLType(methoddtd);

        // this is the SQL type of the procedure parameter.
        DataTypeDescriptor paramdtd = new DataTypeDescriptor(
          parameterTypeId,
          td.getPrecision(),
          td.getScale(),
          td.isNullable(),
          td.getMaximumWidth()
        );

                //
                // Now coerce the actual method parameter to the declared type
                // of this routine arg.
View Full Code Here

  public void checkUserType(TableDescriptor td)
    throws StandardException
  {
    ColumnDescriptor cd;
    TypeDescriptor oldType;
    DataTypeDescriptor newType = dataTypeServices;
    TypeId oldTypeId;
    TypeId newTypeId;

    if (getNodeType() != C_NodeTypes.MODIFY_COLUMN_TYPE_NODE)
      return;        // nothing to do if user not changing length

    cd = td.getColumnDescriptor(name);
    if (cd == null)
    {
      throw StandardException.newException(
        SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE, name, td.getName());
    }
   
    oldType = cd.getType();
    oldTypeId = cd.getType().getTypeId();
    newTypeId = dataTypeServices.getTypeId();
    newType.setNullability(oldType.isNullable());

    // can't change types yet.
    if (!(oldTypeId.equals(newTypeId)))
    {
      throw StandardException.newException(
           SQLState.LANG_MODIFY_COLUMN_CHANGE_TYPE, name);
    }     
   
    // can only alter the length of varchar, nvarchar, bitvarying columns
    String typeName = dataTypeServices.getTypeName();
    if (!(typeName.equals(TypeId.NATIONAL_VARCHAR_NAME)) &&
      !(typeName.equals(TypeId.VARCHAR_NAME)) &&
      !(typeName.equals(TypeId.VARBIT_NAME)))
    {
      throw StandardException.newException(
             SQLState.LANG_MODIFY_COLUMN_INVALID_TYPE);
    }
   
    // cannot decrease the length of a column
    if (newType.getMaximumWidth() < oldType.getMaximumWidth())
    {
      throw StandardException.newException(
             SQLState.LANG_MODIFY_COLUMN_INVALID_LENGTH, name);
    }
  }
View Full Code Here

       
        AliasDescriptor ad = DataDictionaryImpl.SYSFUN_AD[f];
        if (ad == null)
        {
          // details[1] Return type
          TypeDescriptor rt =
            DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]);

          // details[4] - zero or single argument type
          String paramType = details[4];
          TypeDescriptor[] pt;
View Full Code Here

       
        AliasDescriptor ad = DataDictionaryImpl.SYSFUN_AD[f];
        if (ad == null)
        {
          // details[1] Return type
          TypeDescriptor rt =
            DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]);

          // details[4] - zero or single argument type
          String paramType = details[4];
          TypeDescriptor[] pt;
View Full Code Here

    TransactionController   tc)
        throws StandardException
    {
        // Safe to re-use a TypeDescriptor here as they are
        // not modified during the creation of the routine
        TypeDescriptor varchar128 =
            DataTypeDescriptor.getBuiltInDataTypeDescriptor(
                    Types.VARCHAR, 128);

        UUID  sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
        /* SYSCS_EXPORT_TABLE_LOBS_TO_EXTFILE(IN SCHEMANAME  VARCHAR(128),
View Full Code Here

       
        AliasDescriptor ad = DataDictionaryImpl.SYSFUN_AD[f];
        if (ad == null)
        {
          // details[1] Return type
          TypeDescriptor rt =
            DataTypeDescriptor.getBuiltInDataTypeDescriptor(details[1]).getCatalogType();

                    boolean isDeterministic = Boolean.valueOf( details[ SYSFUN_DETERMINISTIC_INDEX ] ).booleanValue();
                   
                    // Determine the number of arguments (could be zero).
View Full Code Here

TOP

Related Classes of org.apache.derby.catalog.TypeDescriptor

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.