Search in sources :

Example 26 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class Constraint method checkHasMainRef.

/**
     * For the candidate table row, finds any referring node in the main table.
     * This is used to check referential integrity when updating a node. We
     * have to make sure that the main table still holds a valid main record.
     * returns true If a valid row is found, false if there are null in the data
     * Otherwise a 'INTEGRITY VIOLATION' Exception gets thrown.
     */
boolean checkHasMainRef(Session session, Object[] row) {
    if (ArrayUtil.hasNull(row, core.refCols)) {
        return false;
    }
    PersistentStore store = session.sessionData.getRowStore(core.mainTable);
    boolean exists = core.mainIndex.exists(session, store, row, core.refCols);
    if (!exists) {
        String[] info = new String[] { core.refName.name, core.mainTable.getName().name };
        throw Error.error(ErrorCode.X_23502, ErrorCode.CONSTRAINT, info);
    }
    return exists;
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 27 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TextTable method getHeader.

public String getHeader() {
    PersistentStore store = database.persistentStoreCollection.getStore(this);
    TextCache cache = (TextCache) store.getCache();
    String header = cache == null ? null : cache.getHeader();
    return header == null ? null : StringConverter.toQuotedString(header, '\"', true);
}
Also used : TextCache(org.hsqldb_voltpatches.persist.TextCache) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 28 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class TransactionManager method mergeRolledBackTransaction.

/**
     * merge a given list of transaction rollback action with given timestamp
     */
void mergeRolledBackTransaction(Object[] list, int start, int limit) {
    for (int i = start; i < limit; i++) {
        RowAction rowact = (RowAction) list[i];
        if (rowact == null || rowact.type == RowActionBase.ACTION_NONE || rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
            continue;
        }
        Row row = rowact.memoryRow;
        if (row == null) {
            PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
            row = (Row) store.get(rowact.getPos(), false);
        }
        if (row == null) {
            continue;
        }
        synchronized (row) {
            rowact.mergeRollback(row);
        }
    }
//        } catch (Throwable t) {
//            System.out.println("throw in merge");
//            t.printStackTrace();
//        }
}
Also used : PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 29 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class Table method deleteNoCheckFromLog.

/**
     * For log statements. Delete a single row.
     */
public void deleteNoCheckFromLog(Session session, Object[] data) {
    Row row = null;
    PersistentStore store = session.sessionData.getRowStore(this);
    if (hasPrimaryKey()) {
        RowIterator it = getPrimaryIndex().findFirstRow(session, store, data, primaryKeyColsSequence);
        row = it.getNextRow();
    } else if (bestIndex == null) {
        RowIterator it = rowIterator(session);
        while (true) {
            row = it.getNextRow();
            if (row == null) {
                break;
            }
            if (IndexAVL.compareRows(row.getData(), data, defaultColumnMap, colTypes) == 0) {
                break;
            }
        }
    } else {
        RowIterator it = bestIndex.findFirstRow(session, store, data);
        while (true) {
            row = it.getNextRow();
            if (row == null) {
                break;
            }
            Object[] rowdata = row.getData();
            // reached end of range
            if (bestIndex.compareRowNonUnique(data, bestIndex.getColumns(), rowdata) != 0) {
                row = null;
                break;
            }
            if (IndexAVL.compareRows(rowdata, data, defaultColumnMap, colTypes) == 0) {
                break;
            }
        }
    }
    if (row == null) {
        return;
    }
    deleteNoCheck(session, row);
}
Also used : RowIterator(org.hsqldb_voltpatches.navigator.RowIterator) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Example 30 with PersistentStore

use of org.hsqldb_voltpatches.persist.PersistentStore in project voltdb by VoltDB.

the class Table method getIndexRootsArray.

/**
     *  Return the list of file pointers to root nodes for this table's
     *  indexes.
     */
public final int[] getIndexRootsArray() {
    PersistentStore store = database.persistentStoreCollection.getStore(this);
    int[] roots = new int[getIndexCount()];
    for (int i = 0; i < getIndexCount(); i++) {
        CachedObject accessor = store.getAccessor(indexList[i]);
        roots[i] = accessor == null ? -1 : accessor.getPos();
    }
    return roots;
}
Also used : CachedObject(org.hsqldb_voltpatches.persist.CachedObject) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore)

Aggregations

PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)103 Table (org.hsqldb_voltpatches.Table)74 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)73 SchemaObject (org.hsqldb_voltpatches.SchemaObject)59 Constraint (org.hsqldb_voltpatches.Constraint)57 TextTable (org.hsqldb_voltpatches.TextTable)56 Iterator (org.hsqldb_voltpatches.lib.Iterator)51 WrapperIterator (org.hsqldb_voltpatches.lib.WrapperIterator)51 OrderedHashSet (org.hsqldb_voltpatches.lib.OrderedHashSet)20 HsqlException (org.hsqldb_voltpatches.HsqlException)19 Session (org.hsqldb_voltpatches.Session)16 Result (org.hsqldb_voltpatches.result.Result)16 NumberType (org.hsqldb_voltpatches.types.NumberType)10 Grantee (org.hsqldb_voltpatches.rights.Grantee)8 Type (org.hsqldb_voltpatches.types.Type)8 Routine (org.hsqldb_voltpatches.Routine)7 RoutineSchema (org.hsqldb_voltpatches.RoutineSchema)7 CachedObject (org.hsqldb_voltpatches.persist.CachedObject)7 TriggerDef (org.hsqldb_voltpatches.TriggerDef)6 CharacterType (org.hsqldb_voltpatches.types.CharacterType)6