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

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


  {
    ExecIndexRow        keyRow1 = null;
    ExecRow              row;
    DataValueDescriptor      IDOrderable;
    DataValueDescriptor      columnNameOrderable;
    TabInfo            ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    SYSCONSTRAINTSRowFactory    rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();

    /* Use objectID/columnName in both start
     * and stop position for index 1 scan.
     */
    IDOrderable = getValueAsDVD(formerUUID);

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

    // build the row to be stuffed into SYSCONSTRAINTS.
    row = rf.makeRow(cd, null);

    /*
    ** Figure out if the index in sysconstraints needs
    ** to be updated.
    */
    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(rf.getNumIndexes() == 3,
          "There are more indexes on sysconstraints than expected, the code herein needs to change");
    }

    boolean[] bArray = new boolean[3];

    /*
    ** Do we need to update indexes?
    */
    if (colsToSet == null)
    {
      bArray[0] = true;
      bArray[1] = true;
      bArray[2] = true;
    }
    else
    {
      /*
      ** Check the specific columns for indexed
      ** columns.
      */
      for (int i = 0; i < colsToSet.length; i++)
      {
        switch (colsToSet[i])
        {
          case SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_CONSTRAINTID:
            bArray[0] = true;
            break;

          case SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_CONSTRAINTNAME:
          case SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_SCHEMAID:
            bArray[1] = true;
            break;
         
          case SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_TABLEID:
            bArray[2] = true;
            break;
        }
      }
    }

    ti.updateRow(keyRow1, row,
           SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX1_ID,
           bArray,
           colsToSet,
           tc);
  }
View Full Code Here


    throws StandardException
  {
    ExecIndexRow      keyRow = null;
    DataValueDescriptor    schemaIDOrderable;
    DataValueDescriptor    constraintNameOrderable;
    TabInfo          ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);

    switch (descriptor.getConstraintType())
    {
      case DataDictionary.PRIMARYKEY_CONSTRAINT:
      case DataDictionary.FOREIGNKEY_CONSTRAINT:
      case DataDictionary.UNIQUE_CONSTRAINT:
        dropSubKeyConstraint(
              descriptor,
              tc);
        break;

      case DataDictionary.CHECK_CONSTRAINT:
        dropSubCheckConstraint(
              descriptor.getUUID(),
              tc);
        break;
    }

    /* Use constraintNameOrderable and schemaIdOrderable in both start
     * and stop position for index 2 scan.
     */
    constraintNameOrderable = dvf.getVarcharDataValue(descriptor.getConstraintName());
    schemaIDOrderable = getValueAsDVD(descriptor.getSchemaDescriptor().getUUID());

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

    ti.deleteRow( tc, keyRow, SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX2_ID );
  }
View Full Code Here

   */
  public SubKeyConstraintDescriptor getSubKeyConstraint(UUID constraintId, int type)
    throws StandardException
  {
    DataValueDescriptor    constraintIDOrderable = null;
    TabInfo          ti;
    int            indexNum;
    int            baseNum;

    if (type == DataDictionary.FOREIGNKEY_CONSTRAINT)
    {
View Full Code Here

  private void addSubKeyConstraint(KeyConstraintDescriptor descriptor,
                   TransactionController tc)
    throws StandardException
  {
    ExecRow  row;
    TabInfo  ti;

    /*
    ** Foreign keys get a row in SYSFOREIGNKEYS, and
    ** all others get a row in SYSKEYS.
    */
    if (descriptor.getConstraintType()
        == DataDictionary.FOREIGNKEY_CONSTRAINT)
    {
      ForeignKeyConstraintDescriptor fkDescriptor =
          (ForeignKeyConstraintDescriptor)descriptor;

      if (SanityManager.DEBUG)
      {
        if (!(descriptor instanceof ForeignKeyConstraintDescriptor))
        {
          SanityManager.THROWASSERT("descriptor not an fk descriptor, is "+
            descriptor.getClass().getName());
        }
      }
     
      ti = getNonCoreTI(SYSFOREIGNKEYS_CATALOG_NUM);
      SYSFOREIGNKEYSRowFactory fkkeysRF = (SYSFOREIGNKEYSRowFactory)ti.getCatalogRowFactory();

      row = fkkeysRF.makeRow(fkDescriptor, null);

      /*
      ** Now we need to bump the reference count of the
      ** contraint that this FK references
      */
      ReferencedKeyConstraintDescriptor refDescriptor =
              fkDescriptor.getReferencedConstraint();

      refDescriptor.incrementReferenceCount();

      int[] colsToSet = new int[1];
      colsToSet[0] = SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_REFERENCECOUNT;

      updateConstraintDescriptor(refDescriptor,
                      refDescriptor.getUUID(),
                      colsToSet,
                      tc);
    }
    else
    {
      ti = getNonCoreTI(SYSKEYS_CATALOG_NUM);
      SYSKEYSRowFactory keysRF = (SYSKEYSRowFactory) ti.getCatalogRowFactory();

      // build the row to be stuffed into SYSKEYS
      row = keysRF.makeRow(descriptor, null);
    }

    // insert row into catalog and all its indices
    ti.insertRow(row, tc, true);
  }
View Full Code Here

  private void dropSubKeyConstraint(ConstraintDescriptor constraint, TransactionController tc)
    throws StandardException
  {
    ExecIndexRow      keyRow1 = null;
    DataValueDescriptor    constraintIdOrderable;
    TabInfo          ti;
    int            baseNum;
    int            indexNum;

    if (constraint.getConstraintType()
        == DataDictionary.FOREIGNKEY_CONSTRAINT)
    {
      baseNum = SYSFOREIGNKEYS_CATALOG_NUM;
      indexNum = SYSFOREIGNKEYSRowFactory.SYSFOREIGNKEYS_INDEX1_ID;

      /*
      ** If we have a foreign key, we need to decrement the
      ** reference count of the contraint that this FK references.
      ** We need to do this *before* we drop the foreign key
      ** because of the way FK.getReferencedConstraint() works. 
      */
      if (constraint.getConstraintType()
          == DataDictionary.FOREIGNKEY_CONSTRAINT)
      {
        ReferencedKeyConstraintDescriptor refDescriptor =
            (ReferencedKeyConstraintDescriptor)
                getConstraintDescriptor(
                  ((ForeignKeyConstraintDescriptor)constraint).
                      getReferencedConstraintId());

        if (refDescriptor != null)
        {
          refDescriptor.decrementReferenceCount();
 
          int[] colsToSet = new int[1];
          colsToSet[0] = SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_REFERENCECOUNT;
   
          updateConstraintDescriptor(refDescriptor,
                        refDescriptor.getUUID(),
                        colsToSet,
                        tc);
        }
      }
    }
    else
    {
      baseNum = SYSKEYS_CATALOG_NUM;
      indexNum = SYSKEYSRowFactory.SYSKEYS_INDEX1_ID;
    }

    ti = getNonCoreTI(baseNum);

    /* Use constraintIdOrderable in both start
     * and stop position for index 1 scan.
     */
    constraintIdOrderable = getValueAsDVD(constraint.getUUID());

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

    ti.deleteRow( tc, keyRow1, indexNum);
  }
View Full Code Here

   */
  private SubCheckConstraintDescriptor getSubCheckConstraint(UUID constraintId)
    throws StandardException
  {
    DataValueDescriptor      constraintIDOrderable = null;
    TabInfo            ti = getNonCoreTI(SYSCHECKS_CATALOG_NUM);
    SYSCHECKSRowFactory      rf = (SYSCHECKSRowFactory) ti.getCatalogRowFactory();

    /* Use constraintIDOrderable in both start and stop positions for scan */
    constraintIDOrderable = getValueAsDVD(constraintId);

    /* Set up the start/stop position for the scan */
 
View Full Code Here

  private void dropSubCheckConstraint(UUID constraintId, TransactionController tc)
    throws StandardException
  {
    ExecIndexRow      checkRow1 = null;
    DataValueDescriptor    constraintIdOrderable;
    TabInfo          ti = getNonCoreTI(SYSCHECKS_CATALOG_NUM);

    /* Use constraintIdOrderable in both start
     * and stop position for index 1 scan.
     */
    constraintIdOrderable = getValueAsDVD(constraintId);

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

    ti.deleteRow( tc, checkRow1, SYSCHECKSRowFactory.SYSCHECKS_INDEX1_ID );
  }
View Full Code Here

    Hashtable ht = new Hashtable();
    ConglomerateDescriptor    cd = null;
    ScanController        scanController;
    ExecRow           outRow;
    // ExecIndexRow        keyRow = null;
    TabInfo            ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];
    SYSCONGLOMERATESRowFactory  rf = (SYSCONGLOMERATESRowFactory) ti.getCatalogRowFactory();

    outRow = rf.makeEmptyRow();
    scanController = tc.openScan(
        ti.getHeapConglomerate()// conglomerate to open
        false, // don't hold open across commit
        0, // for read
                TransactionController.MODE_RECORD,  // scans whole table.
                TransactionController.ISOLATION_READ_UNCOMMITTED,
        (FormatableBitSet) null, // all fields as objects
View Full Code Here

    throws StandardException
  {
    Hashtable ht = new Hashtable();
    ScanController        scanController;
    ExecRow           outRow;
    TabInfo          ti = coreInfo[SYSTABLES_CORE_NUM];
    SYSTABLESRowFactory
          rf = (SYSTABLESRowFactory) ti.getCatalogRowFactory();

    outRow = rf.makeEmptyRow();

    scanController = tc.openScan(
        ti.getHeapConglomerate(),       // sys.systable
        false,                          // don't hold open across commit
        0,                              // for read
                TransactionController.MODE_RECORD,// scans whole table.
                TransactionController.ISOLATION_READ_UNCOMMITTED,
        (FormatableBitSet) null,                 // all fields as objects
View Full Code Here

  public ConglomerateDescriptor[] getConglomerateDescriptors(UUID uuid)
        throws StandardException
  {
    DataValueDescriptor    UUIDStringOrderable;
    SYSCONGLOMERATESRowFactory rf;
    TabInfo          ti = coreInfo[SYSCONGLOMERATES_CORE_NUM];

    /* Use UUIDStringOrderable in both start and stop positions for scan */
    UUIDStringOrderable = dvf.getCharDataValue(uuid.toString());

    /* Set up the start/stop position for the scan */
 
View Full Code Here

TOP

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

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.