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

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


        row.nColumns() == SYSVIEWS_COLUMN_COUNT,
        "Wrong number of columns for a SYSVIEWS row");
    }

    DataValueDescriptor  col;
    DataDescriptorGenerator ddg;
    int          checkIType;
    String        checkSType;
    String        tableID;
    String        compSchemaId;
    String        viewDefinition;
    UUID        tableUUID;
    UUID        compSchemaUUID = null;

    ddg = dd.getDataDescriptorGenerator();

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

    /* 2nd column is VIEWDEFINITION */
    col = row.getColumn(SYSVIEWS_VIEWDEFINITION);
    viewDefinition = col.getString();

    /* 3rd column is CHECKOPTION (char(1)) */
    col = row.getColumn(SYSVIEWS_CHECKOPTION);
    checkSType = col.getString();

    if (SanityManager.DEBUG)
    {
      if (!checkSType.equals("N"))
      {
        SanityManager.THROWASSERT("checkSType expected to be 'N', not " + checkSType);
      }
    }

    /* RESOLVE - no check options for now */
    checkIType = ViewDescriptor.NO_CHECK_OPTION;

    /* 4th column is COMPILATIONSCHEMAID (UUID - char(36)) */
    col = row.getColumn(SYSVIEWS_COMPILATION_SCHEMAID);
    compSchemaId = col.getString();
    if (compSchemaId != null)
    {
      compSchemaUUID = getUUIDFactory().recreateUUID(compSchemaId);
    }

    /* now build and return the descriptor */
    vd = ddg.newViewDescriptor(tableUUID, null, viewDefinition,
        checkIType, compSchemaUUID);
    return vd;
  }
View Full Code Here


    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

        "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

        row.nColumns() == SYSCHECKS_COLUMN_COUNT,
        "Wrong number of columns for a SYSCHECKS row");
    }

    DataValueDescriptor    col;
    DataDescriptorGenerator ddg;
    ReferencedColumns  referencedColumns;
    String        constraintText;
    String        constraintUUIDString;
    UUID        constraintUUID;
View Full Code Here

        row.nColumns() == SYSKEYS_COLUMN_COUNT,
        "Wrong number of columns for a SYSKEYS row");
    }

    DataValueDescriptor    col;
    DataDescriptorGenerator ddg;
    UUID          constraintUUID;
    UUID          conglomerateUUID;
    String        constraintUUIDString;
    String        conglomerateUUIDString;
View Full Code Here

        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

    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

    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

  {
    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

                    SQLState.LANG_COLUMN_NOT_FOUND_IN_TABLE,
                    columnInfo[ix].name,
                    td.getQualifiedName());
    }

    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
    ColumnDescriptorList tab_cdl = td.getColumnDescriptorList();
    int size = tab_cdl.size();

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

TOP

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

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.