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

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


   private void getConstraintDescriptorsScan(TableDescriptor td, boolean forUpdate)
      throws StandardException
  {
    ConstraintDescriptorList  cdl = td.getConstraintDescriptorList();
    DataValueDescriptor      tableIDOrderable = null;
    TabInfo            ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);

    /* Use tableIDOrderable in both start and stop positions for scan */
    tableIDOrderable = getValueAsDVD(td.getUUID());

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


   * @exception StandardException    Thrown on error
   */
  public ConstraintDescriptorList getForeignKeys(UUID constraintId)
      throws StandardException
  {
    TabInfo ti = getNonCoreTI(SYSFOREIGNKEYS_CATALOG_NUM);
    List fkList = newSList();

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

View Full Code Here

    ExecRow         outRow;
    RowLocation        baseRowLocation;
    ConglomerateController  heapCC = null;
    ScanController      scanController = null;
    TransactionController  tc;
    TabInfo         ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    SYSCONSTRAINTSRowFactory rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
    TableDescriptor      td = null;
    List          slist = newSList();

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX1_ID ||
                 indexId == SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_INDEX3_ID,
                  "bad index id, must be one of the indexes on a uuid");
      SanityManager.ASSERT(columnNum > 0 &&
                 columnNum <= SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT,
                  "invalid column number for column to be retrieved");
    }

    try
    {
      /* Use tableIDOrderable in both start and stop positions for scan */
      DataValueDescriptor orderable = getValueAsDVD(uuid);
 
      /* Set up the start/stop position for the scan */
      ExecIndexRow keyRow = (ExecIndexRow) exFactory.getIndexableRow(1);
      keyRow.setColumn(1, orderable);

      // Get the current transaction controller
      tc = getTransactionCompile();
 
      outRow = rf.makeEmptyRow();
 
      heapCC =
                tc.openConglomerate(
                    ti.getHeapConglomerate(), false, 0,
                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

      // create an index row template
      indexRow1 = getIndexRowFromHeapRow(
                ti.getIndexRowGenerator(indexId),
                heapCC.newRowLocationTemplate(),
                outRow);
 
      // just interested in one column
      DataValueDescriptor[] rowTemplate    =
              new DataValueDescriptor[SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT];
      FormatableBitSet  columnToGetSet =
              new FormatableBitSet(SYSCONSTRAINTSRowFactory.SYSCONSTRAINTS_COLUMN_COUNT);
      columnToGetSet.set(columnNum - 1);

      rowTemplate[columnNum - 1] =
                dvf.getNullChar((StringDataValue) null);
 
      // Scan the index and go to the data pages for qualifying rows
      scanController = tc.openScan(
          ti.getIndexConglomerate(indexId),// conglomerate to open
          false,               // don't hold open across commit
          0,                 // for read
                  TransactionController.MODE_RECORD,
                  TransactionController.ISOLATION_REPEATABLE_READ,// RESOLVE: should be level 2
          (FormatableBitSet) null,                 // all fields as objects
View Full Code Here

      TransactionController tc)
    throws StandardException
  {
    ExecRow              row = null;
    int            type = descriptor.getConstraintType();
    TabInfo            ti = getNonCoreTI(SYSCONSTRAINTS_CATALOG_NUM);
    SYSCONSTRAINTSRowFactory  rf = (SYSCONSTRAINTSRowFactory) ti.getCatalogRowFactory();
    int            insertRetCode;

    if (SanityManager.DEBUG)
    {
      if (!(type == DataDictionary.PRIMARYKEY_CONSTRAINT ||
View Full Code Here

  {
    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

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.