Package org.hsqldb_voltpatches.index

Examples of org.hsqldb_voltpatches.index.Index


        checkCreateForeignKey(c);

        Constraint uniqueConstraint =
            c.core.mainTable.getUniqueConstraintForColumns(c.core.mainCols,
                c.core.refCols);
        Index mainIndex = uniqueConstraint.getMainIndex();

        uniqueConstraint.checkReferencedRows(session, table, c.core.refCols);

        int offset = database.schemaManager.getTableIndex(table);
        boolean isForward = c.core.mainTable.getSchemaName()
                            != table.getSchemaName();

        if (offset != -1
                && offset
                   < database.schemaManager.getTableIndex(c.core.mainTable)) {
            isForward = true;
        }

        HsqlName indexName = database.nameManager.newAutoName("IDX",
            table.getSchemaName(), table.getName(), SchemaObject.INDEX);
        Index refIndex = table.createIndexStructure(indexName, c.core.refCols,
            null, null, false, true, isForward);
        HsqlName mainName = database.nameManager.newAutoName("REF",
            c.getName().name, table.getSchemaName(), table.getName(),
            SchemaObject.INDEX);
View Full Code Here


    }

    void addColumn(ColumnSchema column, int colIndex,
                   HsqlArrayList constraints) {

        Index      index          = null;
        Table      originalTable  = table;
        Constraint mainConstraint = null;
        boolean    addFK          = false;
        boolean    addUnique      = false;
        boolean    addCheck       = false;

        checkAddColumn(column);

        Constraint c = (Constraint) constraints.get(0);

        if (c.getConstraintType() == Constraint.PRIMARY_KEY) {
            c.core.mainCols = new int[]{ colIndex };

            database.schemaManager.checkSchemaObjectNotExists(c.getName());

            if (table.hasPrimaryKey()) {
                throw Error.error(ErrorCode.X_42530);
            }

            addUnique = true;
        } else {
            c = null;
        }

        table = table.moveDefinition(session, table.tableType, column, c,
                                     null, colIndex, 1, emptySet, emptySet);

        for (int i = 1; i < constraints.size(); i++) {
            c = (Constraint) constraints.get(i);

            switch (c.constType) {

                case Constraint.UNIQUE : {
                    if (addUnique) {
                        throw Error.error(ErrorCode.X_42522);
                    }

                    addUnique       = true;
                    c.core.mainCols = new int[]{ colIndex };

                    database.schemaManager.checkSchemaObjectNotExists(
                        c.getName());

                    HsqlName indexName =
                        database.nameManager.newAutoName("IDX",
                                                         c.getName().name,
                                                         table.getSchemaName(),
                                                         table.getName(),
                                                         SchemaObject.INDEX);

                    // create an autonamed index
                    index = table.createAndAddIndexStructure(indexName,
                            c.getMainColumns(), null, null, true, true, false);
                    // A VoltDB extension to support the assume unique attribute
                    index = index.setAssumeUnique(c.assumeUnique);
                    // End of VoltDB extension
                    c.core.mainTable = table;
                    c.core.mainIndex = index;

                    table.addConstraint(c);
View Full Code Here

     * @param unique boolean
     * @return new index
     */
    Index addIndex(int[] col, HsqlName name, boolean unique) {

        Index newindex;

        if (table.isEmpty(session) || table.isIndexingMutable()) {
            PersistentStore store = session.sessionData.getRowStore(table);

            newindex = table.createIndex(store, name, col, null, null, unique,
View Full Code Here

        // create an autonamed index
        HsqlName indexname = database.nameManager.newAutoName("IDX",
            name.name, table.getSchemaName(), table.getName(),
            SchemaObject.INDEX);
        Index index = table.createIndexStructure(indexname, cols, null, null,
            true, true, false);
        Constraint constraint = new Constraint(name, table, index,
                                               Constraint.UNIQUE);
        // A VoltDB extension to support the assume unique attribute
        constraint = constraint.setAssumeUnique(assumeUnique);
View Full Code Here

     *
     * @param indexName String
     */
    void dropIndex(String indexName) {

        Index index;

        index = table.getIndex(indexName);

        if (table.isIndexingMutable()) {
            table.dropIndex(session, indexName);
        } else {
            OrderedHashSet indexSet = new OrderedHashSet();

            indexSet.add(table.getIndex(indexName).getName());

            Table tn = table.moveDefinition(session, table.tableType, null,
                                            null, null, -1, 0, emptySet,
                                            indexSet);

            tn.moveData(session, table, -1, 0);
            updateConstraints(tn, emptySet);
            setNewTableInSchema(tn);
            database.persistentStoreCollection.releaseStore(table);

            table = tn;
        }

        if (!index.isConstraint()) {
            database.schemaManager.removeSchemaObject(index.getName());
        }

        database.schemaManager.recompileDependentObjects(table);
    }
View Full Code Here

     * @param unique boolean
     * @return new index
     */
    Index addExprIndex(int[] col, Expression[] indexExprs, HsqlName name, boolean unique) {

        Index newindex;

        if (table.isEmpty(session) || table.isIndexingMutable()) {
            newindex = table.createAndAddExprIndexStructure(name, col, indexExprs, unique, false);
        } else {
            newindex = table.createIndexStructure(name, col, null, null,
View Full Code Here

        // create an autonamed index
        HsqlName indexname = database.nameManager.newAutoName("IDX",
            name.name, table.getSchemaName(), table.getName(),
            SchemaObject.INDEX);
        Index exprIndex = table.createIndexStructure(indexname, cols, null, null, true, true, false);
        exprIndex = exprIndex.withExpressions(indexExprs);
        Constraint constraint = new Constraint(name, table, exprIndex, Constraint.UNIQUE).setAssumeUnique(assumeUnique);
        Table tn = table.moveDefinition(session, table.tableType, null,
                                        constraint, exprIndex, -1, 0, emptySet, emptySet);
        tn.moveData(session, table, -1, 0);
        database.persistentStoreCollection.releaseStore(table);
View Full Code Here

        cache = null;
    }

    public void setAccessor(Index key, CachedObject accessor) {

        Index index = (Index) key;

        accessorList[index.getPosition()] = accessor;
    }
View Full Code Here

     */
    public String describe(Session session) {

        StringBuffer sb;
        String       temp;
        Index        index;
        Index        primaryIndex;
        int[]        primaryKey;
        boolean      hidden;
        boolean      fullScan;

        sb           = new StringBuffer();
View Full Code Here

     * @throws HSQLParseException
     */
    VoltXMLElement voltGetRangeVariableXML(Session session)
    throws org.hsqldb_voltpatches.HSQLInterface.HSQLParseException
    {
        Index        index;
        Index        primaryIndex;

        index        = rangeIndex;
        primaryIndex = rangeTable.getPrimaryIndex();

        // get the index for this scan (/filter)
View Full Code Here

TOP

Related Classes of org.hsqldb_voltpatches.index.Index

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.