Search in sources :

Example 36 with Result

use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.

the class StatementQuery method getResult.

@Override
Result getResult(Session session) {
    Result result = queryExpression.getResult(session, session.getMaxRows());
    result.setStatement(this);
    return result;
}
Also used : Result(org.hsqldb_voltpatches.result.Result)

Example 37 with Result

use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.

the class SessionData method getRowSetSlice.

RowSetNavigatorClient getRowSetSlice(long id, int offset, int count) {
    Result result = (Result) resultMap.get(id);
    RowSetNavigator source = result.getNavigator();
    if (offset + count > source.getSize()) {
        count = source.getSize() - offset;
    }
    return new RowSetNavigatorClient(source, offset, count);
}
Also used : RowSetNavigator(org.hsqldb_voltpatches.navigator.RowSetNavigator) RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient) Result(org.hsqldb_voltpatches.result.Result)

Example 38 with Result

use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.

the class StatementCompound method executeIf.

private Result executeIf(Session session) {
    Result result = Result.updateZeroResult;
    boolean execute = false;
    for (int i = 0; i < statements.length; i++) {
        if (statements[i].getType() == StatementTypes.CONDITION) {
            if (execute) {
                break;
            }
            result = statements[i].execute(session);
            if (result.isError()) {
                break;
            }
            Object value = result.getValueObject();
            execute = Boolean.TRUE.equals(value);
            i++;
        }
        result = Result.updateZeroResult;
        if (!execute) {
            continue;
        }
        result = statements[i].execute(session);
        if (result.isError()) {
            break;
        }
        if (result.getType() == ResultConstants.VALUE) {
            break;
        }
    }
    return result;
}
Also used : Result(org.hsqldb_voltpatches.result.Result)

Example 39 with Result

use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.

the class DatabaseInformationFull method COLUMN_UDT_USAGE.

/**
     * UDT's are shown if the authorization is the user or a role given to the
     * user.
     *
     * <p>
     *
     * @return Table
     */
Table COLUMN_UDT_USAGE() {
    Table t = sysTables[COLUMN_UDT_USAGE];
    if (t == null) {
        t = createBlankTable(sysTableHsqlNames[COLUMN_UDT_USAGE]);
        addColumn(t, "UDT_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "UDT_SCHEMA", SQL_IDENTIFIER);
        addColumn(t, "UDT_NAME", SQL_IDENTIFIER);
        addColumn(t, "TABLE_CATALOG", SQL_IDENTIFIER);
        addColumn(t, "TABLE_SCHEMA", SQL_IDENTIFIER);
        // not null
        addColumn(t, "TABLE_NAME", SQL_IDENTIFIER);
        // not null
        addColumn(t, "COLUMN_NAME", SQL_IDENTIFIER);
        HsqlName name = HsqlNameManager.newInfoSchemaObjectName(sysTableHsqlNames[COLUMN_UDT_USAGE].name, false, SchemaObject.INDEX);
        t.createPrimaryKey(name, new int[] { 0, 1, 2, 3, 4, 5, 6 }, false);
        return t;
    }
    PersistentStore store = database.persistentStoreCollection.getStore(t);
    Session sys = database.sessionManager.newSysSession(SqlInvariants.INFORMATION_SCHEMA_HSQLNAME, session.getUser());
    Result rs = sys.executeDirectStatement("SELECT UDT_CATALOG, UDT_SCHEMA, UDT_NAME, TABLE_CATALOG, " + "TABLE_SCHEMA, TABLE_NAME, COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE UDT_NAME IS NOT NULL;");
    t.insertSys(store, rs);
    sys.close();
    return t;
}
Also used : Table(org.hsqldb_voltpatches.Table) TextTable(org.hsqldb_voltpatches.TextTable) PersistentStore(org.hsqldb_voltpatches.persist.PersistentStore) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) Session(org.hsqldb_voltpatches.Session) Result(org.hsqldb_voltpatches.result.Result)

Example 40 with Result

use of org.hsqldb_voltpatches.result.Result in project voltdb by VoltDB.

the class ScriptRunner method runScript.

/**
     *  This is used to read the *.log file and manage any necessary
     *  transaction rollback.
     */
public static void runScript(Database database, String logFilename, int logType) {
    IntKeyHashMap sessionMap = new IntKeyHashMap();
    Session current = null;
    int currentId = 0;
    database.setReferentialIntegrity(false);
    ScriptReaderBase scr = null;
    String statement;
    int statementType;
    try {
        StopWatch sw = new StopWatch();
        scr = ScriptReaderBase.newScriptReader(database, logFilename, logType);
        while (scr.readLoggedStatement(current)) {
            int sessionId = scr.getSessionNumber();
            if (current == null || currentId != sessionId) {
                currentId = sessionId;
                current = (Session) sessionMap.get(currentId);
                if (current == null) {
                    current = database.getSessionManager().newSession(database, database.getUserManager().getSysUser(), false, true, 0);
                    sessionMap.put(currentId, current);
                }
            }
            if (current.isClosed()) {
                sessionMap.remove(currentId);
                continue;
            }
            Result result = null;
            statementType = scr.getStatementType();
            switch(statementType) {
                case ScriptReaderBase.ANY_STATEMENT:
                    statement = scr.getLoggedStatement();
                    result = current.executeDirectStatement(statement);
                    if (result != null && result.isError()) {
                        if (result.getException() != null) {
                            throw result.getException();
                        }
                        throw Error.error(result);
                    }
                    break;
                case ScriptReaderBase.SEQUENCE_STATEMENT:
                    scr.getCurrentSequence().reset(scr.getSequenceValue());
                    break;
                case ScriptReaderBase.COMMIT_STATEMENT:
                    current.commit(false);
                    break;
                case ScriptReaderBase.INSERT_STATEMENT:
                    {
                        current.beginAction(null);
                        Object[] data = scr.getData();
                        scr.getCurrentTable().insertNoCheckFromLog(current, data);
                        current.endAction(Result.updateOneResult);
                        break;
                    }
                case ScriptReaderBase.DELETE_STATEMENT:
                    {
                        current.beginAction(null);
                        Object[] data = scr.getData();
                        scr.getCurrentTable().deleteNoCheckFromLog(current, data);
                        current.endAction(Result.updateOneResult);
                        break;
                    }
                case ScriptReaderBase.SET_SCHEMA_STATEMENT:
                    {
                        current.setSchema(scr.getCurrentSchema());
                    }
            }
            if (current.isClosed()) {
                sessionMap.remove(currentId);
            }
        }
    } catch (Throwable e) {
        String message;
        // catch out-of-memory errors and terminate
        if (e instanceof EOFException) {
        // end of file - normal end
        } else if (e instanceof OutOfMemoryError) {
            message = "out of memory processing " + logFilename + " line: " + scr.getLineNumber();
            database.logger.appLog.logContext(SimpleLog.LOG_ERROR, message);
            throw Error.error(ErrorCode.OUT_OF_MEMORY);
        } else {
            // stop processing on bad log line
            message = logFilename + " line: " + scr.getLineNumber() + " " + e.toString();
            database.logger.appLog.logContext(SimpleLog.LOG_ERROR, message);
        }
    } finally {
        if (scr != null) {
            scr.close();
        }
        database.getSessionManager().closeAllSessions();
        database.setReferentialIntegrity(true);
    }
}
Also used : EOFException(java.io.EOFException) ScriptReaderBase(org.hsqldb_voltpatches.scriptio.ScriptReaderBase) IntKeyHashMap(org.hsqldb_voltpatches.lib.IntKeyHashMap) Session(org.hsqldb_voltpatches.Session) StopWatch(org.hsqldb_voltpatches.lib.StopWatch) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

Result (org.hsqldb_voltpatches.result.Result)83 Session (org.hsqldb_voltpatches.Session)18 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)16 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)15 Table (org.hsqldb_voltpatches.Table)14 ResultLob (org.hsqldb_voltpatches.result.ResultLob)13 TextTable (org.hsqldb_voltpatches.TextTable)12 ResultMetaData (org.hsqldb_voltpatches.result.ResultMetaData)11 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)10 HsqlException (org.hsqldb_voltpatches.HsqlException)5 RowSetNavigatorData (org.hsqldb_voltpatches.navigator.RowSetNavigatorData)4 EOFException (java.io.EOFException)3 RowSetNavigatorClient (org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)3 IOException (java.io.IOException)2 RangeIteratorBase (org.hsqldb_voltpatches.RangeVariable.RangeIteratorBase)2 Statement (org.hsqldb_voltpatches.Statement)2 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)2 HsqlArrayList (org.hsqldb_voltpatches.lib.HsqlArrayList)2 HsqlByteArrayInputStream (org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream)2 Iterator (org.hsqldb_voltpatches.lib.Iterator)2