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

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


                    columnNumber + 1, td );
    }
    addDescriptorArray(cdlArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc);
   
    // now add the columns to the cdl of the table.
    ColumnDescriptorList cdl = td.getColumnDescriptorList();
    for (int i = 0; i < columnCount; i++)
      cdl.add(cdlArray[i]);
  }
View Full Code Here


    /* Add all of the columns in the table */
    rcList = (ResultColumnList) getNodeFactory().getNode(
                    C_NodeTypes.RESULT_COLUMN_LIST,
                    getContextManager());
    ColumnDescriptorList cdl = tableDescriptor.getColumnDescriptorList();
    int           cdlSize = cdl.size();

    for (int index = 0; index < cdlSize; index++)
    {
      /* Build a ResultColumn/BaseColumnNode pair for the column */
      colDesc = (ColumnDescriptor) cdl.elementAt(index);
      //A ColumnDescriptor instantiated through SYSCOLUMNSRowFactory only has
      //the uuid set on it and no table descriptor set on it. Since we know here
      //that this columnDescriptor is tied to tableDescriptor, set it so using
      //setTableDescriptor method. ColumnDescriptor's table descriptor is used
      //to get ResultSetMetaData.getTableName & ResultSetMetaData.getSchemaName
View Full Code Here

    /* Add all of the columns in the table */
    ResultColumnList newRcl = (ResultColumnList) getNodeFactory().getNode(
                        C_NodeTypes.RESULT_COLUMN_LIST,
                        getContextManager());
    ColumnDescriptorList cdl = tableDescriptor.getColumnDescriptorList();
    int           cdlSize = cdl.size();

    for (int index = 0; index < cdlSize; index++)
    {
      /* Build a ResultColumn/BaseColumnNode pair for the column */
      cd = (ColumnDescriptor) cdl.elementAt(index);
      int position = cd.getPosition();

      if (!colsWeWant.get(position))
      {
        continue;
View Full Code Here

        conglomNumbers = new long[size];
        isSelfReferencingFK = new boolean[size];
        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,
                inner, uuids, conglomNumbers, fkNames,
                isSelfReferencingFK, raRules);
          if((raRules[inner] == StatementType.RA_CASCADE) ||
             (raRules[inner] ==StatementType.RA_SETNULL))
          {
            //find  the referencing  table Name
            fktd = fkcd.getTableDescriptor();
            refTableNames.addElement(fktd.getSchemaName() + "." + fktd.getName());
            refActions.addElement(new Integer(raRules[inner]));
            //find the referencing column name required for update null.
            refColumns = fkcd.getReferencedColumns();
            coldl = fktd.getColumnDescriptorList();
            ColumnDescriptorList releventColDes = new ColumnDescriptorList();
            for(int i = 0 ; i < refColumns.length; i++)
            {
              cold =(ColumnDescriptor)coldl.elementAt(refColumns[i]-1);
              releventColDes.add(cold);
            }
            refColDescriptors.addElement(releventColDes);
            refIndexConglomNum.addElement(new Long(conglomNumbers[inner]));
            fkColMap.addElement(colArray);
          }
View Full Code Here

                lcc.getExecutionContext().getExecutionFactory().getValueRow(
                    td.getNumberOfColumns());


      /* Fill the row with nulls of the correct type */
      ColumnDescriptorList cdl = td.getColumnDescriptorList();
      int           cdlSize = cdl.size();

      for (int index = 0; index < cdlSize; index++)
      {
        ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
        baseRow.setColumn(cd.getPosition(), cd.getType().getNull());
      }

            DataValueDescriptor[][] row_array = new DataValueDescriptor[100][];
            row_array[0] = baseRow.getRowArray();
View Full Code Here

      /* Get a row template for the base table */
      baseRow = ec.getExecutionFactory().getValueRow(td.getNumberOfColumns());

      /* Fill the row with nulls of the correct type */
      ColumnDescriptorList cdl = td.getColumnDescriptorList();
      int           cdlSize = cdl.size();

      for (int index = 0; index < cdlSize; index++)
      {
        ColumnDescriptor cd = (ColumnDescriptor) cdl.elementAt(index);
        baseRow.setColumn(cd.getPosition(),
                    cd.getType().getNull());
      }

      /* Look at all the indexes on the table */
 
View Full Code Here

                      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 = getValueAsDVD(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

   * @exception StandardException    Thrown on error
   */
  public DataTypeDescriptor[] getSPSParams(SPSDescriptor spsd, Vector defaults)
    throws StandardException
  {
    ColumnDescriptorList cdl = new ColumnDescriptorList();
    getColumnDescriptorsScan(spsd.getUUID(), cdl, spsd);

    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.addElement(cd.getDefaultValue());
      }
View Full Code Here

                    columnNumber + 1, td );
    }
    addDescriptorArray(cdlArray, td, SYSCOLUMNS_CATALOG_NUM, false, tc);
   
    // now add the columns to the cdl of the table.
    ColumnDescriptorList cdl = td.getColumnDescriptorList();
    for (int i = 0; i < columnCount; i++)
      cdl.add(cdlArray[i]);
  }
View Full Code Here

      }

      // for each related column, stuff system.column
      for (int ix = 0; ix < columnInfo.length; ix++)
      {
        ColumnDescriptorList cdl = new ColumnDescriptorList();

        /* If there is a default value, use it, otherwise use null */
       
        // Are we adding a new column or modifying a default?
       
        if (columnInfo[ix].action == ColumnInfo.CREATE)
        {
          addNewColumnToTable(activation, ix);
        }
        else if (columnInfo[ix].action ==
             ColumnInfo.MODIFY_COLUMN_DEFAULT_RESTART ||
             columnInfo[ix].action == ColumnInfo.MODIFY_COLUMN_DEFAULT_INCREMENT)
        {
          modifyColumnDefault(activation, ix);
        }
        else if (columnInfo[ix].action ==
             ColumnInfo.MODIFY_COLUMN_TYPE)
        {
          modifyColumnType(activation, ix);
        }
        else if (columnInfo[ix].action ==
             ColumnInfo.MODIFY_COLUMN_CONSTRAINT)
        {
          modifyColumnConstraint(activation, columnInfo[ix].name, true);
        }
        else if (columnInfo[ix].action ==
             ColumnInfo.MODIFY_COLUMN_CONSTRAINT_NOT_NULL)
        {
          if (! tableScanned)
          {
            tableScanned = true;
            numRows = getSemiRowCount(tc);
          }
          // check that the data in the column is not null
          String colNames[] = new String[1];
          colNames[0] = columnInfo[ix].name;
          boolean nullCols[] = new boolean[1];

          /* note validateNotNullConstraint returns true if the
           * column is nullable
           */
          if (validateNotNullConstraint(colNames, nullCols,
              numRows, lcc, SQLState.LANG_NULL_DATA_IN_NON_NULL_COLUMN))
          {
            /* nullable column - modify it to be not null
             * This is O.K. at this point since we would have
             * thrown an exception if any data was null
             */
            modifyColumnConstraint(activation, columnInfo[ix].name, false);
          }
        }
        else if (columnInfo[ix].action == ColumnInfo.DROP)
        {
          dropColumnFromTable(activation, ix);
        }
        else if (SanityManager.DEBUG)
        {
          SanityManager.THROWASSERT(
                "Unexpected action in AlterTableConstantAction");
        }
      }
    }

    /* Create/Drop any constraints */
    if (constraintActions != null)
    {
      for (int conIndex = 0; conIndex < constraintActions.length; conIndex++)
      {
        ConstraintConstantAction cca = constraintActions[conIndex];

        if (cca instanceof CreateConstraintConstantAction)
        {
          int constraintType = cca.getConstraintType();

          /* Some constraint types require special checking:
           *    Check    - table must be empty, for now
           *    Primary Key - table cannot already have a primary key
           */
          switch (constraintType)
          {
            case DataDictionary.PRIMARYKEY_CONSTRAINT:
              // Check to see if a constraint of the same type already exists
              ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
              if (cdl.getPrimaryKey() != null)
              {
                throw StandardException.newException(SQLState.LANG_ADD_PRIMARY_KEY_FAILED1,
                      td.getQualifiedName());
              }
              if (! tableScanned)
View Full Code Here

TOP

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

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.