Examples of DataDescriptorGenerator


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

    SchemaDescriptor      descriptor;
    String            name;
    UUID              id;
    String            aid;
    String            uuid;
    DataDescriptorGenerator    ddg = dd.getDataDescriptorGenerator();

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(row.nColumns() == SYSSCHEMAS_COLUMN_COUNT,
                 "Wrong number of columns for a SYSSCHEMAS row");
    }

    // first column is schemaid (UUID - char(36))
    col = row.getColumn(1);
    uuid = col.getString();
    id = getUUIDFactory().recreateUUID(uuid);

    // second column is schemaname (varchar(128))
    col = row.getColumn(2);
    name = col.getString();

    // third column is auid (varchar(128))
    col = row.getColumn(3);
    aid = col.getString();

    descriptor = ddg.newSchemaDescriptor(name, aid, id);

    return descriptor;
  }
View Full Code Here

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

        "Wrong number of columns for a SYSCONSTRAINTS row");
    }

    DataValueDescriptor  col;
    ConglomerateDescriptor conglomDesc;
    DataDescriptorGenerator ddg;
    TableDescriptor    td = null;
    int          constraintIType = -1;
    int[]        keyColumns = null;
    UUID        constraintUUID;
    UUID        schemaUUID;
    UUID        tableUUID;
    UUID        referencedConstraintId = null;
    SchemaDescriptor  schema;
    String        tableUUIDString;
    String        constraintName;
    String        constraintSType;
    String        constraintStateStr;
    boolean        constraintEnabled;
    int          referenceCount;
    String        constraintUUIDString;
    String        schemaUUIDString;
    SubConstraintDescriptor scd;

    if (SanityManager.DEBUG)
    {
      if (!(parentTupleDescriptor instanceof SubConstraintDescriptor))
      {
        SanityManager.THROWASSERT(
          "parentTupleDescriptor expected to be instanceof " +
          "SubConstraintDescriptor, not " +
          parentTupleDescriptor.getClass().getName());
      }
    }

    scd = (SubConstraintDescriptor) parentTupleDescriptor;

    ddg = dd.getDataDescriptorGenerator();

    /* 1st column is CONSTRAINTID (UUID - char(36)) */
    col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTID);
    constraintUUIDString = col.getString();
    constraintUUID = getUUIDFactory().recreateUUID(constraintUUIDString);

    /* 2nd column is TABLEID (UUID - char(36)) */
    col = row.getColumn(SYSCONSTRAINTS_TABLEID);
    tableUUIDString = col.getString();
    tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);

    /* Get the TableDescriptor. 
     * It may be cached in the SCD,
     * otherwise we need to go to the
     * DD.
     */
    if (scd != null)
    {
      td = scd.getTableDescriptor();
    }
    if (td == null)
    {
      td = dd.getTableDescriptor(tableUUID);
    }

    /* 3rd column is NAME (varchar(128)) */
    col = row.getColumn(SYSCONSTRAINTS_CONSTRAINTNAME);
    constraintName = col.getString();

    /* 4th column is TYPE (char(1)) */
    col = row.getColumn(SYSCONSTRAINTS_TYPE);
    constraintSType = col.getString();
    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(constraintSType.length() == 1,
        "Fourth column type incorrect");
    }

    boolean typeSet = false;
    switch (constraintSType.charAt(0))
    {
      case 'P' :
        constraintIType = DataDictionary.PRIMARYKEY_CONSTRAINT;
        typeSet = true;
        // fall through

      case 'U' :
        if (! typeSet)
        {
          constraintIType = DataDictionary.UNIQUE_CONSTRAINT;
          typeSet = true;
        }
        // fall through

      case 'F' :
        if (! typeSet)
          constraintIType = DataDictionary.FOREIGNKEY_CONSTRAINT;
        if (SanityManager.DEBUG)
        {
          if (!(parentTupleDescriptor instanceof SubKeyConstraintDescriptor))
          {
            SanityManager.THROWASSERT(
            "parentTupleDescriptor expected to be instanceof " +
            "SubKeyConstraintDescriptor, not " +
            parentTupleDescriptor.getClass().getName());
          }
        }
        conglomDesc = td.getConglomerateDescriptor(
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getIndexId());
        /* Take care the rare case of conglomDesc being null.  The
         * reason is that our "td" is out of date.  Another thread
         * which was adding a constraint committed between the moment
         * we got the table descriptor (conglomerate list) and the
         * moment we scanned and got the constraint desc list.  Since
         * that thread just added a new row to SYSCONGLOMERATES,
         * SYSCONSTRAINTS, etc.  We wouldn't have wanted to lock the
         * system tables just to prevent other threads from adding new
         * rows.
         */
        if (conglomDesc == null)
        {
          // we can't be getting td from cache because if we are
          // here, we must have been in dd's ddl mode (that's why
          // the ddl thread went through), we are not done yet, the
          // dd ref count is not 0, hence it couldn't have turned
          // into COMPILE_ONLY mode
          td = dd.getTableDescriptor(tableUUID);
          if (scd != null)
            scd.setTableDescriptor(td);
          // try again now
          conglomDesc = td.getConglomerateDescriptor(
                  ((SubKeyConstraintDescriptor)
                    parentTupleDescriptor).getIndexId());
        }

        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(conglomDesc != null,
          "conglomDesc is expected to be non-null for backing index");
        }
        keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();
        referencedConstraintId = ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getKeyConstraintId();
        keyColumns = conglomDesc.getIndexDescriptor().baseColumnPositions();
        break;

      case 'C' :
        constraintIType = DataDictionary.CHECK_CONSTRAINT;
        if (SanityManager.DEBUG)
        {
          if (!(parentTupleDescriptor instanceof SubCheckConstraintDescriptor))
          {
            SanityManager.THROWASSERT("parentTupleDescriptor expected to be instanceof " +
            "SubCheckConstraintDescriptor, not " +
            parentTupleDescriptor.getClass().getName());
          }
        }
        break;

      default:
        if (SanityManager.DEBUG)
        {
          SanityManager.THROWASSERT("Fourth column value invalid");
        }
    }

    /* 5th column is SCHEMAID (UUID - char(36)) */
    col = row.getColumn(SYSCONSTRAINTS_SCHEMAID);
    schemaUUIDString = col.getString();
    schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);

    schema = dd.getSchemaDescriptor(schemaUUID, null);

    /* 6th column is STATE (char(1)) */
    col = row.getColumn(SYSCONSTRAINTS_STATE);
    constraintStateStr = col.getString();
    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(constraintStateStr.length() == 1,
        "Sixth column (state) type incorrect");
    }

    switch (constraintStateStr.charAt(0))
    {
      case 'E':
        constraintEnabled = true;
        break;
      case 'D':
        constraintEnabled = false;
        break;
      default:
        constraintEnabled = true;
        if (SanityManager.DEBUG)
        {
          SanityManager.THROWASSERT("Invalidate state value '"
              +constraintStateStr+ "' for constraint");
        }
    }

    /* 7th column is REFERENCECOUNT, boolean */
    col = row.getColumn(SYSCONSTRAINTS_REFERENCECOUNT);
    referenceCount = col.getInt();
   
    /* now build and return the descriptor */

    switch (constraintIType)
    {
      case DataDictionary.PRIMARYKEY_CONSTRAINT :
        constraintDesc = ddg.newPrimaryKeyConstraintDescriptor(
                    td,
                    constraintName,
                    false, //deferable,
                    false, //initiallyDeferred,
                    keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],
                    constraintUUID,
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getIndexId(),
                    schema,
                    constraintEnabled,
                    referenceCount);
        break;

      case DataDictionary.UNIQUE_CONSTRAINT :
        constraintDesc = ddg.newUniqueConstraintDescriptor(
                    td,
                    constraintName,
                    false, //deferable,
                    false, //initiallyDeferred,
                    keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],
                    constraintUUID,
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getIndexId(),
                    schema,
                    constraintEnabled,
                    referenceCount);
        break;

      case DataDictionary.FOREIGNKEY_CONSTRAINT :
        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(referenceCount == 0,
            "REFERENCECOUNT column is nonzero for fk constraint");
        }
         
        constraintDesc = ddg.newForeignKeyConstraintDescriptor(
                    td,
                    constraintName,
                    false, //deferable,
                    false, //initiallyDeferred,
                    keyColumns,//genReferencedColumns(dd, td), //int referencedColumns[],
                    constraintUUID,
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getIndexId(),
                    schema,
                    referencedConstraintId,
                    constraintEnabled,
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getRaDeleteRule(),
                    ((SubKeyConstraintDescriptor)
                      parentTupleDescriptor).getRaUpdateRule()
                    );
        break;

      case DataDictionary.CHECK_CONSTRAINT :
        if (SanityManager.DEBUG)
        {
          SanityManager.ASSERT(referenceCount == 0,
            "REFERENCECOUNT column is nonzero for check constraint");
        }
         
        constraintDesc = ddg.newCheckConstraintDescriptor(
                    td,
                    constraintName,
                    false, //deferable,
                    false, //initiallyDeferred,
                    constraintUUID,
View Full Code Here

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

        String objectTypeName = _tupleDescriptor.getObjectTypeName();

    // Check that the current user has permission to grant the privileges.
    checkOwnership( currentUser, (TupleDescriptor) _tupleDescriptor, sd, dd );
   
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    PermDescriptor permDesc = ddg.newPermDescriptor
            ( null, objectTypeName, objectID, _privilege, currentUser, null, false );

    dd.startWriting(lcc);
    for( Iterator itr = grantees.iterator(); itr.hasNext();)
    {
View Full Code Here

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

  {
    ColumnDescriptor columnDescriptor   =
      td.getColumnDescriptor(columnInfo[ix].name);
    DataValueDescriptor storableDV;
    int                     colNumber   = td.getMaxColumnID() + ix;
    DataDescriptorGenerator ddg         = dd.getDataDescriptorGenerator();

    /* We need to verify that the table does not have an existing
     * column with the same name before we try to add the new
     * one as addColumnDescriptor() is a void method.
     */
 
View Full Code Here

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

                    }
                }
            }
        }

    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
        int                             cascadedDrops = cascadedDroppedColumns.size();
    int sizeAfterCascadedDrops = td.getColumnDescriptorList().size() - cascadedDrops;

    // can NOT drop a column if it is the only one in the table
    if (sizeAfterCascadedDrops == 1)
View Full Code Here

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

    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    ColumnDescriptor columnDescriptor =
      td.getColumnDescriptor(columnInfo[ix].name);
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    int columnPosition = columnDescriptor.getPosition();

    // Clean up after the old default, if non-null
    if (columnDescriptor.hasNonNullDefault())
    {
View Full Code Here

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

    // indicate that we are in the process of booting
    booting = true;

    // set only if child class hasn't overriden this already
    if ( dataDescriptorGenerator == null )
    { dataDescriptorGenerator = new DataDescriptorGenerator( this ); }

    if (!create) {


      // SYSTABLES

      coreInfo[SYSTABLES_CORE_NUM].setHeapConglomerate(
          getBootParameter(startParams, CFG_SYSTABLES_ID, true));

      coreInfo[SYSTABLES_CORE_NUM].setIndexConglomerate(SYSTABLESRowFactory.SYSTABLES_INDEX1_ID,
          getBootParameter(startParams, CFG_SYSTABLES_INDEX1_ID, true));


      coreInfo[SYSTABLES_CORE_NUM].setIndexConglomerate(
          SYSTABLESRowFactory.SYSTABLES_INDEX2_ID,
          getBootParameter(startParams, CFG_SYSTABLES_INDEX2_ID, true));

      // SYSCOLUMNS

      coreInfo[SYSCOLUMNS_CORE_NUM].setHeapConglomerate(
          getBootParameter(startParams, CFG_SYSCOLUMNS_ID, true));


      coreInfo[SYSCOLUMNS_CORE_NUM].setIndexConglomerate(
          SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID,
          getBootParameter(startParams, CFG_SYSCOLUMNS_INDEX1_ID, true));
      // 2nd syscolumns index added in Xena, hence may not be there
      coreInfo[SYSCOLUMNS_CORE_NUM].setIndexConglomerate(
          SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX2_ID,
          getBootParameter(startParams, CFG_SYSCOLUMNS_INDEX2_ID, false));

      // SYSCONGLOMERATES

      coreInfo[SYSCONGLOMERATES_CORE_NUM].setHeapConglomerate(
          getBootParameter(startParams, CFG_SYSCONGLOMERATES_ID, true));


      coreInfo[SYSCONGLOMERATES_CORE_NUM].setIndexConglomerate(
          SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX1_ID,
          getBootParameter(startParams, CFG_SYSCONGLOMERATES_INDEX1_ID, true));


      coreInfo[SYSCONGLOMERATES_CORE_NUM].setIndexConglomerate(
          SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX2_ID,
          getBootParameter(startParams, CFG_SYSCONGLOMERATES_INDEX2_ID, true));

      coreInfo[SYSCONGLOMERATES_CORE_NUM].setIndexConglomerate(
          SYSCONGLOMERATESRowFactory.SYSCONGLOMERATES_INDEX3_ID,
          getBootParameter(startParams, CFG_SYSCONGLOMERATES_INDEX3_ID, true));


      // SYSSCHEMAS
      coreInfo[SYSSCHEMAS_CORE_NUM].setHeapConglomerate(
          getBootParameter(startParams, CFG_SYSSCHEMAS_ID, true));


      coreInfo[SYSSCHEMAS_CORE_NUM].setIndexConglomerate(
          SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX1_ID,
          getBootParameter(startParams, CFG_SYSSCHEMAS_INDEX1_ID, true));

      coreInfo[SYSSCHEMAS_CORE_NUM].setIndexConglomerate(
          SYSSCHEMASRowFactory.SYSSCHEMAS_INDEX2_ID,
          getBootParameter(startParams, CFG_SYSSCHEMAS_INDEX2_ID, true));

    }



    String value = startParams.getProperty(Property.LANG_TD_CACHE_SIZE);
    tdCacheSize = PropertyUtil.intPropertyValue(Property.LANG_TD_CACHE_SIZE, value,
                     0, Integer.MAX_VALUE, Property.LANG_TD_CACHE_SIZE_DEFAULT);

   
    value = startParams.getProperty(Property.LANG_SPS_CACHE_SIZE);
    stmtCacheSize = PropertyUtil.intPropertyValue(Property.LANG_SPS_CACHE_SIZE, value,
                     0, Integer.MAX_VALUE, Property.LANG_SPS_CACHE_SIZE_DEFAULT);

    value = startParams.getProperty(Property.LANG_PERMISSIONS_CACHE_SIZE);
    permissionsCacheSize = PropertyUtil.intPropertyValue(Property.LANG_PERMISSIONS_CACHE_SIZE, value,
                     0, Integer.MAX_VALUE, Property.LANG_PERMISSIONS_CACHE_SIZE_DEFAULT);


    /*
     * data dictionary contexts are only associated with connections.
     * we have to look for the basic data dictionary, as there is
     * no connection, and thus no context stack yet.
     */

    /*
     * Get the table descriptor cache.
     */
    CacheFactory cf =
        (CacheFactory) Monitor.startSystemModule(org.apache.derby.iapi.reference.Module.CacheFactory);
    OIDTdCache =
      cf.newCacheManager(this,
        "TableDescriptorOIDCache",
        tdCacheSize,
        tdCacheSize);
    nameTdCache =
      cf.newCacheManager(this,
        "TableDescriptorNameCache",
        tdCacheSize,
        tdCacheSize);

    if (stmtCacheSize > 0)
    {
      spsNameCache =
        cf.newCacheManager(this,
          "SPSNameDescriptorCache",
          stmtCacheSize,
          stmtCacheSize);
      spsIdHash = new Hashtable(stmtCacheSize);
      // spsTextHash = new Hashtable(stmtCacheSize);
    }


    /* Get the object to coordinate cache transitions */
    cacheCoordinator = new ShExLockable();

    /* Get AccessFactory in order to transaction stuff */
    af = (AccessFactoryMonitor.findServiceModule(this, AccessFactory.MODULE);

    /* Get the lock factory */
    lockFactory = af.getLockFactory();

    /*
     * now we need to setup a context stack for the database creation work.
     * We assume the System boot process has created a context
     * manager already, but not that contexts we need are there.
     */
    ContextService csf = ContextService.getFactory();

    ContextManager cm = csf.getCurrentContextManager();
    if (SanityManager.DEBUG)
      SanityManager.ASSERT((cm != null), "Failed to get current ContextManager");

    // RESOLVE other non-StandardException errors.
    bootingTC = null;
    try
    {
      // Get a transaction controller. This has the side effect of
      // creating a transaction context if there isn't one already.
      bootingTC = af.getTransaction(cm);

      /*
        We need an execution context so that we can generate rows
        REMIND: maybe only for create case?
       */
      exFactory.newExecutionContext(cm);

      DataDescriptorGenerator ddg = getDataDescriptorGenerator();

      //We should set the user schema collation type here now because
      //later on, we are going to create user schema APP. By the time any
      //user schema gets created, we should have the correct collation
      //type set for such schemas to use. For this reason, don't remove
View Full Code Here

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

  public  void  makeCatalog( TabInfoImpl          ti,
                 SchemaDescriptor      sd,
                 TransactionController     tc )
          throws StandardException
  {
    DataDescriptorGenerator ddg = getDataDescriptorGenerator();

    Properties  heapProperties = ti.getCreateHeapProperties();
    ti.setHeapConglomerate(
      createConglomerate(
        ti.getTableName(),
View Full Code Here

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

    long          heapConglomerateNumber
    )
    throws StandardException
  {
    SchemaDescriptor    sd = getSystemSchemaDescriptor( );
    DataDescriptorGenerator ddg = getDataDescriptorGenerator();
    long          indexConglomerateNumber;

    ConglomerateDescriptor  conglomerateDescriptor = bootstrapOneIndex
      ( sd, tc, ddg, ti, indexNumber, heapConglomerateNumber );
View Full Code Here

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

  {
    int numIndexes = ti.getNumberOfIndexes();

    if (numIndexes > 0)
    {
      DataDescriptorGenerator ddg = getDataDescriptorGenerator();

      for (int indexCtr = 0; indexCtr < numIndexes; indexCtr++)
      {
        initSystemIndexVariables(ddg, ti, indexCtr)
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.