Search in sources :

Example 81 with Result

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

the class StatementProcedure method getExpressionResult.

Result getExpressionResult(Session session) {
    // representing CALL
    Expression e = expression;
    // expression return value
    Object o = e.getValue(session);
    Result r;
    if (o instanceof Result) {
        return (Result) o;
    }
    if (resultMetaData == null) {
        getResultMetaData();
    }
    /**
         * @todo 1.9.0 For table functions implment handling of Result objects
         * returned from Java functions. Review and document instantiation and usage
         * of relevant implementation of Result and JDBCResultSet for returning
         * from Java functions?
         * else if (o instanceof JDBCResultSet) {
         *   return ((JDBCResultSet) o).getResult();
         * }
         */
    r = Result.newSingleColumnResult(resultMetaData);
    Object[] row = new Object[1];
    row[0] = o;
    r.getNavigator().add(row);
    return r;
}
Also used : Result(org.hsqldb_voltpatches.result.Result)

Example 82 with Result

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

the class StatementProcedure method getProcedureResult.

Result getProcedureResult(Session session) {
    Object[] data = ValuePool.emptyObjectArray;
    if (arguments.length > 0) {
        data = new Object[arguments.length];
    }
    for (int i = 0; i < arguments.length; i++) {
        Expression e = arguments[i];
        if (e != null) {
            data[i] = e.getValue(session, e.dataType);
        }
    }
    int variableCount = procedure.getVariableCount();
    session.sessionContext.push();
    session.sessionContext.routineArguments = data;
    session.sessionContext.routineVariables = ValuePool.emptyObjectArray;
    if (variableCount > 0) {
        session.sessionContext.routineVariables = new Object[variableCount];
    }
    // fixed? temp until assignment of dynamicArguments in materialiseSubqueries is fixed
    //        Object[] args   = session.sessionContext.dynamicArguments;
    Result result = procedure.statement.execute(session);
    //        session.sessionContext.dynamicArguments = args;
    if (!result.isError()) {
        result = Result.updateZeroResult;
    }
    Object[] callArguments = session.sessionContext.routineArguments;
    session.sessionContext.pop();
    if (result.isError()) {
        return result;
    }
    boolean returnParams = false;
    for (int i = 0; i < procedure.getParameterCount(); i++) {
        ColumnSchema param = procedure.getParameter(i);
        int mode = param.getParameterMode();
        if (mode != SchemaObject.ParameterModes.PARAM_IN) {
            if (this.arguments[i].isParam) {
                int paramIndex = arguments[i].parameterIndex;
                session.sessionContext.dynamicArguments[paramIndex] = callArguments[i];
                returnParams = true;
            } else {
                int varIndex = arguments[i].getColumnIndex();
                session.sessionContext.routineVariables[varIndex] = callArguments[i];
            }
        }
    }
    if (returnParams) {
        result = Result.newCallResponse(this.getParametersMetaData().getParameterTypes(), this.id, session.sessionContext.dynamicArguments);
    }
    return result;
}
Also used : Result(org.hsqldb_voltpatches.result.Result)

Example 83 with Result

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

the class JDBCStatementBase method performPostExecute.

/**
     * processes chained warnings and any generated columns result set
     */
void performPostExecute() throws SQLException {
    resultOut.clearLobResults();
    generatedResult = null;
    if (resultIn == null) {
        return;
    }
    Result current = resultIn;
    while (current.getChainedResult() != null) {
        current = current.getUnlinkChainedResult();
        if (current.getType() == ResultConstants.WARNING) {
            SQLWarning w = Util.sqlWarning(current);
            if (rootWarning == null) {
                rootWarning = w;
            } else {
                rootWarning.setNextWarning(w);
            }
        } else if (current.getType() == ResultConstants.ERROR) {
            errorResult = current;
        } else if (current.getType() == ResultConstants.DATA) {
            generatedResult = current;
        }
    }
    if (resultIn.isData()) {
        currentResultSet = new JDBCResultSet(connection.sessionProxy, this, resultIn, resultIn.metaData, connection.connProperties);
    }
}
Also used : SQLWarning(java.sql.SQLWarning) 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