Package org.apache.derby.iapi.sql.dictionary

Examples of org.apache.derby.iapi.sql.dictionary.ColumnDescriptor


    int[] baseCols = cd.getIndexDescriptor().baseColumnPositions();
    ExecRow row = getExecutionFactory().getValueRow(baseCols.length + 1);

    for (int i = 0; i < baseCols.length; i++)
    {
      ColumnDescriptor coldes = td.getColumnDescriptor(baseCols[i]);
      DataTypeDescriptor dataType = coldes.getType();

      // rc = getResultColumn(baseCols[i]);
        // rc = (ResultColumn) at(baseCols[i] - 1);
      // dataType = rc.getTypeServices();
      DataValueDescriptor dataValue = dataType.getNull();
View Full Code Here


  public ResultColumnList expandToAll(TableDescriptor td,
                TableName tableName)
            throws StandardException
  {
    ResultColumn        rc;
    ColumnDescriptor      cd;
    ResultColumnList      retval;
    ResultColumn[]        originalRCS;
    int              posn;

    /* Get a new ResultColumnList */
    retval = (ResultColumnList) getNodeFactory().getNode(
                    C_NodeTypes.RESULT_COLUMN_LIST,
                    getContextManager());

    /*
    ** Form a sorted array of the ResultColumns
    */
    originalRCS = getSortedByPosition();

    posn = 0;
    /* Iterate through the ColumnDescriptors for the given table */
    ColumnDescriptorList cdl = td.getColumnDescriptorList();
    int           cdlSize = cdl.size();

    for (int index = 0; index < cdlSize; index++)
    {
      cd = (ColumnDescriptor) cdl.elementAt(index);

      if ((posn < originalRCS.length) &&
        (cd.getPosition() == originalRCS[posn].getColumnPosition()))
      {
        rc = originalRCS[posn];
        posn++;
      }
      else
      {
        /* Build a ResultColumn/ColumnReference pair for the column */
        rc = makeColumnReferenceFromName( tableName, cd.getColumnName() );

        /* Bind the new ResultColumn */
        rc.bindResultColumnByPosition(td, cd.getPosition());
      }

      /* Add the ResultColumn to the list */
      retval.addResultColumn(rc);
    }
 
View Full Code Here

            //
            if ( forUpdate && !rc.updated() ) { continue; }
           
            if ( rc.hasGenerationClause() )
            {
                ColumnDescriptor    colDesc = rc.getTableColumnDescriptor();
                DataTypeDescriptor  dtd = colDesc.getType();
                DefaultInfo             di = colDesc.getDefaultInfo();
                ValueNode   generationClause = parseGenerationClause( di.getDefaultText(), targetTableDescriptor );

                // insert CAST in case column data type is not same as the
                // resolved type of the generation clause
                generationClause = (ValueNode) getNodeFactory().getNode
View Full Code Here

        raRules = new int[size];
        ForeignKeyConstraintDescriptor fkcd = null;
        TableDescriptor fktd;
        ColumnDescriptorList coldl;
        int[] refColumns;
        ColumnDescriptor cold;
        int[] colArray = remapReferencedColumns(cd, rowMap);
        for (int inner = 0; inner < size; inner++)
        {
          fkcd = (ForeignKeyConstraintDescriptor) fkcdl.elementAt(inner);
          fkSetupArrays(dd, fkcd,
View Full Code Here

          throw StandardException.newException(SQLState.LANG_DUPLICATE_COLUMN_IN_TRIGGER_UPDATE,
                      rc.getName(),
                      triggerName);
        }

        ColumnDescriptor cd = triggerTableDescriptor.getColumnDescriptor(rc.getName());
        if (cd == null)
        {
          throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE,
                                rc.getName(),
                                tableName);
View Full Code Here

      //If the trigger is defined on speific columns, then collect
      //their column positions and ensure that those columns do
      //indeed exist in the trigger table.
      referencedColInts = new int[triggerCols.size()];
      ResultColumn rc;
      ColumnDescriptor cd;
      //This is the most interesting case for us. If we are here,
      //then it means that the trigger is defined at the row level
      //and a set of trigger columns are specified in the CREATE
      //TRIGGER statement. This can only happen for an UPDATE
      //trigger.
      //eg
      //CREATE TRIGGER tr1 AFTER UPDATE OF c12 ON table1
      //    REFERENCING OLD AS oldt NEW AS newt
      //    FOR EACH ROW UPDATE table2 SET c24=oldt.c14;
     
      for (int i=0; i < triggerCols.size(); i++){
        rc = (ResultColumn)triggerCols.elementAt(i);
        cd = triggerTableDescriptor.getColumnDescriptor(rc.getName());
        //Following will catch the case where an invalid trigger column
        //has been specified in CREATE TRIGGER statement.
        //CREATE TRIGGER tr1 AFTER UPDATE OF c1678 ON table1
        //    REFERENCING OLD AS oldt NEW AS newt
        //    FOR EACH ROW UPDATE table2 SET c24=oldt.c14;
        if (cd == null)
        {
          throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE,
                                rc.getName(),
                                tableName);
        }
        referencedColInts[i] = cd.getPosition();
      }
      // sort the list
      java.util.Arrays.sort(referencedColInts);
    }
   
View Full Code Here

                      UUID           uuid,
                      ColumnDescriptorList   cdl,
                      TupleDescriptor     td)
      throws StandardException
  {
    ColumnDescriptor    cd;
    ColumnDescriptorList    cdlCopy         = new ColumnDescriptorList();
    DataValueDescriptor    refIDOrderable  = null;
    TabInfoImpl                 ti              = coreInfo[SYSCOLUMNS_CORE_NUM];

    /* Use refIDOrderable in both start and stop position for scan. */
    refIDOrderable = getIDValueAsCHAR(uuid);

    /* Set up the start/stop position for the scan */
    ExecIndexRow keyRow = exFactory.getIndexableRow(1);
    keyRow.setColumn(1, refIDOrderable);

    getDescriptorViaIndex(
            SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID,
            keyRow,
            (ScanQualifier [][]) null,
            ti,
            td,
            (ColumnDescriptorList) cdl,
            false);

    /* The TableDescriptor's column descriptor list must be ordered by
     * columnNumber.  (It is probably not ordered correctly at this point due
     * to the index on syscolumns being on (tableId, columnName).)  The
     * cheapest way to reorder the list appears to be to copy it (above), and then
     * walk the copy and put the elements back into the original in the
     * expected locations.
     */
    int cdlSize = cdl.size();
    for (int index = 0; index < cdlSize; index++)
    {
      cdlCopy.add( cdl.get(index));
    }
    for (int index = 0; index < cdlSize; index++)
    {
      cd = (ColumnDescriptor) cdlCopy.elementAt(index);
      cdl.set(cd.getPosition() - 1, cd);
    }
  }
View Full Code Here

    for (int index = 0; index < pdlSize; index++)
    {
      int parameterId = index + 1;

      //RESOLVEAUTOINCREMENT
      ColumnDescriptor cd =
                new ColumnDescriptor(
                    "PARAM" + parameterId,
                    parameterId,  // position
          params[index],
                    ((parameterDefaults == null) || // default
                        (index >= parameterDefaults.length)) ?
View Full Code Here

    int cdlSize = cdl.size();
    DataTypeDescriptor[] params = new DataTypeDescriptor[cdlSize]
    for (int index = 0; index < cdlSize; index++)
    {
      ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
      params[index] = cd.getType();
            if (defaults != null) {
                defaults.add(cd.getDefaultValue());
      }
    }

    return params; 
  }
View Full Code Here

      for (int index = 0; index < params.length; index++)
      {
        int parameterId = index + 1;

      //RESOLVEAUTOINCREMENT
        ColumnDescriptor cd = new ColumnDescriptor("PARAM" + parameterId,
                      parameterId,  // position
                      params[index],
                      ((parameterDefaults == null) || // default
                       (index >= parameterDefaults.length)) ?
                      (DataValueDescriptor)null :
                      (DataValueDescriptor)parameterDefaults[index],
                      (DefaultInfo) null,
                      uuid,
                      (UUID) null,
                      0, 0, 0);
                   
        updateColumnDescriptor(cd,
                     cd.getReferencingUUID(),
                     cd.getColumnName(),
                     columnsToSet,
                     tc);
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.dictionary.ColumnDescriptor

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.