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

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


    if (cascadeOnRefKey)
    {
      ForeignKeyConstraintDescriptor fkcd;
      ReferencedKeyConstraintDescriptor cd;
      ConstraintDescriptorList cdl;

      cd = (ReferencedKeyConstraintDescriptor)conDesc;
      cdl = cd.getForeignKeyConstraints(ReferencedKeyConstraintDescriptor.ALL);
      int cdlSize = cdl.size();

      for(int index = 0; index < cdlSize; index++)
      {
        fkcd = (ForeignKeyConstraintDescriptor) cdl.elementAt(index);
        dm.invalidateFor(fkcd, DependencyManager.DROP_CONSTRAINT, lcc);
        fkcd.drop(lcc, true);
      }
 
      /*
 
View Full Code Here


  private void execGutsRenameTable
  (
           TableDescriptor td, Activation activation)
    throws StandardException
  {
    ConstraintDescriptorList constraintDescriptorList;
    ConstraintDescriptor constraintDescriptor;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();
    dm.invalidateFor(td, DependencyManager.RENAME, lcc);

    /* look for foreign key dependency on the table. If found any,
    use dependency manager to pass the rename action to the
    dependents. */
    constraintDescriptorList = dd.getConstraintDescriptors(td);
    for(int index=0; index<constraintDescriptorList.size(); index++)
    {
      constraintDescriptor = constraintDescriptorList.elementAt(index);
      if (constraintDescriptor instanceof ReferencedKeyConstraintDescriptor)
        dm.invalidateFor(constraintDescriptor, DependencyManager.RENAME, lcc);
    }

    // Drop the table
View Full Code Here

           TableDescriptor td, Activation activation)
    throws StandardException
  {
    ColumnDescriptor columnDescriptor = null;
    int columnPosition = 0;
    ConstraintDescriptorList constraintDescriptorList;
    ConstraintDescriptor constraintDescriptor;
    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    /* get the column descriptor for column to be renamed and
     * using it's position in the table, set the referenced
     * column map of the table indicating which column is being
     * renamed. Dependency Manager uses this to find out the
     * dependents on the column.
     */
    columnDescriptor = td.getColumnDescriptor(oldObjectName);
    columnPosition = columnDescriptor.getPosition();
    FormatableBitSet toRename = new FormatableBitSet(td.getColumnDescriptorList().size() + 1);
    toRename.set(columnPosition);
    td.setReferencedColumnMap(toRename);
   
    dm.invalidateFor(td, DependencyManager.RENAME, lcc);

    //look for foreign key dependency on the column.
    constraintDescriptorList = dd.getConstraintDescriptors(td);
    for(int index=0; index<constraintDescriptorList.size(); index++)
    {
      constraintDescriptor = constraintDescriptorList.elementAt(index);
      int[] referencedColumns = constraintDescriptor.getReferencedColumns();
      int numRefCols = referencedColumns.length;
      for (int j = 0; j < numRefCols; j++)
      {
        if ((referencedColumns[j] == columnPosition) &&
View Full Code Here

  private void dropAllConstraintDescriptors(TableDescriptor td, Activation activation)
    throws StandardException
  {
    ConstraintDescriptor        cd;
    ConstraintDescriptorList       cdl;
    ConstraintDescriptor         fkcd;
    ConstraintDescriptorList       fkcdl;
    LanguageConnectionContext      lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    cdl = dd.getConstraintDescriptors(td);
   
    /*
    ** First go, don't drop unique or primary keys.
    ** This will ensure that self-referential constraints
    ** will work ok, even if not cascading.
     */
    /* The current element will be deleted underneath
     * the loop, so we only increment the counter when
     * skipping an element. (HACK!)
     */
    for(int index = 0; index < cdl.size(); )
    {
      cd = cdl.elementAt(index);
      if (cd instanceof ReferencedKeyConstraintDescriptor)
      {
        index++;
        continue;
      }

      dm.invalidateFor(cd, DependencyManager.DROP_CONSTRAINT, lcc);
      cd.drop(lcc, true);
    }

    /*
     ** Referenced keys (unique or pk) constraints only
    */
    /* The current element will be deleted underneath
     * the loop. (HACK!)
     */
    while (cdl.size() > 0)
    {
      cd = cdl.elementAt(0);
      if (SanityManager.DEBUG)
      {
        if (!(cd instanceof ReferencedKeyConstraintDescriptor))
        {
          SanityManager.THROWASSERT("Constraint descriptor not an instance of " +
          "ReferencedKeyConstraintDescriptor as expected.  Is a "+ cd.getClass().getName());
        }
      }

      /*
      ** Drop the referenced constraint (after we got
      ** the primary keys) now.  Do this prior to
      ** droping the referenced keys to avoid performing
      ** a lot of extra work updating the referencedcount
      ** field of sys.sysconstraints.
      **
      ** Pass in false to dropConstraintsAndIndex so it
      ** doesn't clear dependencies, we'll do that ourselves.
      */
      cd.drop(lcc, false);

      /*
      ** If we are going to cascade, get all the
      ** referencing foreign keys and zap them first.
      */
      if (cascade)
      {
        /*
        ** Go to the system tables to get the foreign keys
        ** to be safe
        */

        fkcdl = dd.getForeignKeys(cd.getUUID());

        /*
        ** For each FK that references this key, drop
        ** it.
        */
        for(int inner = 0; inner < fkcdl.size(); inner++)
        {
          fkcd = (ConstraintDescriptor) fkcdl.elementAt(inner);
          dm.invalidateFor(fkcd, DependencyManager.DROP_CONSTRAINT, lcc);
          fkcd.drop(lcc, true);
          activation.addWarning(
            StandardException.newWarning(SQLState.LANG_CONSTRAINT_DROPPED,
               fkcd.getConstraintName(),
View Full Code Here

                    Long.toString(indexRows),
                    Long.toString(baseRowCount));
        }
      }
      /* check that all constraints have backing index */
      ConstraintDescriptorList constraintDescList =
        dd.getConstraintDescriptors(td);
      for (int index = 0; index < constraintDescList.size(); index++)
      {
        constraintDesc = constraintDescList.elementAt(index);
        if (constraintDesc.hasBackingIndex())
        {
          ConglomerateDescriptor conglomDesc;

          conglomDesc = td.getConglomerateDescriptor(
View Full Code Here

   */
  protected boolean hasCheckConstraints(DataDictionary dd,
                      TableDescriptor td)
    throws StandardException
  {
    ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
        if (cdl == null)
            return false;
    ConstraintDescriptorList ccCDL = cdl.getSubList(DataDictionary.CHECK_CONSTRAINT);

    return (ccCDL.size() > 0);
  }
View Full Code Here

    ConstraintDescriptorList  cdl,
    TableDescriptor        td
    )
    throws StandardException
  {
    ConstraintDescriptorList  ccCDL = cdl.getSubList(DataDictionary.CHECK_CONSTRAINT);
    int              ccCDLSize = ccCDL.size();
    ValueNode          checkTree = null;

    // Get the text of all the check constraints
    for (int index = 0; index < ccCDLSize; index++)
    {
      ConstraintDescriptor cd = ccCDL.elementAt(index);

      String constraintText = cd.getConstraintText();

      // Get the query tree for this constraint
      ValueNode oneConstraint =
View Full Code Here

    Vector                fkVector = new Vector(10);
    int                 type;
    UUID[]                 uuids = null;
    long[]                 conglomNumbers = null;
    String[]              fkNames = null;
    ConstraintDescriptorList      fkcdl;
    ReferencedKeyConstraintDescriptor  refcd;
    boolean[]              isSelfReferencingFK;
    ConstraintDescriptorList      activeList = dd.getActiveConstraintDescriptors(cdl);
    int[]                rowMap = getRowMap(readColsBitSet, td);
    int[]                               raRules = null;
    Vector                              refTableNames = new Vector(1);
    Vector                              refIndexConglomNum = new Vector(1);
    Vector                              refActions = new Vector(1);
    Vector                              refColDescriptors = new Vector(1);
    Vector                              fkColMap = new Vector(1);
    int activeSize = activeList.size();
    for (int index = 0; index < activeSize; index++)
    {
      ConstraintDescriptor cd = activeList.elementAt(index);

      if (cd instanceof ForeignKeyConstraintDescriptor)
      {
        /*
        ** We are saving information for checking the
View Full Code Here

      ** the index number will change, so we'll add a
      ** dependency on all tables we will scan.
      */
      if (cd instanceof ReferencedKeyConstraintDescriptor)
      { 
        ConstraintDescriptorList fkcdl = dd.getActiveConstraintDescriptors
          ( ((ReferencedKeyConstraintDescriptor)cd).getForeignKeyConstraints(ConstraintDescriptor.ENABLED) );
 
        int fklSize = fkcdl.size();
        for (int inner = 0; inner < fklSize; inner++)
        {
          ConstraintDescriptor fkcd = fkcdl.elementAt(inner);
          if (dependent == null)
          {
            compilerContext.createDependency(fkcd);
            compilerContext.createDependency(fkcd.getTableDescriptor());
          }
View Full Code Here

    throws StandardException
  {
    if ( relevantCdl != null ) { return relevantCdl; }

    boolean[]  needsDeferredProcessing = new boolean[1];
    relevantCdl = new ConstraintDescriptorList();

    needsDeferredProcessing[0] = requiresDeferredProcessing;
    td.getAllRelevantConstraints
      ( statementType, skipCheckConstraints, changedColumnIds,
        needsDeferredProcessing, relevantCdl );
View Full Code Here

TOP

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

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.