Search in sources :

Example 1 with RowSetNavigatorLinkedList

use of org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList in project voltdb by VoltDB.

the class StatementDML method executeDeleteStatement.

// fredt - currently deletes that fail due to referential constraints are caught
// prior to actual delete operation
/**
     * Executes a DELETE statement.  It is assumed that the argument is
     * of the correct type.
     *
     * @return the result of executing the statement
     */
Result executeDeleteStatement(Session session) {
    int count = 0;
    RowSetNavigatorLinkedList oldRows = new RowSetNavigatorLinkedList();
    RangeIterator it = RangeVariable.getIterator(session, targetRangeVariables);
    while (it.next()) {
        Row currentRow = it.getCurrentRow();
        oldRows.add(currentRow);
    }
    count = delete(session, baseTable, oldRows);
    if (restartIdentity && targetTable.identitySequence != null) {
        targetTable.identitySequence.reset();
    }
    return Result.getUpdateCountResult(count);
}
Also used : RowSetNavigatorLinkedList(org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList) RangeIterator(org.hsqldb_voltpatches.navigator.RangeIterator)

Example 2 with RowSetNavigatorLinkedList

use of org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList in project voltdb by VoltDB.

the class StatementResultUpdate method getResult.

Result getResult(Session session) {
    checkAccessRights(session);
    Object[] args = session.sessionContext.dynamicArguments;
    switch(actionType) {
        case ResultConstants.UPDATE_CURSOR:
            {
                Long id = (Long) args[args.length - 1];
                PersistentStore store = session.sessionData.getRowStore(baseTable);
                Row row = (Row) store.get((int) id.longValue(), false);
                HashMappedList list = new HashMappedList();
                Object[] data = (Object[]) ArrayUtil.duplicateArray(row.getData());
                for (int i = 0; i < baseColumnMap.length; i++) {
                    if (types[i] == Type.SQL_ALL_TYPES) {
                        continue;
                    }
                    data[baseColumnMap[i]] = args[i];
                }
                list.add(row, data);
                update(session, baseTable, list);
                break;
            }
        case ResultConstants.DELETE_CURSOR:
            {
                Long id = (Long) args[args.length - 1];
                PersistentStore store = session.sessionData.getRowStore(baseTable);
                Row row = (Row) store.get((int) id.longValue(), false);
                RowSetNavigator navigator = new RowSetNavigatorLinkedList();
                navigator.add(row);
                delete(session, baseTable, navigator);
                break;
            }
        case ResultConstants.INSERT_CURSOR:
            {
                Object[] data = baseTable.getNewRowData(session);
                for (int i = 0; i < data.length; i++) {
                    data[baseColumnMap[i]] = args[i];
                }
                PersistentStore store = session.sessionData.getRowStore(baseTable);
                baseTable.insertRow(session, store, data);
            }
    }
    return Result.updateOneResult;
}
Also used : RowSetNavigatorLinkedList(org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList) HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator)

Aggregations

RowSetNavigatorLinkedList (org.hsqldb_voltpatches.navigator.RowSetNavigatorLinkedList)2 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)1 RangeIterator (org.hsqldb_voltpatches.navigator.RangeIterator)1 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)1 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)1