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

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


        // than fetch, so that the fetch happens while latch is held, otherwise
        // the next() might position the scan on a row, but the subsequent
        // fetch() may find the row deleted or purged from the table.
    while(scanController.fetchNext(outRow.getRowArray()))
    {
      TableDescriptor td = (TableDescriptor)
        rf.buildDescriptor(
          outRow,
          (TupleDescriptor)null,
          this,
          TransactionController.ISOLATION_READ_UNCOMMITTED);
      ht.put(td.getUUID(), td);
    }
    scanController.close();
    return ht;
  }
View Full Code Here


  {
    SystemColumn    theColumn;
    SystemColumn[]    columns = rowFactory.buildColumnList();
    SchemaDescriptor  sd = getSystemSchemaDescriptor();

    TableDescriptor td = getTableDescriptor(rowFactory.getCatalogName(), sd, tc);

    theColumn = columns[columnNumber - 1]// from 1 to 0 based
    ColumnDescriptor cd = makeColumnDescriptor(theColumn, columnNumber, td );
    String columnName = cd.getColumnName();
    int[] columnNameColArray = new int[1];
    columnNameColArray[0] = SYSCOLUMNSRowFactory.SYSCOLUMNS_COLUMNDATATYPE ;
    updateColumnDescriptor(cd,
                td.getUUID(),
                columnName,
                columnNameColArray,
                tc);

  }
View Full Code Here

    SystemColumn[]    columns = rowFactory.buildColumnList();
    ExecRow        templateRow = rowFactory.makeEmptyRow();
    int          columnCount = newColumnIDs.length;
    SchemaDescriptor  sd = getSystemSchemaDescriptor();
    TableDescriptor    td;
    long        conglomID;

    // Special case when adding a column to systables or syscolumns,
    // since we can't go to systables/syscolumns to get the
    // table/column descriptor until after we add and populate the new column.
    if (rowFactory instanceof SYSTABLESRowFactory)
    {
      td = dataDescriptorGenerator.newTableDescriptor(
            "SYSTABLES",
            sd,
            TableDescriptor.BASE_TABLE_TYPE,
            TableDescriptor.ROW_LOCK_GRANULARITY);
      td.setUUID(getUUIDForCoreTable("SYSTABLES", sd.getUUID().toString(), tc));
      conglomID = coreInfo[SYSTABLES_CORE_NUM].getHeapConglomerate();
    }
    else if (rowFactory instanceof SYSCOLUMNSRowFactory)
    {
      td = dataDescriptorGenerator.newTableDescriptor(
            "SYSCOLUMNS",
            sd,
            TableDescriptor.BASE_TABLE_TYPE,
            TableDescriptor.ROW_LOCK_GRANULARITY);
      td.setUUID(getUUIDForCoreTable("SYSCOLUMNS", sd.getUUID().toString(), tc));
      conglomID = coreInfo[SYSCOLUMNS_CORE_NUM].getHeapConglomerate();
    }
    else
    {
      td = getTableDescriptor( rowFactory.getCatalogName(), sd, tc );
      conglomID = td.getHeapConglomerateId();
    }

    widenConglomerate( templateRow, newColumnIDs, conglomID, tc );

View Full Code Here

    String        name = ti.getTableName();
    long        conglomId = ti.getHeapConglomerate();
    SystemColumn[]    columnList = crf.buildColumnList();
    UUID        heapUUID = crf.getCanonicalHeapUUID();
    String        heapName = crf.getCanonicalHeapName();
    TableDescriptor    td;
    UUID        toid;
    ColumnDescriptor  cd;
    int          columnCount;
    SystemColumn    column;

    // add table to the data dictionary

    columnCount = columnList.length;
    td = ddg.newTableDescriptor(name, sd, TableDescriptor.SYSTEM_TABLE_TYPE,
                    TableDescriptor.ROW_LOCK_GRANULARITY);
    td.setUUID(crf.getCanonicalTableUUID());
    addDescriptor(td, sd, SYSTABLES_CATALOG_NUM,
            false, tc);
    toid = td.getUUID();
 
    /* Add the conglomerate for the heap */
    ConglomerateDescriptor cgd = ddg.newConglomerateDescriptor(conglomId,
                                  heapName,
                                  false,
                                  null,
                                  false,
                                  heapUUID,
                                    toid,
                                  sd.getUUID());

    addDescriptor(cgd, sd, SYSCONGLOMERATES_CATALOG_NUM, false, tc);

    /* Create the columns */
    ColumnDescriptor[] cdlArray = new ColumnDescriptor[columnCount];

    for (int columnNumber = 0; columnNumber < columnCount; columnNumber++)
    {
      column = columnList[columnNumber];

      if (SanityManager.DEBUG)
      {
        if (column == null)
        {
          SanityManager.THROWASSERT("column "+columnNumber+" for table "+ti.getTableName()+" is null");
        }
      }
      cdlArray[columnNumber] = makeColumnDescriptor( column,
                    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

      if (ti.isComplete())
      {
        return;
      }

      TableDescriptor td = getTableDescriptor(ti.getTableName(),
                          getSystemSchemaDescriptor(), null);

      // It's possible that the system table is not there right
      // now. This can happen, for example, if we're in the
      // process of upgrading a source or target to Xena, in
      // which case SYSSYNCINSTANTS is dropped and re-created.
      // Just return in this case, so we don't get a null pointer
      // exception.
      if (td == null)
      {
        return;
      }

      ConglomerateDescriptor cd = null;
      ConglomerateDescriptor[] cds = td.getConglomerateDescriptors();

      /* Init the heap conglomerate here */
      for (int index = 0; index < cds.length; index++)
      {
        cd = cds[index];
View Full Code Here

    //collect all the exceptions we might receive while dropping the temporary tables and throw them as one chained exception at the end.
    for (int i = 0; i < allDeclaredGlobalTempTables.size(); i++) {
      try {
        TempTableInfo tempTableInfo = (TempTableInfo)allDeclaredGlobalTempTables.get(i);
        TableDescriptor td = tempTableInfo.getTableDescriptor();
        //the following 2 lines of code has been copied from DropTableConstantAction. If there are any changes made there in future,
        //we should check if they need to be made here too.
        dm.invalidateFor(td, DependencyManager.DROP_TABLE, this);
        tran.dropConglomerate(td.getHeapConglomerateId());
      } catch (StandardException e) {
        if (topLevelStandardException == null) {
          // always keep the first exception unchanged
          topLevelStandardException = e;
        } else {
View Full Code Here

      {
        if (tempTableInfo.getDroppedInSavepointLevel() == -1)
        {
          //the table was declared but not dropped in the unit of work getting rolled back and hence we will remove
          //it from valid list of temporary tables and drop the conglomerate associated with it
          TableDescriptor td = tempTableInfo.getTableDescriptor();
          tran.dropConglomerate(td.getHeapConglomerateId()); //remove the conglomerate created for this temp table
          allDeclaredGlobalTempTables.remove(i); //remove it from the list of temp tables
        } else if (tempTableInfo.getDroppedInSavepointLevel() >= currentSavepointLevel)
        {
          //the table was declared and dropped in the unit of work getting rolled back
          allDeclaredGlobalTempTables.remove(i);
        }
      } else if (tempTableInfo.getDroppedInSavepointLevel() >= currentSavepointLevel) //this means the table was declared in an earlier savepoint unit / transaction and then dropped in current UOW
      {
        //restore the old definition of temp table because drop is being rolledback
        TableDescriptor td = tempTableInfo.getTableDescriptor();
        td = cleanupTempTableOnCommitOrRollback(td, false);
        //In order to store the old conglomerate information for the temp table, we need to replace the
        //existing table descriptor with the old table descriptor which has the old conglomerate information
        tempTableInfo.setTableDescriptor(td);
        tempTableInfo.setDroppedInSavepointLevel(-1);
        //following will mark the table as not modified. This is because the table data has been deleted as part of the current rollback
        tempTableInfo.setModifiedInSavepointLevel(-1);
        allDeclaredGlobalTempTables.set(i, tempTableInfo);
      } else if (tempTableInfo.getModifiedInSavepointLevel() >= currentSavepointLevel) //this means the table was declared in an earlier savepoint unit / transaction and modified in current UOW
      {
        //following will mark the table as not modified. This is because the table data will be deleted as part of the current rollback
        tempTableInfo.setModifiedInSavepointLevel(-1);
        TableDescriptor td = tempTableInfo.getTableDescriptor();
        getDataDictionary().getDependencyManager().invalidateFor(td, DependencyManager.DROP_TABLE, this);
        cleanupTempTableOnCommitOrRollback(td, true);
      } // there is no else here because there is no special processing required for temp tables declares in earlier work of unit/transaction and not modified
    }
   
View Full Code Here

      //at commit time, for all the temp tables declared with ON COMMIT DELETE ROWS, make sure there are no held cursor open on them.
      //If there are no held cursors open on ON COMMIT DELETE ROWS, drop those temp tables and redeclare them to get rid of all the data in them
      if (allDeclaredGlobalTempTables != null) {
        for (int i=0; i<allDeclaredGlobalTempTables.size(); i++)
        {
          TableDescriptor td = ((TempTableInfo)(allDeclaredGlobalTempTables.get(i))).getTableDescriptor();
          if (td.isOnCommitDeleteRows() == false) //do nothing for temp table with ON COMMIT PRESERVE ROWS
          {
            continue;
          }
          if (checkIfAnyActivationHasHoldCursor(td.getName()) == false)//temp tables with ON COMMIT DELETE ROWS and no open held cursors
          {
            getDataDictionary().getDependencyManager().invalidateFor(td, DependencyManager.DROP_TABLE, this);
            cleanupTempTableOnCommitOrRollback(td, true);
          }
        }
View Full Code Here

     * staleness (or to create).
     *
     * @param fromTable the table
     */
    private void collectTablePrivsAndStats(FromBaseTable fromTable) {
        TableDescriptor td = fromTable.getTableDescriptor();
        if (fromTable.isPrivilegeCollectionRequired()) {
            // We ask for MIN_SELECT_PRIV requirement of the first column in
            // the table. The first column is just a place holder. What we
            // really do at execution time when we see we are looking for
            // MIN_SELECT_PRIV privilege is as follows:
            //
            // 1) We will look for SELECT privilege at table level.
            // 2) If not found, we will look for SELECT privilege on
            //    ANY column, not necessarily the first column. But since
            //    the constructor for column privilege requires us to pass
            //    a column descriptor, we just choose the first column for
            //    MIN_SELECT_PRIV requirement.
            getCompilerContext().addRequiredColumnPriv(
                    td.getColumnDescriptor(1));
        }
        // Save a list of base tables to check the index statistics for at a
        // later time. We want to compute statistics for base user tables only,
        // not for instance system tables or VTIs (see TableDescriptor for a
        // list of all available "table types").
        if (checkIndexStats &&
                td.getTableType() == TableDescriptor.BASE_TABLE_TYPE) {
            if (statsToUpdate == null) {
                statsToUpdate = new ArrayList();
            }
            statsToUpdate.add(td);
        }
View Full Code Here

   */
  private void bindUpdateColumns(FromTable targetTable)
          throws StandardException
  {
    int size = updatableColumns.size();
    TableDescriptor tableDescriptor;
    String columnName;
    ResultColumnList rcls = resultSet.getResultColumns();

    for (int index = 0; index < size; index++)
    {
        columnName = (String) updatableColumns.get(index);
        tableDescriptor = targetTable.getTableDescriptor();
        if ( tableDescriptor.getColumnDescriptor(columnName) == null)
        {
          throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOUND, columnName);
        }

        ResultColumn rc;
View Full Code Here

TOP

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

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.