Examples of DataDescriptorGenerator


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

        SanityManager.THROWASSERT("Wrong number of columns for a SYSFILES row: "+
               row.nColumns());
      }
    }

    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    String  id_S;
    UUID    id;
    String  schemaId_S;
    UUID    schemaId;
    String  name;
    long     generationId;
    DataValueDescriptor  col;

    SchemaDescriptor  schemaDescriptor;
    FileInfoDescriptor  result;

    /* 1st column is ID (UUID - char(36)) */
    col = row.getColumn(ID_COL_NUM);
    id_S = col.getString();
    id = getUUIDFactory().recreateUUID(id_S);

    /* 2nd column is SchemaId */
    col = row.getColumn(SCHEMA_ID_COL_NUM);
    schemaId_S = col.getString();
    schemaId = getUUIDFactory().recreateUUID(schemaId_S);
   
    schemaDescriptor = dd.getSchemaDescriptor(schemaId, null);
    if (SanityManager.DEBUG)
    {
      if (schemaDescriptor == null)
      {
        SanityManager.THROWASSERT("Missing schema for FileInfo: "+id_S);
      }
    }

    /* 3nd column is NAME (varchar(128)) */
    col = row.getColumn(NAME_COL_NUM);
    name = col.getString();

    /* 4th column is generationId (long) */
    col = row.getColumn(GENERATION_ID_COL_NUM);
    generationId = col.getLong();

      result = ddg.newFileInfoDescriptor(id,schemaDescriptor,name,
                       generationId);
    return result;
  }
View Full Code Here

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

    if (SanityManager.DEBUG)
    SanityManager.ASSERT(
      row.nColumns() == SYSCONGLOMERATES_COLUMN_COUNT,
      "Wrong number of columns for a SYSCONGLOMERATES row");

    DataDescriptorGenerator  ddg = dd.getDataDescriptorGenerator();
    long conglomerateNumber;
    String  name;
    boolean isConstraint;
    boolean isIndex;
    IndexRowGenerator  indexRowGenerator;
    DataValueDescriptor col;
    ConglomerateDescriptor conglomerateDesc;
    String    conglomUUIDString;
    UUID    conglomUUID;
    String    schemaUUIDString;
    UUID    schemaUUID;
    String    tableUUIDString;
    UUID    tableUUID;

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

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


    /* 3nd column is CONGLOMERATENUMBER (long) */
    col = row.getColumn(3);
    conglomerateNumber = col.getLong();

    /* 4rd column is CONGLOMERATENAME (varchar(128)) */
    col = row.getColumn(4);
    name = col.getString();

    /* 5th column is ISINDEX (boolean) */
    col = row.getColumn(5);
    isIndex = col.getBoolean();

    /* 6th column is DESCRIPTOR */
    col = row.getColumn(6);
    indexRowGenerator = new IndexRowGenerator(
      (IndexDescriptor) col.getObject());

    /* 7th column is ISCONSTRAINT (boolean) */
    col = row.getColumn(7);
    isConstraint = col.getBoolean();

    /* 8th column is CONGLOMERATEID (UUID - char(36)) */
    col = row.getColumn(8);
    conglomUUIDString = col.getString();
    conglomUUID = getUUIDFactory().recreateUUID(conglomUUIDString);

    /* now build and return the descriptor */
    conglomerateDesc = ddg.newConglomerateDescriptor(conglomerateNumber,
                             name,
                             isIndex,
                             indexRowGenerator,
                             isConstraint,
                             conglomUUID,
View Full Code Here

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

    checkOwnership( currentUser,
            aliasDescriptor,
            dd.getSchemaDescriptor( aliasDescriptor.getSchemaUUID(), tc),
            dd);
   
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    RoutinePermsDescriptor routinePermsDesc = ddg.newRoutinePermsDescriptor( aliasDescriptor, currentUser);

    dd.startWriting(lcc);
    for( Iterator itr = grantees.iterator(); itr.hasNext();)
    {
      // Keep track to see if any privileges are revoked by a revoke
View Full Code Here

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

      // To prevent any possible deadlocks with SYSTABLES, we insert a row into
      // SYSTABLES also for synonyms. This also ensures tables/views/synonyms share
      // same namespace
      TableDescriptor td;
      DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
      td = ddg.newTableDescriptor(aliasName, sd, TableDescriptor.SYNONYM_TYPE,
            TableDescriptor.DEFAULT_LOCK_GRANULARITY);
      dd.addDescriptor(td, sd, DataDictionary.SYSTABLES_CATALOG_NUM, false, tc);
   
    default:
      break;
View Full Code Here

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

    UUID        defaultUUID = null;
    UUID        uuid = null;
    UUIDFactory      uuidFactory = getUUIDFactory();
    long autoincStart, autoincInc;

    DataDescriptorGenerator  ddg = dd.getDataDescriptorGenerator();


    /*
    ** We're going to be getting the UUID for this sucka
    ** so make sure it is a UniqueTupleDescriptor.
View Full Code Here

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

    char            type;
    boolean            valid;
    Timestamp          time = null;
    ExecPreparedStatement    preparedStatement = null;
    boolean            initiallyCompilable;
    DataDescriptorGenerator    ddg = dd.getDataDescriptorGenerator();

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(row.nColumns() == SYSSTATEMENTS_COLUMN_COUNT,
                 "Wrong number of columns for a SYSSTATEMENTS row");
View Full Code Here

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

          throws StandardException
  {
    if (SanityManager.DEBUG)
    SanityManager.ASSERT(row.nColumns() == SYSTABLES_COLUMN_COUNT, "Wrong number of columns for a SYSTABLES row");

    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    String  tableUUIDString;
    String  schemaUUIDString;
    int    tableTypeEnum;
    String  lockGranularity;
    String  tableName, tableType;
    DataValueDescriptor  col;
    UUID    tableUUID;
    UUID    schemaUUID;
    SchemaDescriptor  schema;
    TableDescriptor    tabDesc;

    /* 1st column is TABLEID (UUID - char(36)) */
    col = row.getColumn(SYSTABLES_TABLEID);
    tableUUIDString = col.getString();
    tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);


    /* 2nd column is TABLENAME (varchar(128)) */
    col = row.getColumn(SYSTABLES_TABLENAME);
    tableName = col.getString();

    /* 3rd column is TABLETYPE (char(1)) */
    col = row.getColumn(SYSTABLES_TABLETYPE);
    tableType = col.getString();
    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(tableType.length() == 1, "Fourth column type incorrect");
    }
    switch (tableType.charAt(0))
    {
      case 'T' :
        tableTypeEnum = TableDescriptor.BASE_TABLE_TYPE;
        break;
      case 'S' :
        tableTypeEnum = TableDescriptor.SYSTEM_TABLE_TYPE;
        break;
      case 'V' :
        tableTypeEnum = TableDescriptor.VIEW_TYPE;
        break;
      case 'A' :
        tableTypeEnum = TableDescriptor.SYNONYM_TYPE;
        break;
      default:
        if (SanityManager.DEBUG)
        SanityManager.THROWASSERT("Fourth column value invalid");
        tableTypeEnum = -1;
    }

    /* 4th column is SCHEMAID (UUID - char(36)) */
    col = row.getColumn(SYSTABLES_SCHEMAID);
    schemaUUIDString = col.getString();
    schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
   
    schema = dd.getSchemaDescriptor(schemaUUID, null);

    /* 5th column is LOCKGRANULARITY (char(1)) */
    col = row.getColumn(SYSTABLES_LOCKGRANULARITY);
    lockGranularity = col.getString();
    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(lockGranularity.length() == 1, "Fifth column type incorrect");
    }

    // RESOLVE - Deal with lock granularity
    tabDesc = ddg.newTableDescriptor(tableName, schema, tableTypeEnum, lockGranularity.charAt(0));
    tabDesc.setUUID(tableUUID);
    return tabDesc;
  }
View Full Code Here

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

            throws StandardException
  {
    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    TransactionController tc = lcc.getTransactionExecute();
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, lcc.getTransactionExecute(), false);

    //if the schema descriptor is an in-memory schema, we donot throw schema already exists exception for it.
    //This is to handle in-memory SESSION schema for temp tables
    if ((sd != null) && (sd.getUUID() != null))
    {
      throw StandardException.newException(SQLState.LANG_OBJECT_ALREADY_EXISTS, "Schema" , schemaName);
    }

    UUID tmpSchemaId = dd.getUUIDFactory().createUUID();

    /*
    ** AID defaults to connection authorization if not
    ** specified in CREATE SCHEMA (if we had module
     ** authorizations, that would be the first check
    ** for default, then session aid).
    */
    String thisAid = aid;
    if (thisAid == null)
    {
      thisAid = lcc.getAuthorizationId();
    }

    /*
    ** Inform the data dictionary that we are about to write to it.
    ** There are several calls to data dictionary "get" methods here
    ** that might be done in "read" mode in the data dictionary, but
    ** it seemed safer to do this whole operation in "write" mode.
    **
    ** We tell the data dictionary we're done writing at the end of
    ** the transaction.
    */
    dd.startWriting(lcc);

    sd = ddg.newSchemaDescriptor(schemaName,
                  thisAid,
                  tmpSchemaId);

    dd.addDescriptor(sd, null, DataDictionary.SYSSCHEMAS_CATALOG_NUM, false, tc);
  }
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.