Search in sources :

Example 1 with RowSetNavigatorClient

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

the class StatementInsert method getInsertValuesNavigator.

RowSetNavigator getInsertValuesNavigator(Session session) {
    Type[] colTypes = baseTable.getColumnTypes();
    int[] columnMap = insertColumnMap;
    //
    Expression[] list = insertExpression.nodes;
    RowSetNavigatorClient newData = new RowSetNavigatorClient(list.length);
    for (int j = 0; j < list.length; j++) {
        Expression[] rowArgs = list[j].nodes;
        Object[] data = baseTable.getNewRowData(session);
        session.sessionData.startRowProcessing();
        for (int i = 0; i < rowArgs.length; i++) {
            Expression e = rowArgs[i];
            int colIndex = columnMap[i];
            if (e.getType() == OpTypes.DEFAULT) {
                if (baseTable.identityColumn == colIndex) {
                    continue;
                }
                data[colIndex] = baseTable.colDefaults[colIndex].getValue(session);
                continue;
            }
            data[colIndex] = colTypes[colIndex].convertToType(session, e.getValue(session), e.getDataType());
        }
        newData.add(data);
    }
    return newData;
}
Also used : Type(org.hsqldb_voltpatches.types.Type) RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)

Example 2 with RowSetNavigatorClient

use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient 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 3 with RowSetNavigatorClient

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

the class Result method newDataRowsResult.

public static Result newDataRowsResult(Result source, int offset, int count) {
    if (offset + count > source.navigator.getSize()) {
        count = source.navigator.getSize() - offset;
    }
    Result result = newResult(ResultConstants.DATAROWS);
    result.id = source.id;
    result.metaData = source.metaData;
    result.navigator = new RowSetNavigatorClient(source.navigator, offset, count);
    return result;
}
Also used : RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)

Example 4 with RowSetNavigatorClient

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

the class Result method newDataHeadResult.

public static Result newDataHeadResult(SessionInterface session, Result source, int offset, int count) {
    if (offset + count > source.navigator.getSize()) {
        count = source.navigator.getSize() - offset;
    }
    Result result = newResult(ResultConstants.DATAHEAD);
    result.metaData = source.metaData;
    result.navigator = new RowSetNavigatorClient(source.navigator, offset, count);
    result.navigator.setId(source.navigator.getId());
    result.setSession(session);
    result.rsConcurrency = source.rsConcurrency;
    result.rsHoldability = source.rsHoldability;
    result.rsScrollability = source.rsScrollability;
    result.fetchSize = source.fetchSize;
    return result;
}
Also used : RowSetNavigatorClient(org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)

Example 5 with RowSetNavigatorClient

use of org.hsqldb_voltpatches.navigator.RowSetNavigatorClient 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)

Aggregations

RowSetNavigatorClient (org.hsqldb_voltpatches.navigator.RowSetNavigatorClient)12 RowSetNavigator (org.hsqldb_voltpatches.navigator.RowSetNavigator)4 Result (org.hsqldb_voltpatches.result.Result)3 Type (org.hsqldb_voltpatches.types.Type)2 ColumnBase (org.hsqldb_voltpatches.ColumnBase)1 Statement (org.hsqldb_voltpatches.Statement)1 HashMappedList (org.hsqldb_voltpatches.lib.HashMappedList)1 RangeIterator (org.hsqldb_voltpatches.navigator.RangeIterator)1 PersistentStore (org.hsqldb_voltpatches.persist.PersistentStore)1