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

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


      (getNodeType() != C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NODE) &&
      (getNodeType() != C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NOT_NULL_NODE))
      return;

    DataDictionary dd = getDataDictionary();
    ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
    int intArray[] = new int[1];
    intArray[0] = columnPosition;

    for (int index = 0; index < cdl.size(); index++)
    {
      ConstraintDescriptor existingConstraint =
                                        cdl.elementAt(index);
      if (!(existingConstraint instanceof KeyConstraintDescriptor))
        continue;

      if (!existingConstraint.columnIntersects(intArray))
        continue;
                              
      int constraintType = existingConstraint.getConstraintType();

      // cannot change the length of a column that is part of a
      // foreign key constraint. Must be an exact match between pkey
      // and fkey columns.
      if ((constraintType == DataDictionary.FOREIGNKEY_CONSTRAINT)
        &&
        (getNodeType() == C_NodeTypes.MODIFY_COLUMN_TYPE_NODE))
      {
        throw StandardException.newException(
           SQLState.LANG_MODIFY_COLUMN_FKEY_CONSTRAINT, name, existingConstraint.getConstraintName());
     
     
      else
      {
        // a column that is part of a primary key or unique constraint
                // is being made nullable; can't be done.
        if ((getNodeType() ==
           C_NodeTypes.MODIFY_COLUMN_CONSTRAINT_NODE) &&
          ((existingConstraint.getConstraintType() ==
           DataDictionary.PRIMARYKEY_CONSTRAINT) ||
           (existingConstraint.getConstraintType() ==
           DataDictionary.UNIQUE_CONSTRAINT)))
        {
        throw StandardException.newException(
           SQLState.LANG_MODIFY_COLUMN_EXISTING_CONSTRAINT, name);
        }
        // unique key or primary key.
        ConstraintDescriptorList
          refcdl = dd.getForeignKeys(existingConstraint.getUUID());
        
        if (refcdl.size() > 0)
        {
          throw StandardException.newException(
             SQLState.LANG_MODIFY_COLUMN_REFERENCED, name, refcdl.elementAt(0).getConstraintName());
        }
       
        // Make the statement dependent on the primary key constraint.
        getCompilerContext().createDependency(existingConstraint);
      }
View Full Code Here


  //do any checking needs to be done at bind time for rename table
  private void renameTableBind(DataDictionary dd)
    throws StandardException
  {
    /* Verify that there are no check constraints on the table */
    ConstraintDescriptorList constraintDescriptorList = dd.getConstraintDescriptors(td);
    int size =
      constraintDescriptorList == null ? 0 : constraintDescriptorList.size();

    ConstraintDescriptor constraintDescriptor;

    // go through all the constraints defined on the table
    for (int index = 0; index < size; index++)
    {
      constraintDescriptor = constraintDescriptorList.elementAt(index);
      // if it is a check constraint, error
      if (constraintDescriptor.getConstraintType() == DataDictionary.CHECK_CONSTRAINT)
      {
        throw StandardException.newException(
            SQLState.LANG_PROVIDER_HAS_DEPENDENT_OBJECT,
View Full Code Here

    ColumnDescriptor cd = td.getColumnDescriptor(newObjectName);
      if (cd != null)
        throw descriptorExistsException(cd, td);

    /* Verify that there are no check constraints using the column being renamed */
    ConstraintDescriptorList constraintDescriptorList =
      dd.getConstraintDescriptors(td);
    int size =
      constraintDescriptorList == null ? 0 : constraintDescriptorList.size();

    ConstraintDescriptor constraintDescriptor;
    ColumnDescriptorList checkConstraintCDL;
    int  checkConstraintCDLSize;

    // go through all the constraints defined on the table
    for (int index = 0; index < size; index++)
    {
      constraintDescriptor = constraintDescriptorList.elementAt(index);
      // if it is a check constraint, verify that column being
      // renamed is not used in it's sql
      if (constraintDescriptor.getConstraintType() == DataDictionary.CHECK_CONSTRAINT)
      {
        checkConstraintCDL = constraintDescriptor.getColumnDescriptors();
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

  {
    boolean[]  needsDeferredProcessing = new boolean[1];
    needsDeferredProcessing[0] = requiresDeferredProcessing();

    Vector    conglomVector = new Vector();
    relevantCdl = new ConstraintDescriptorList();
    relevantTriggers =  new GenericDescriptorList();

    FormatableBitSet  columnMap = UpdateNode.getUpdateReadMap(baseTable,
      updateColumnList, conglomVector, relevantCdl, relevantTriggers, needsDeferredProcessing );
View Full Code Here

    if (td != null)
    {
      //In case of alter table, get the already existing primary key and unique
      //key constraints for this table. And then we will compare them with  new
      //primary key/unique key constraint column lists.
      ConstraintDescriptorList cdl = dd.getConstraintDescriptors(td);
      ConstraintDescriptor cd;

      if (cdl != null) //table does have some pre-existing constraints defined on it
      {
        for (int i=0; i<cdl.size();i++)
        {
          cd = cdl.elementAt(i);
          //if the constraint type is not primary key or unique key, ignore it.
          if (cd.getConstraintType() == DataDictionary.PRIMARYKEY_CONSTRAINT ||
          cd.getConstraintType() == DataDictionary.UNIQUE_CONSTRAINT)
            constraintsVector.addElement(cd);
        }
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.