Examples of SchemaDescriptor


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

  public void  executeConstantAction( Activation activation )
    throws StandardException
  {
    TableDescriptor       td;
    UUID             toid;
    SchemaDescriptor      schemaDescriptor;
    ColumnDescriptor      columnDescriptor;
    ExecRow            template;

    LanguageConnectionContext lcc = activation.getLanguageConnectionContext();
    DataDictionary dd = lcc.getDataDictionary();
    DependencyManager dm = dd.getDependencyManager();
    TransactionController tc = lcc.getTransactionExecute();

    /* Mark the activation as being for create table */
    activation.setForCreateTable();

        // setup for create conglomerate call:
        //   o create row template to tell the store what type of rows this
        //     table holds.
        //   o create array of collation id's to tell collation id of each
        //     column in table.
    template            = RowUtil.getEmptyValueRow(columnInfo.length, lcc);
        int[] collation_ids = new int[columnInfo.length];

    for (int ix = 0; ix < columnInfo.length; ix++)
    {
            ColumnInfo  col_info = columnInfo[ix];

            // Get a template value for each column

      if (col_info.defaultValue != null)
            {
                /* If there is a default value, use it, otherwise use null */
        template.setColumn(ix + 1, col_info.defaultValue);
            }
      else
            {
        template.setColumn(ix + 1, col_info.dataType.getNull());
            }

            // get collation info for each column.

            collation_ids[ix] = col_info.dataType.getCollationType();
    }


    /* create the conglomerate to hold the table's rows
     * RESOLVE - If we ever have a conglomerate creator
     * that lets us specify the conglomerate number then
     * we will need to handle it here.
     */
    long conglomId = tc.createConglomerate(
        "heap", // we're requesting a heap conglomerate
        template.getRowArray(), // row template
        null, //column sort order - not required for heap
                collation_ids,
        properties, // properties
        tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE ?
                    (TransactionController.IS_TEMPORARY |
                     TransactionController.IS_KEPT) :
                        TransactionController.IS_DEFAULT);

    /*
    ** 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.
    */
    if ( tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE )
      dd.startWriting(lcc);

    SchemaDescriptor sd;
    if (tableType == TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE)
      sd = dd.getSchemaDescriptor(schemaName, tc, true);
    else
      sd = DDLConstantAction.getSchemaDescriptorForCreate(dd, activation, schemaName);

    //
    // Create a new table descriptor.
    //
    DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();

    if ( tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE )
    {
      td = ddg.newTableDescriptor(tableName, sd, tableType, lockGranularity);
      dd.addDescriptor(td, sd, DataDictionary.SYSTABLES_CATALOG_NUM, false, tc);
    } else
    {
      td = ddg.newTableDescriptor(tableName, sd, tableType, onCommitDeleteRows, onRollbackDeleteRows);
      td.setUUID(dd.getUUIDFactory().createUUID());
    }
    toid = td.getUUID();

    // Save the TableDescriptor off in the Activation
    activation.setDDLTableDescriptor(td);

    /* NOTE: We must write the columns out to the system
     * tables before any of the conglomerates, including
     * the heap, since we read the columns before the
     * conglomerates when building a TableDescriptor.
     * This will hopefully reduce the probability of
     * a deadlock involving those system tables.
     */
   
    // for each column, stuff system.column
    int index = 1;

    ColumnDescriptor[] cdlArray = new ColumnDescriptor[columnInfo.length];
    for (int ix = 0; ix < columnInfo.length; ix++)
    {
      UUID defaultUUID = columnInfo[ix].newDefaultUUID;

      /* Generate a UUID for the default, if one exists
       * and there is no default id yet.
       */
      if (columnInfo[ix].defaultInfo != null &&
        defaultUUID == null)
      {
        defaultUUID = dd.getUUIDFactory().createUUID();
      }

      if (columnInfo[ix].autoincInc != 0)//dealing with autoinc column
      columnDescriptor = new ColumnDescriptor(
                           columnInfo[ix].name,
                   index++,
                   columnInfo[ix].dataType,
                   columnInfo[ix].defaultValue,
                   columnInfo[ix].defaultInfo,
                   td,
                   defaultUUID,
                   columnInfo[ix].autoincStart,
                   columnInfo[ix].autoincInc,
                   columnInfo[ix].autoinc_create_or_modify_Start_Increment
                 );
      else
        columnDescriptor = new ColumnDescriptor(
                       columnInfo[ix].name,
               index++,
               columnInfo[ix].dataType,
               columnInfo[ix].defaultValue,
               columnInfo[ix].defaultInfo,
               td,
               defaultUUID,
               columnInfo[ix].autoincStart,
               columnInfo[ix].autoincInc
             );

      cdlArray[ix] = columnDescriptor;
    }

    if ( tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE )
    {
      dd.addDescriptorArray(cdlArray, td,
                DataDictionary.SYSCOLUMNS_CATALOG_NUM,
                false, tc);
    }

    // now add the column descriptors to the table.
    ColumnDescriptorList cdl = td.getColumnDescriptorList();
    for (int i = 0; i < cdlArray.length; i++)
      cdl.add(cdlArray[i]);
        
    //
    // Create a conglomerate desciptor with the conglomId filled in and
    // add it.
    //
    // RESOLVE: Get information from the conglomerate descriptor which
    //          was provided.
    //
    ConglomerateDescriptor cgd =
      ddg.newConglomerateDescriptor(conglomId, null, false, null, false, null, toid,
                      sd.getUUID());
    if ( tableType != TableDescriptor.GLOBAL_TEMPORARY_TABLE_TYPE )
    {
      dd.addDescriptor(cgd, sd, DataDictionary.SYSCONGLOMERATES_CATALOG_NUM,
             false, tc);
    }
View Full Code Here

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

    ** we must have just read ourselves in. 
    ** So we will get the corresponding schema
    ** descriptor from the data dictionary.
    */

    SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
   
    /* Try to get the TableDescriptor from
     * the Activation. We will go to the
     * DD if not there. (It should always be
     * there except when in a target.)
View Full Code Here

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

    // find the DataDictionary
    DataDictionary dd = lcc.getDataDictionary();


    // get the SchemaDescriptor
    SchemaDescriptor sd = dd.getSchemaDescriptor(schemaName, tc, true);
    if ( !isIndex)
    {
      // get the TableDescriptor for the table
      TableDescriptor td = dd.getTableDescriptor(conglomerateName, sd);
View Full Code Here

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

    int            baseColumns = 0;
    DataValueFactory    dvf;
    long          indexRows;
    ConglomerateController  baseCC = null;
    ConglomerateController  indexCC = null;
    SchemaDescriptor    sd;
    ConstraintDescriptor  constraintDesc;

    LanguageConnectionContext lcc = ConnectionUtil.getCurrentLCC();
    tc = lcc.getTransactionExecute();
View Full Code Here

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

    }

    /*
    ** Manual lookup
    */
    SchemaDescriptor sd = locateSchemaRow(schemaName, tc);

    //if no schema found and schema name is SESSION, then create an
        //in-memory schema descriptor
    if (sd == null &&
            getDeclaredGlobalTemporaryTablesSchemaDescriptor().getSchemaName().equals(schemaName))
View Full Code Here

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

  private SchemaDescriptor getSchemaDescriptorBody(
    UUID schemaId,
    int isolationLevel,
    TransactionController tc) throws StandardException
  {
    SchemaDescriptor    sd = null;
   
    if ( tc == null )
    {
        tc = getTransactionCompile();
        }

    /*
    ** Check for APP and SYS schemas before going any
    ** further.
    */
    if (schemaId != null)
    {
      if (getSystemSchemaDescriptor().getUUID().equals(schemaId))
      {
        return getSystemSchemaDescriptor();
      }
      else if (getSysIBMSchemaDescriptor().getUUID().equals(schemaId))
      {
        return getSysIBMSchemaDescriptor();
      }
    }

    /*
    ** If we aren't booting, lets see if we already
    ** have the descriptor.  If we are in the middle
    ** of booting we cannot get the LanguageConnectionContext.
    */
    if (!booting)
    {

      LanguageConnectionContext  lcc = getLCC();

      if (lcc != null)
      {
        sd = lcc.getDefaultSchema();

        if ((sd != null) &&
            ((schemaId == null) ||
              schemaId.equals(sd.getUUID())))
        {
          return sd;
        }
      }
    }
View Full Code Here

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

    DataValueDescriptor    schemaNameOrderable;
    TabInfoImpl          ti = coreInfo[SYSSCHEMAS_CORE_NUM];

    if (SanityManager.DEBUG)
    {
      SchemaDescriptor sd = getSchemaDescriptor(schemaName, getTransactionCompile(), true);
      if (!isSchemaEmpty(sd))
      {
        SanityManager.THROWASSERT("Attempt to drop schema "+schemaName+" that is not empty");
      }
    }
View Full Code Here

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

      {
        SanityManager.THROWASSERT("null schema for non system table "+tableName);
      }
    }

    SchemaDescriptor sd = (schema == null) ?
        getSystemSchemaDescriptor()
        : schema;

    UUID schemaUUID = sd.getUUID();
   
    if (SchemaDescriptor.STD_SYSTEM_DIAG_SCHEMA_NAME.equals(
        sd.getSchemaName()))
    {
      TableDescriptor td =
        new TableDescriptor(this, tableName, sd,
            TableDescriptor.VTI_TYPE,
            TableDescriptor.DEFAULT_LOCK_GRANULARITY);
View Full Code Here

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

    LanguageConnectionContext lcc       = ConnectionUtil.getCurrentLCC();
    TransactionController     nested_tc = null;

    try {

            SchemaDescriptor sd =
                data_dictionary.getSchemaDescriptor(
                    schemaName, nested_tc, true);
            TableDescriptor td =
                data_dictionary.getTableDescriptor(tableName, sd);
            nested_tc =
View Full Code Here

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

        if ( dtd == null ) { return null; }

        BaseTypeIdImpl btii = dtd.getTypeId().getBaseTypeId();
        if ( !btii.isAnsiUDT() ) { return null; }

        SchemaDescriptor sd = getSchemaDescriptor( btii.getSchemaName(), tc, true );
        AliasDescriptor ad = getAliasDescriptor
            ( sd.getUUID().toString(), btii.getUnqualifiedName(), AliasInfo.ALIAS_NAME_SPACE_UDT_AS_CHAR );

        return ad;
    }
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.