Examples of ResultInterface


Examples of org.h2.result.ResultInterface

    public boolean isReadOnly() throws SQLException {
        try {
            debugCodeCall("isReadOnly");
            checkClosed();
            getReadOnly = prepareCommand("CALL READONLY()", getReadOnly);
            ResultInterface result = getReadOnly.executeQuery(0, false);
            result.next();
            boolean readOnly = result.currentRow()[0].getBoolean().booleanValue();
            return readOnly;
        } catch (Exception e) {
            throw logAndConvert(e);
        }
    }
View Full Code Here

Examples of org.h2.result.ResultInterface

        try {
            debugCodeCall("getCatalog");
            checkClosed();
            if (catalog == null) {
                CommandInterface cat = prepareCommand("CALL DATABASE()", Integer.MAX_VALUE);
                ResultInterface result = cat.executeQuery(0, false);
                result.next();
                catalog = result.currentRow()[0].getString();
                cat.close();
            }
            return catalog;
        } catch (Exception e) {
            throw logAndConvert(e);
View Full Code Here

Examples of org.h2.result.ResultInterface

        try {
            debugCodeCall("getQueryTimeout");
            checkClosed();
            getQueryTimeout = prepareCommand("SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME=?", getQueryTimeout);
            getQueryTimeout.getParameters().get(0).setValue(ValueString.get("QUERY_TIMEOUT"), false);
            ResultInterface result = getQueryTimeout.executeQuery(0, false);
            result.next();
            int queryTimeout = result.currentRow()[0].getInt();
            result.close();
            if (queryTimeout == 0) {
                return 0;
            }
            // round to the next second, otherwise 999 millis would return 0 seconds
            return (queryTimeout + 999) / 1000;
View Full Code Here

Examples of org.h2.result.ResultInterface

    public int getTransactionIsolation() throws SQLException {
        try {
            debugCodeCall("getTransactionIsolation");
            checkClosed();
            getLockMode = prepareCommand("CALL LOCK_MODE()", getLockMode);
            ResultInterface result = getLockMode.executeQuery(0, false);
            result.next();
            int lockMode = result.currentRow()[0].getInt();
            result.close();
            int transactionIsolationLevel;
            switch(lockMode) {
            case Constants.LOCK_MODE_OFF:
                transactionIsolationLevel = Connection.TRANSACTION_READ_UNCOMMITTED;
                break;
View Full Code Here

Examples of org.h2.result.ResultInterface

    /**
     * INTERNAL
     */
    ResultSet getGeneratedKeys(JdbcStatement stat, int id) {
        getGeneratedKeys = prepareCommand("SELECT SCOPE_IDENTITY() WHERE SCOPE_IDENTITY() IS NOT NULL", getGeneratedKeys);
        ResultInterface result = getGeneratedKeys.executeQuery(0, false);
        ResultSet rs = new JdbcResultSet(this, stat, result, id, false, true, false);
        return rs;
    }
View Full Code Here

Examples of org.lealone.result.ResultInterface

        this.query = query;
    }

    public Value getValue(Session session) {
        query.setSession(session);
        ResultInterface result = session.createSubqueryResult(query, 2); //query.query(2);
        try {
            int rowcount = result.getRowCount();
            if (rowcount > 1) {
                throw DbException.get(ErrorCode.SCALAR_SUBQUERY_CONTAINS_MORE_THAN_ONE_ROW);
            }
            Value v;
            if (rowcount <= 0) {
                v = ValueNull.INSTANCE;
            } else {
                result.next();
                Value[] values = result.currentRow();
                if (result.getVisibleColumnCount() == 1) {
                    v = values[0];
                } else {
                    v = ValueArray.get(values);
                }
            }
            return v;
        } finally {
            result.close();
        }
    }
View Full Code Here

Examples of org.lealone.result.ResultInterface

            CommandRemote cr = null;
            try {
                sr = SessionRemotePool.getMasterSessionRemote(s.getOriginalProperties());
                cr = SessionRemotePool.getCommandRemote(sr, "ALTER SEQUENCE " + getSQL() + " NEXT VALUE MARGIN", null, 1);
                //cr.executeUpdate();
                ResultInterface ri = cr.executeQuery(-1, false);
                ri.next();
                valueWithMargin = ri.currentRow()[0].getLong();
                value = valueWithMargin - increment * cacheSize;
            } catch (Exception e) {
                throw DbException.convert(e);
            } finally {
                SessionRemotePool.release(sr);
View Full Code Here

Examples of org.lealone.result.ResultInterface

        newSelect.getTopTableFilter().setIndex(
                new HBaseMergedIndex(serializedResult, table, -1, IndexColumn.wrap(table.getColumns()), IndexType
                        .createScan(false)));

        //2. 把多个结果集合并
        ResultInterface mergedResult = newSelect.queryGroupMerge();

        //3. 计算合并后的结果集,
        //例如oldSelect="select avg"时,在分布式环境要转成newSelect="select count, sum",
        //此时就由count, sum来算出avg
        ResultInterface calculatedResult = oldSelect.calculate(mergedResult, newSelect);

        //4. 如果不存在avg、stddev这类需要拆分为count、sum的计算,此时mergedResult和calculatedResult是同一个实例
        //否则就是不同实例,需要再一次按oldSelect合并结果集
        if (mergedResult != calculatedResult) {
            table = oldSelect.getTopTableFilter().getTable();
            oldSelect.getTopTableFilter().setIndex(
                    new HBaseMergedIndex(calculatedResult, table, -1, IndexColumn.wrap(table.getColumns()), IndexType
                            .createScan(false)));
            //5. 最终结果集
            result = oldSelect.queryGroupMerge();

            //6. 立刻关闭中间结果集
            serializedResult.close();
            mergedResult.close();
            calculatedResult.close();
        } else {
            result = mergedResult;
        }

    }
View Full Code Here

Examples of org.lealone.result.ResultInterface

        this.query = query;
    }

    public Value getValue(Session session) {
        query.setSession(session);
        ResultInterface result = session.createSubqueryResult(query, 1); //query.query(1);
        session.addTemporaryResult(result);
        boolean r = result.getRowCount() > 0;
        return ValueBoolean.get(r);
    }
View Full Code Here

Examples of org.lealone.result.ResultInterface

    }

    @Override
    public ResultInterface query(int limit, ResultTarget target) {
        boolean addRowToResultTarget = true;
        ResultInterface result;

        if (isExecuteDirec()) {
            result = super.query(limit, target);
            addRowToResultTarget = false;
        } else if (localRegionNames != null && localRegionNames.length != 0) {
            if (localRegionNames.length == 1) {
                whereClauseSupport.setRegionName(localRegionNames[0]);
                result = super.query(limit, target);
                addRowToResultTarget = false;
            } else {
                sqlRoutingInfo = new SQLRoutingInfo();
                sqlRoutingInfo.localRegions = Arrays.asList(localRegionNames);
                result = CommandParallel.executeQuery(session, sqlRoutingInfo, this, limit, false);
            }
        } else {
            try {
                sqlRoutingInfo = HBaseUtils.getSQLRoutingInfo((HBaseSession) session, whereClauseSupport, this);
            } catch (Exception e) {
                throw DbException.convert(e);
            }

            if (sqlRoutingInfo.localRegion != null) {
                whereClauseSupport.setRegionName(sqlRoutingInfo.localRegion);
                result = super.query(limit, target);
                addRowToResultTarget = false;
            } else if (sqlRoutingInfo.remoteCommand != null) {
                result = sqlRoutingInfo.remoteCommand.executeQuery(limit, false);
            } else {
                result = CommandParallel.executeQuery(session, sqlRoutingInfo, this, limit, false);
            }
        }

        if (addRowToResultTarget && target != null) {
            while (result.next()) {
                target.addRow(result.currentRow());
            }
            result.reset();
        }
        return result;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.