Search in sources :

Example 1 with Statement

use of org.hsqldb_voltpatches.Statement in project voltdb by VoltDB.

the class Result method newResult.

private static Result newResult(Session session, DataInput dataInput, RowInputBinary in, int mode) throws IOException, HsqlException {
    Result result = newResult(mode);
    int length = dataInput.readInt();
    in.resetRow(0, length);
    byte[] byteArray = in.getBuffer();
    final int offset = 4;
    dataInput.readFully(byteArray, offset, length - offset);
    switch(mode) {
        case ResultConstants.GETSESSIONATTR:
            result.statementReturnType = in.readByte();
            break;
        case ResultConstants.DISCONNECT:
        case ResultConstants.RESETSESSION:
        case ResultConstants.STARTTRAN:
            break;
        case ResultConstants.PREPARE:
            result.setStatementType(in.readByte());
            result.mainString = in.readString();
            result.rsScrollability = in.readShort();
            result.rsConcurrency = in.readShort();
            result.rsHoldability = in.readShort();
            result.generateKeys = in.readByte();
            if (result.generateKeys == ResultConstants.RETURN_GENERATED_KEYS_COL_NAMES || result.generateKeys == ResultConstants.RETURN_GENERATED_KEYS_COL_INDEXES) {
                result.generatedMetaData = new ResultMetaData(in);
            }
            break;
        case ResultConstants.CLOSE_RESULT:
            result.id = in.readLong();
            break;
        case ResultConstants.FREESTMT:
            result.statementID = in.readLong();
            break;
        case ResultConstants.EXECDIRECT:
            result.updateCount = in.readInt();
            result.fetchSize = in.readInt();
            result.statementReturnType = in.readByte();
            result.mainString = in.readString();
            result.rsScrollability = in.readShort();
            result.rsConcurrency = in.readShort();
            result.rsHoldability = in.readShort();
            result.generateKeys = in.readByte();
            if (result.generateKeys == ResultConstants.RETURN_GENERATED_KEYS_COL_NAMES || result.generateKeys == ResultConstants.RETURN_GENERATED_KEYS_COL_INDEXES) {
                result.generatedMetaData = new ResultMetaData(in);
            }
            break;
        case ResultConstants.CONNECT:
            result.databaseName = in.readString();
            result.mainString = in.readString();
            result.subString = in.readString();
            result.updateCount = in.readInt();
            break;
        case ResultConstants.ERROR:
            result.mainString = in.readString();
            result.subString = in.readString();
            result.errorCode = in.readInt();
            break;
        case ResultConstants.CONNECTACKNOWLEDGE:
            result.databaseID = in.readInt();
            result.sessionID = in.readLong();
            break;
        case ResultConstants.UPDATECOUNT:
            result.updateCount = in.readInt();
            break;
        case ResultConstants.ENDTRAN:
            {
                int type = in.readInt();
                // endtran type
                result.setActionType(type);
                switch(type) {
                    case ResultConstants.TX_SAVEPOINT_NAME_RELEASE:
                    case ResultConstants.TX_SAVEPOINT_NAME_ROLLBACK:
                        // savepoint name
                        result.mainString = in.readString();
                        break;
                    case ResultConstants.TX_COMMIT:
                    case ResultConstants.TX_ROLLBACK:
                    case ResultConstants.TX_COMMIT_AND_CHAIN:
                    case ResultConstants.TX_ROLLBACK_AND_CHAIN:
                        break;
                    default:
                        throw Error.runtimeError(ErrorCode.U_S0500, "Result");
                }
                break;
            }
        case ResultConstants.SETCONNECTATTR:
            {
                // attr type
                int type = in.readInt();
                result.setConnectionAttrType(type);
                switch(type) {
                    case ResultConstants.SQL_ATTR_SAVEPOINT_NAME:
                        // savepoint name
                        result.mainString = in.readString();
                        break;
                    //  default: throw - case never happens
                    default:
                        throw Error.runtimeError(ErrorCode.U_S0500, "Result");
                }
                break;
            }
        case ResultConstants.PREPARE_ACK:
            result.statementReturnType = in.readByte();
            result.statementID = in.readLong();
            result.rsScrollability = in.readShort();
            result.rsConcurrency = in.readShort();
            result.rsHoldability = in.readShort();
            result.metaData = new ResultMetaData(in);
            result.parameterMetaData = new ResultMetaData(in);
            break;
        case ResultConstants.CALL_RESPONSE:
            result.updateCount = in.readInt();
            result.fetchSize = in.readInt();
            result.statementID = in.readLong();
            result.rsScrollability = in.readShort();
            result.rsConcurrency = in.readShort();
            result.rsHoldability = in.readShort();
            result.metaData = new ResultMetaData(in);
            result.navigator.readSimple(in, result.metaData);
            break;
        case ResultConstants.EXECUTE:
            result.updateCount = in.readInt();
            result.fetchSize = in.readInt();
            result.statementID = in.readLong();
            result.rsScrollability = in.readShort();
            result.rsConcurrency = in.readShort();
            result.rsHoldability = in.readShort();
            Statement statement = session.database.compiledStatementManager.getStatement(session, result.statementID);
            result.statement = statement;
            result.metaData = result.statement.getParametersMetaData();
            result.navigator.readSimple(in, result.metaData);
            break;
        case ResultConstants.UPDATE_RESULT:
            {
                result.id = in.readLong();
                int type = in.readInt();
                result.setActionType(type);
                result.metaData = new ResultMetaData(in);
                result.navigator.read(in, result.metaData);
                break;
            }
        case ResultConstants.BATCHEXECRESPONSE:
        case ResultConstants.BATCHEXECUTE:
        case ResultConstants.BATCHEXECDIRECT:
        case ResultConstants.SETSESSIONATTR:
            {
                result.updateCount = in.readInt();
                result.fetchSize = in.readInt();
                result.statementID = in.readLong();
                result.metaData = new ResultMetaData(in);
                result.navigator.readSimple(in, result.metaData);
                break;
            }
        case ResultConstants.PARAM_METADATA:
            {
                result.metaData = new ResultMetaData(in);
                result.navigator.read(in, result.metaData);
                break;
            }
        case ResultConstants.REQUESTDATA:
            {
                result.id = in.readLong();
                result.updateCount = in.readInt();
                result.fetchSize = in.readInt();
                break;
            }
        case ResultConstants.DATAHEAD:
        case ResultConstants.DATA:
            {
                result.id = in.readLong();
                result.updateCount = in.readInt();
                result.fetchSize = in.readInt();
                result.rsScrollability = in.readShort();
                result.rsConcurrency = in.readShort();
                result.rsHoldability = in.readShort();
                result.metaData = new ResultMetaData(in);
                result.navigator = new RowSetNavigatorClient();
                result.navigator.read(in, result.metaData);
                break;
            }
        case ResultConstants.DATAROWS:
            {
                result.metaData = new ResultMetaData(in);
                result.navigator = new RowSetNavigatorClient();
                result.navigator.read(in, result.metaData);
                break;
            }
        default:
            throw Error.runtimeError(ErrorCode.U_S0500, "Result.newResult");
    }
    return result;
}
Also used : Statement(org.hsqldb_voltpatches.Statement) RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)

Example 2 with Statement

use of org.hsqldb_voltpatches.Statement in project voltdb by VoltDB.

the class Result method readExecuteProperties.

public static void readExecuteProperties(Session session, Result result, DataInputStream dataInput, RowInputBinary in) {
    try {
        int length = dataInput.readInt();
        in.resetRow(0, length);
        byte[] byteArray = in.getBuffer();
        final int offset = 4;
        dataInput.readFully(byteArray, offset, length - offset);
        result.updateCount = in.readInt();
        result.fetchSize = in.readInt();
        result.statementID = in.readLong();
        result.rsScrollability = in.readShort();
        result.rsConcurrency = in.readShort();
        result.rsHoldability = in.readShort();
        Statement statement = session.database.compiledStatementManager.getStatement(session, result.statementID);
        result.statement = statement;
        result.metaData = result.statement.getParametersMetaData();
        result.navigator.readSimple(in, result.metaData);
    } catch (IOException e) {
        throw Error.error(ErrorCode.X_08000);
    }
}
Also used : Statement(org.hsqldb_voltpatches.Statement) IOException(java.io.IOException)

Example 3 with Statement

use of org.hsqldb_voltpatches.Statement in project voltdb by VoltDB.

the class LobManager method createSchema.

public void createSchema() {
    sysLobSession = database.sessionManager.getSysLobSession();
    Session session = sysLobSession;
    InputStream fis = getClass().getResourceAsStream(resourceFileName);
    InputStreamReader reader = null;
    try {
        reader = new InputStreamReader(fis, "ISO-8859-1");
    } catch (Exception e) {
    }
    LineNumberReader lineReader = new LineNumberReader(reader);
    LineGroupReader lg = new LineGroupReader(lineReader, starters);
    HashMappedList map = lg.getAsMap();
    lg.close();
    String sql = (String) map.get("/*lob_schema_definition*/");
    Statement statement = session.compileStatement(sql);
    Result result = statement.execute(session);
    Table table = database.schemaManager.getTable(session, "BLOCKS", "SYSTEM_LOBS");
    //            table.isTransactional = false;
    getLob = session.compileStatement(getLobSQL);
    getLobPart = session.compileStatement(getLobPartSQL);
    createLob = session.compileStatement(createLobSQL);
    createLobPart = session.compileStatement(createLobPartSQL);
    divideLobPart = session.compileStatement(divideLobPartSQL);
    deleteLob = session.compileStatement(deleteLobSQL);
    deleteLobPart = session.compileStatement(deleteLobPartSQL);
    setLobLength = session.compileStatement(updateLobLengthSQL);
    setLobUsage = session.compileStatement(updateLobUsageSQL);
    getNextLobId = session.compileStatement(getNextLobIdSQL);
}
Also used : HashMappedList(org.hsqldb_voltpatches.lib.HashMappedList) Table(org.hsqldb_voltpatches.Table) InputStreamReader(java.io.InputStreamReader) LineGroupReader(org.hsqldb_voltpatches.lib.LineGroupReader) HsqlByteArrayInputStream(org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream) InputStream(java.io.InputStream) Statement(org.hsqldb_voltpatches.Statement) IOException(java.io.IOException) EOFException(java.io.EOFException) HsqlException(org.hsqldb_voltpatches.HsqlException) Session(org.hsqldb_voltpatches.Session) LineNumberReader(java.io.LineNumberReader) Result(org.hsqldb_voltpatches.result.Result)

Example 4 with Statement

use of org.hsqldb_voltpatches.Statement in project voltdb by VoltDB.

the class LobManager method initialiseLobSpace.

public void initialiseLobSpace() {
    Statement statement = sysLobSession.compileStatement(initialiseBlocksSQL);
    Object[] args = new Object[3];
    args[0] = Integer.valueOf(0);
    args[1] = Integer.valueOf(totalBlockLimitCount);
    args[2] = Long.valueOf(0);
    sysLobSession.executeCompiledStatement(statement, args);
}
Also used : Statement(org.hsqldb_voltpatches.Statement)

Example 5 with Statement

use of org.hsqldb_voltpatches.Statement in project voltdb by VoltDB.

the class ScriptReaderText method readDDL.

protected void readDDL(Session session) throws IOException {
    for (; readLoggedStatement(session); ) {
        Statement cs = null;
        Result result = null;
        if (rowIn.getStatementType() == INSERT_STATEMENT) {
            isInsert = true;
            break;
        }
        try {
            cs = session.compileStatement(statement);
            result = session.executeCompiledStatement(cs, ValuePool.emptyObjectArray);
            if (cs.getType() == StatementTypes.CREATE_SCHEMA) {
                HsqlName name = cs.getSchemaName();
                session.setSchema(name.name);
            }
        } catch (HsqlException e) {
            result = Result.newErrorResult(e);
        }
        if (result.isError()) {
            // handle grants on math and library routines in old versions
            if (cs == null) {
            } else {
                if (cs.getType() == StatementTypes.GRANT) {
                    continue;
                }
            }
        //
        }
        if (result.isError()) {
            db.logger.appLog.logContext(SimpleLog.LOG_ERROR, result.getMainString());
            throw Error.error(ErrorCode.ERROR_IN_SCRIPT_FILE, ErrorCode.M_DatabaseScriptReader_readDDL, new Object[] { new Integer(lineCount), result.getMainString() });
        }
    }
}
Also used : Statement(org.hsqldb_voltpatches.Statement) HsqlName(org.hsqldb_voltpatches.HsqlNameManager.HsqlName) HsqlException(org.hsqldb_voltpatches.HsqlException) Result(org.hsqldb_voltpatches.result.Result)

Aggregations

Statement (org.hsqldb_voltpatches.Statement)5 IOException (java.io.IOException)2 HsqlException (org.hsqldb_voltpatches.HsqlException)2 Result (org.hsqldb_voltpatches.result.Result)2 EOFException (java.io.EOFException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 LineNumberReader (java.io.LineNumberReader)1 HsqlName (org.hsqldb_voltpatches.HsqlNameManager.HsqlName)1 Session (org.hsqldb_voltpatches.Session)1 Table (org.hsqldb_voltpatches.Table)1 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)1 HsqlByteArrayInputStream (org.hsqldb_voltpatches.lib.HsqlByteArrayInputStream)1 LineGroupReader (org.hsqldb_voltpatches.lib.LineGroupReader)1 RowSetNavigatorClient (org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)1