Search in sources :

Example 1 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class TriggerDescriptor method getSPS.

/**
 * Get the SPS for the triggered SQL statement or the WHEN clause.
 *
 * @param lcc the LanguageConnectionContext to use
 * @param isWhenClause {@code true} if the SPS for the WHEN clause is
 *   requested, {@code false} if it is the triggered SQL statement
 * @return the requested SPS
 * @throws StandardException if an error occurs
 */
private SPSDescriptor getSPS(LanguageConnectionContext lcc, boolean isWhenClause) throws StandardException {
    DataDictionary dd = getDataDictionary();
    SPSDescriptor sps = isWhenClause ? whenSPS : actionSPS;
    UUID spsId = isWhenClause ? whenSPSId : actionSPSId;
    String originalSQL = isWhenClause ? whenClauseText : triggerDefinition;
    if (sps == null) {
        // bug 4821 - do the sysstatement look up in a nested readonly
        // transaction rather than in the user transaction. Because of
        // this, the nested compile transaction which is attempting to
        // compile the trigger will not run into any locking issues with
        // the user transaction for sysstatements.
        lcc.beginNestedTransaction(true);
        sps = dd.getSPSDescriptor(spsId);
        lcc.commitNestedTransaction();
    }
    // We need to regenerate the trigger action sql if
    // 1)the trigger is found to be invalid,
    // 2)the trigger is defined at row level (that is the only kind of
    // trigger which allows reference to individual columns from
    // old/new row)
    // 3)the trigger action plan has columns that reference
    // old/new row columns(if we are working with pre-10.9 db,
    // meaning we are in soft-upgrade mode, then we won't have
    // information about the actual trigger action columns since
    // we didn't keep that info in those releases. For such dbs,
    // we will just check if they are using REFERENCING OLD and/or
    // NEW clause.)
    // This code was added as part of DERBY-4874 where the Alter table
    // had changed the length of a varchar column from varchar(30) to
    // varchar(64) but the trigger action plan continued to use varchar(30).
    // To fix varchar(30) in trigger action sql to varchar(64), we need
    // to regenerate the trigger action sql. This new trigger action sql
    // will then get updated into SYSSTATEMENTS table.
    boolean in10_9_orHigherVersion = dd.checkVersion(DataDictionary.DD_VERSION_DERBY_10_9, null);
    boolean usesReferencingClause = (in10_9_orHigherVersion) ? referencedColsInTriggerAction != null : (referencingOld || referencingNew);
    if ((!sps.isValid() || (sps.getPreparedStatement() == null)) && isRow && usesReferencingClause) {
        CompilerContext newCC = lcc.pushCompilerContext(dd.getSchemaDescriptor(sps.getCompSchemaId(), null));
        Parser pa = newCC.getParser();
        Visitable stmtnode = isWhenClause ? pa.parseSearchCondition(originalSQL) : pa.parseStatement(originalSQL);
        lcc.popCompilerContext(newCC);
        int[] cols;
        cols = dd.examineTriggerNodeAndCols(stmtnode, oldReferencingName, newReferencingName, originalSQL, referencedCols, referencedColsInTriggerAction, 0, getTableDescriptor(), -1, false, null);
        String newText = dd.getTriggerActionString(stmtnode, oldReferencingName, newReferencingName, originalSQL, referencedCols, referencedColsInTriggerAction, 0, getTableDescriptor(), -1, false, null, cols);
        if (isWhenClause) {
            // The WHEN clause is not a full SQL statement, just a search
            // condition, so we need to turn it into a statement in order
            // to create an SPS.
            newText = "VALUES " + newText;
        }
        sps.setText(newText);
    // By this point, we are finished transforming the trigger action if
    // it has any references to old/new transition variables.
    }
    return sps;
}
Also used : CompilerContext(org.apache.derby.iapi.sql.compile.CompilerContext) Visitable(org.apache.derby.iapi.sql.compile.Visitable) UUID(org.apache.derby.catalog.UUID) Parser(org.apache.derby.iapi.sql.compile.Parser)

Example 2 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class BasicDatabase method makeDatabaseID.

protected UUID makeDatabaseID(boolean create, Properties startParams) throws StandardException {
    TransactionController tc = af.getTransaction(getContextService().getCurrentContextManager());
    String upgradeID = null;
    UUID databaseID;
    if ((databaseID = (UUID) tc.getProperty(DataDictionary.DATABASE_ID)) == null) {
        // no property defined in the Transaction set
        // this could be an upgrade, see if it's stored in the service set
        UUIDFactory uuidFactory = getMonitor().getUUIDFactory();
        upgradeID = startParams.getProperty(DataDictionary.DATABASE_ID);
        if (upgradeID == null) {
            // just create one
            databaseID = uuidFactory.createUUID();
        } else {
            databaseID = uuidFactory.recreateUUID(upgradeID);
        }
        tc.setProperty(DataDictionary.DATABASE_ID, databaseID, true);
    }
    // property set.
    if (upgradeID != null)
        startParams.remove(DataDictionary.DATABASE_ID);
    tc.commit();
    tc.destroy();
    return databaseID;
}
Also used : UUIDFactory(org.apache.derby.iapi.services.uuid.UUIDFactory) TransactionController(org.apache.derby.iapi.store.access.TransactionController) UUID(org.apache.derby.catalog.UUID)

Example 3 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method create_10_10_system_procedures.

/**
 * <p>
 * Create system procedures that are part of the SYSCS_UTIL schema, added in version 10.10.
 * </p>
 *
 * @param tc an instance of the Transaction Controller.
 * @param newlyCreatedRoutines set of routines we are creating (used to add permissions later on)
 */
void create_10_10_system_procedures(TransactionController tc, HashSet<String> newlyCreatedRoutines) throws StandardException {
    UUID sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
    TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(Types.VARCHAR, 32672);
    // void SYSCS_UTIL.SYSCS_INVALIDATE_STORED_STATEMENTS()
    {
        createSystemProcedureOrFunction("SYSCS_INVALIDATE_STORED_STATEMENTS", sysUtilUUID, (String[]) null, (TypeDescriptor[]) null, 0, 0, RoutineAliasInfo.NO_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_REGISTER_TOOL
    {
        // procedure argument names
        String[] arg_names = { "toolName", "register", "optionalArgs" };
        // procedure argument types
        TypeDescriptor[] arg_types = { varchar32672Type, DataTypeDescriptor.getCatalogType(Types.BOOLEAN), varchar32672Type };
        createSystemProcedureOrFunction("SYSCS_REGISTER_TOOL", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, true, (TypeDescriptor) null, newlyCreatedRoutines, tc, "org.apache.derby.catalog.Java5SystemProcedures");
    }
}
Also used : TypeDescriptor(org.apache.derby.catalog.TypeDescriptor) DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 4 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method create_SYSCS_procedures.

/**
 * Create system procedures
 * <p>
 * Used to add the system procedures to the database when
 * it is created.  System procedures are currently added to
 * either SYSCS_UTIL or SQLJ schemas.
 * <p>
 *
 * @param tc     transaction controller to use.  Counts on caller to
 *               commit.
 * @param newlyCreatedRoutines evolving set of routines which may need to be given permissions later on
 *
 * @exception  StandardException  Standard exception policy.
 */
private final void create_SYSCS_procedures(TransactionController tc, HashSet<String> newlyCreatedRoutines) throws StandardException {
    // Types used for routine parameters and return types, all nullable.
    TypeDescriptor varchar32672Type = DataTypeDescriptor.getCatalogType(Types.VARCHAR, 32672);
    /*
		** SYSCS_UTIL routines.
		*/
    // used to put procedure into the SYSCS_UTIL schema
    UUID sysUtilUUID = getSystemUtilSchemaDescriptor().getUUID();
    // void SYSCS_UTIL.SYSCS_SET_DATABASE_PROPERTY(
    // varchar(128), varchar(Limits.DB2_VARCHAR_MAXWIDTH))
    {
        // procedure argument names
        String[] arg_names = { "KEY", "VALUE" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH) };
        createSystemProcedureOrFunction("SYSCS_SET_DATABASE_PROPERTY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_COMPRESS_TABLE(varchar(128), varchar(128), SMALLINT)
    {
        // procedure argument names
        String[] arg_names = { "SCHEMANAME", "TABLENAME", "SEQUENTIAL" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_COMPRESS_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_CHECKPOINT_DATABASE()
    {
        createSystemProcedureOrFunction("SYSCS_CHECKPOINT_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_FREEZE_DATABASE()
    {
        createSystemProcedureOrFunction("SYSCS_FREEZE_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_UNFREEZE_DATABASE()
    {
        createSystemProcedureOrFunction("SYSCS_UNFREEZE_DATABASE", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_BACKUP_DATABASE(varchar Limits.DB2_VARCHAR_MAXWIDTH)
    {
        // procedure argument names
        String[] arg_names = { "BACKUPDIR" };
        // procedure argument types
        TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH) };
        createSystemProcedureOrFunction("SYSCS_BACKUP_DATABASE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE(
    // varchar Limits.DB2_VARCHAR_MAXWIDTH, smallint)
    {
        // procedure argument names
        String[] arg_names = { "BACKUPDIR", "DELETE_ARCHIVED_LOG_FILES" };
        // procedure argument types
        TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_BACKUP_DATABASE_AND_ENABLE_LOG_ARCHIVE_MODE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_DISABLE_LOG_ARCHIVE_MODE(smallint)
    {
        // procedure argument names
        String[] arg_names = { "DELETE_ARCHIVED_LOG_FILES" };
        // procedure argument types
        TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_DISABLE_LOG_ARCHIVE_MODE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_SET_RUNTIMESTTISTICS(smallint)
    {
        // procedure argument names
        String[] arg_names = { "ENABLE" };
        // procedure argument types
        TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_SET_RUNTIMESTATISTICS", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // void SYSCS_UTIL.SYSCS_SET_STATISTICS_TIMING(smallint)
    {
        // procedure argument names
        String[] arg_names = { "ENABLE" };
        // procedure argument types
        TypeDescriptor[] arg_types = { TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_SET_STATISTICS_TIMING", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // SYSCS_UTIL functions
    // 
    // TODO (mikem) -
    // the following need to be functions when that is supported.
    // until then calling them will not work.
    // VARCHAR(Limits.DB2_VARCHAR_MAXWIDTH)
    // SYSCS_UTIL.SYSCS_GET_DATABASE_PROPERTY(varchar(128))
    {
        // procedure argument names
        String[] arg_names = { "KEY" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER };
        createSystemProcedureOrFunction("SYSCS_GET_DATABASE_PROPERTY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, tc);
    }
    // SMALLINT SYSCS_UTIL.SYSCS_CHECK_TABLE(varchar(128), varchar(128))
    {
        // procedure argument names
        String[] arg_names = { "SCHEMANAME", "TABLENAME" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER };
        createSystemProcedureOrFunction("SYSCS_CHECK_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, TypeDescriptor.INTEGER, newlyCreatedRoutines, tc);
    }
    // CLOB SYSCS_UTIL.SYSCS_GET_RUNTIMESTATISTICS()
    {
        createSystemProcedureOrFunction("SYSCS_GET_RUNTIMESTATISTICS", sysUtilUUID, null, null, 0, 0, RoutineAliasInfo.CONTAINS_SQL, false, false, DataTypeDescriptor.getCatalogType(Types.VARCHAR, Limits.DB2_VARCHAR_MAXWIDTH), newlyCreatedRoutines, /*
                TODO - mikem, wants to be a CLOB, but don't know how to do 
                that yet.  Testing it with varchar for now.
                DataTypeDescriptor.getCatalogType(
                    Types.CLOB, Limits.DB2_LOB_MAXWIDTH),
                */
        tc);
    }
    /*
		** SQLJ routine.
		*/
    UUID sqlJUUID = getSchemaDescriptor(SchemaDescriptor.STD_SQLJ_SCHEMA_NAME, tc, true).getUUID();
    // SQLJ.INSTALL_JAR(URL VARCHAR(??), JAR VARCHAR(128), DEPLOY INT)
    {
        String[] arg_names = { "URL", "JAR", "DEPLOY" };
        TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, 256), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.INTEGER };
        createSystemProcedureOrFunction("INSTALL_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // SQLJ.REPLACE_JAR(URL VARCHAR(??), JAR VARCHAR(128))
    {
        String[] arg_names = { "URL", "JAR" };
        TypeDescriptor[] arg_types = { DataTypeDescriptor.getCatalogType(Types.VARCHAR, 256), CATALOG_TYPE_SYSTEM_IDENTIFIER };
        createSystemProcedureOrFunction("REPLACE_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // SQLJ.REMOVE_JAR(JAR VARCHAR(128), UNDEPLOY INT)
    {
        String[] arg_names = { "JAR", "UNDEPLOY" };
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.INTEGER };
        createSystemProcedureOrFunction("REMOVE_JAR", sqlJUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    /*  SYSCS_EXPORT_TABLE (IN SCHEMANAME  VARCHAR(128), 
         * IN TABLENAME    VARCHAR(128),  IN FILENAME VARCHAR(32672) , 
         * IN COLUMNDELIMITER CHAR(1),  IN CHARACTERDELIMITER CHAR(1) ,  
		 * IN CODESET VARCHAR(128))
		 */
    {
        // procedure argument names
        String[] arg_names = { "schemaName", "tableName", "fileName", " columnDelimiter", "characterDelimiter", "codeset" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER };
        createSystemProcedureOrFunction("SYSCS_EXPORT_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    /* SYSCS_EXPORT_QUERY (IN SELECTSTATEMENT  VARCHAR(32672), 
		 * IN FILENAME VARCHAR(32672) , 
         * IN COLUMNDELIMITER CHAR(1),  IN CHARACTERDELIMITER CHAR(1) ,  
		 * IN CODESET VARCHAR(128))
		 */
    {
        // procedure argument names
        String[] arg_names = { "selectStatement", "fileName", " columnDelimiter", "characterDelimiter", "codeset" };
        // procedure argument types
        TypeDescriptor[] arg_types = { varchar32672Type, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER };
        createSystemProcedureOrFunction("SYSCS_EXPORT_QUERY", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.READS_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    /*  SYSCS_IMPORT_TABLE(IN SCHEMANAME VARCHAR(128), 
		 *  IN TABLENAME VARCHAR(128),  IN FILENAME VARCHAR(32672), 
		 *  IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER  CHAR(1),  
		 *  IN CODESET VARCHAR(128) , IN  REPLACE SMALLINT)
		 */
    {
        // procedure argument names
        String[] arg_names = { "schemaName", "tableName", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace" };
        // procedure argument types
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_IMPORT_TABLE", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    /*  SYSCS_IMPORT_DATA(IN SCHEMANAME VARCHAR(128), 
		 *  IN TABLENAME VARCHAR(128), IN INSERTCOLUMNLIST VARCHAR(32672), 
		 *  IN COLUMNINDEXES VARCHAR(32672), IN IN FILENAME VARCHAR(32672), 
		 *  IN COLUMNDELIMITER CHAR(1), IN CHARACTERDELIMITER  CHAR(1),  
		 *  IN CODESET VARCHAR(128) , IN  REPLACE SMALLINT)
		 */
    {
        // procedure argument names
        String[] arg_names = { "schemaName", "tableName", "insertColumnList", "columnIndexes", "fileName", " columnDelimiter", "characterDelimiter", "codeset", "replace" };
        // procedure argument types
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, varchar32672Type, varchar32672Type, DataTypeDescriptor.getCatalogType(Types.CHAR, 1), DataTypeDescriptor.getCatalogType(Types.CHAR, 1), CATALOG_TYPE_SYSTEM_IDENTIFIER, TypeDescriptor.SMALLINT };
        createSystemProcedureOrFunction("SYSCS_IMPORT_DATA", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    /*  
		 * SYSCS_BULK_INSERT(
         *     IN SCHEMANAME VARCHAR(128), 
         *     IN TABLENAME  VARCHAR(128),
		 *     IN VTINAME    VARCHAR(32672), 
         *     IN VTIARG     VARCHAR(32672))
		 */
    {
        // procedure argument names
        String[] arg_names = { "schemaName", "tableName", "vtiName", "vtiArg" };
        // procedure argument types
        TypeDescriptor[] arg_types = { CATALOG_TYPE_SYSTEM_IDENTIFIER, CATALOG_TYPE_SYSTEM_IDENTIFIER, varchar32672Type, varchar32672Type };
        createSystemProcedureOrFunction("SYSCS_BULK_INSERT", sysUtilUUID, arg_names, arg_types, 0, 0, RoutineAliasInfo.MODIFIES_SQL_DATA, false, false, (TypeDescriptor) null, newlyCreatedRoutines, tc);
    }
    // add 10.1 specific system procedures
    create_10_1_system_procedures(tc, newlyCreatedRoutines, sysUtilUUID);
    // add 10.2 specific system procedures
    create_10_2_system_procedures(tc, newlyCreatedRoutines, sysUtilUUID);
    // add 10.3 specific system procedures
    create_10_3_system_procedures(tc, newlyCreatedRoutines);
    // add 10.5 specific system procedures
    create_10_5_system_procedures(tc, newlyCreatedRoutines);
    // add 10.6 specific system procedures
    create_10_6_system_procedures(tc, newlyCreatedRoutines);
    // add 10.9 specific system procedures
    create_10_9_system_procedures(tc, newlyCreatedRoutines);
    // add 10.10 specific system procedures
    create_10_10_system_procedures(tc, newlyCreatedRoutines);
    // add 10.11 specific system procedures
    create_10_11_system_procedures(tc, newlyCreatedRoutines);
    // add 10.12 specific system procedures
    create_10_12_system_procedures(tc, newlyCreatedRoutines);
    // add 10.13 specific system procedures
    create_10_13_system_procedures(tc, newlyCreatedRoutines);
}
Also used : TypeDescriptor(org.apache.derby.catalog.TypeDescriptor) DataTypeDescriptor(org.apache.derby.iapi.types.DataTypeDescriptor) UUID(org.apache.derby.catalog.UUID)

Example 5 with UUID

use of org.apache.derby.catalog.UUID in project derby by apache.

the class DataDictionaryImpl method addSystemTableToDictionary.

/**
 *		Add the required entries to the data dictionary for a System table.
 */
private void addSystemTableToDictionary(TabInfoImpl ti, SchemaDescriptor sd, TransactionController tc, DataDescriptorGenerator ddg) throws StandardException {
    CatalogRowFactory crf = ti.getCatalogRowFactory();
    String name = ti.getTableName();
    long conglomId = ti.getHeapConglomerate();
    SystemColumn[] columnList = crf.buildColumnList();
    UUID heapUUID = crf.getCanonicalHeapUUID();
    String heapName = crf.getCanonicalHeapName();
    TableDescriptor td;
    UUID toid;
    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]);
}
Also used : ColumnDescriptorList(org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList) SystemColumn(org.apache.derby.iapi.sql.dictionary.SystemColumn) ColumnDescriptor(org.apache.derby.iapi.sql.dictionary.ColumnDescriptor) CatalogRowFactory(org.apache.derby.iapi.sql.dictionary.CatalogRowFactory) UUID(org.apache.derby.catalog.UUID) ConglomerateDescriptor(org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor) TableDescriptor(org.apache.derby.iapi.sql.dictionary.TableDescriptor) SQLLongint(org.apache.derby.iapi.types.SQLLongint)

Aggregations

UUID (org.apache.derby.catalog.UUID)101 DataValueDescriptor (org.apache.derby.iapi.types.DataValueDescriptor)31 DataDescriptorGenerator (org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator)23 TableDescriptor (org.apache.derby.iapi.sql.dictionary.TableDescriptor)22 SchemaDescriptor (org.apache.derby.iapi.sql.dictionary.SchemaDescriptor)21 ExecRow (org.apache.derby.iapi.sql.execute.ExecRow)19 ColumnDescriptor (org.apache.derby.iapi.sql.dictionary.ColumnDescriptor)15 DataDictionary (org.apache.derby.iapi.sql.dictionary.DataDictionary)15 SQLChar (org.apache.derby.iapi.types.SQLChar)15 LanguageConnectionContext (org.apache.derby.iapi.sql.conn.LanguageConnectionContext)14 TransactionController (org.apache.derby.iapi.store.access.TransactionController)14 ConglomerateDescriptor (org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor)12 SQLVarchar (org.apache.derby.iapi.types.SQLVarchar)12 DependencyManager (org.apache.derby.iapi.sql.depend.DependencyManager)11 FormatableBitSet (org.apache.derby.iapi.services.io.FormatableBitSet)10 ColumnDescriptorList (org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList)10 ConstraintDescriptor (org.apache.derby.iapi.sql.dictionary.ConstraintDescriptor)10 ArrayList (java.util.ArrayList)9 DataTypeDescriptor (org.apache.derby.iapi.types.DataTypeDescriptor)9 ExecIndexRow (org.apache.derby.iapi.sql.execute.ExecIndexRow)8