Package org.hsqldb.navigator

Examples of org.hsqldb.navigator.RowIterator


     * checks all rows of a table to ensure they all have a corresponding
     * row in the main table.
     */
    void checkReferencedRows(Session session, Table table) {

        RowIterator it = table.rowIterator(session);

        while (true) {
            Row row = it.getNextRow();

            if (row == null) {
                break;
            }

View Full Code Here


        database.getGranteeManager().removeDbObject(table.getName());
        table.releaseTriggers();

        if (table.hasLobColumn()) {
            RowIterator it = table.rowIterator(session);

            while (it.hasNext()) {
                Row      row  = it.getNextRow();
                Object[] data = row.getData();

                session.sessionData.adjustLobUsageCount(table, data, -1);
            }
        }
View Full Code Here

            if (nulls != 0
                    && (opType == OpTypes.MATCH_PARTIAL
                        || opType == OpTypes.MATCH_UNIQUE_PARTIAL)) {
                boolean     hasMatch = false;
                RowIterator it = nodes[RIGHT].getTable().rowIterator(session);

                while (it.hasNext()) {
                    Object[] rowData = it.getNextRow().getData();
                    Boolean  result  = compareValues(session, data, rowData);

                    if (result == null) {
                        continue;
                    }

                    if (result.booleanValue()) {
                        if (opType == OpTypes.MATCH_PARTIAL) {
                            return Boolean.TRUE;
                        }

                        if (hasMatch) {
                            return Boolean.FALSE;
                        }

                        hasMatch = true;
                    }
                }

                return hasMatch ? Boolean.TRUE
                                : Boolean.FALSE;
            }

            RowIterator it =
                nodes[RIGHT].getTable().getPrimaryIndex().findFirstRow(session,
                    store, data);
            boolean result = it.hasNext();

            if (!result) {
                return Boolean.FALSE;
            }

            switch (opType) {

                case OpTypes.MATCH_SIMPLE :
                case OpTypes.MATCH_PARTIAL :
                case OpTypes.MATCH_FULL :
                    return Boolean.TRUE;
            }

            it.getNextRow();

            result = it.hasNext();

            if (!result) {
                return Boolean.TRUE;
            }

            Object[] rowData = it.getNextRow().getData();
            Boolean returnValue =
                Boolean.TRUE.equals(compareValues(session, data, rowData))
                ? Boolean.FALSE
                : Boolean.TRUE;
View Full Code Here

                                   SubQuery subquery) {

        Table           table = subquery.getTable();
        boolean         empty = table.isEmpty(session);
        Index           index = table.getFullIndex();
        RowIterator     it;
        Row             firstrow;
        PersistentStore store   = session.sessionData.getRowStore(table);
        Row             lastrow = index.lastRow(session, store).getNextRow();
        Object[]        lastdata;
        Object[]        firstdata;

        switch (exprSubType) {

            case OpTypes.ANY_QUANTIFIED : {
                if (empty) {
                    return Boolean.FALSE;
                }

                if (countNulls(data) == data.length) {
                    return null;
                }

                lastdata = lastrow.getData();

                if (countNulls(lastdata) == data.length) {
                    return null;
                }

                convertToType(session, data, nodes[LEFT].nodeDataTypes,
                              nodes[RIGHT].nodeDataTypes);

                if (opType == OpTypes.EQUAL) {
                    it = index.findFirstRow(session, store, data);

                    return it.hasNext() ? Boolean.TRUE
                                        : Boolean.FALSE;
                }

                it        = index.findFirstRowNotNull(session, store);
                firstrow  = it.getNextRow();
                firstdata = firstrow.getData();

                Boolean comparefirst = compareValues(session, data, firstdata);
                Boolean comparelast  = compareValues(session, data, lastdata);

                switch (opType) {

                    case OpTypes.NOT_EQUAL :
                        return Boolean.TRUE.equals(comparefirst)
                               || Boolean.TRUE.equals(
                                   comparelast) ? Boolean.TRUE
                                                : Boolean.FALSE;

                    case OpTypes.GREATER :
                        return comparefirst;

                    case OpTypes.GREATER_EQUAL :
                        return comparefirst;

                    case OpTypes.SMALLER :
                        return comparelast;

                    case OpTypes.SMALLER_EQUAL :
                        return comparelast;
                }

                break;
            }
            case OpTypes.ALL_QUANTIFIED : {
                if (empty) {
                    return Boolean.TRUE;
                }

                if (countNulls(data) == data.length) {
                    return null;
                }

                it        = index.firstRow(session, store);
                firstrow  = it.getNextRow();
                firstdata = firstrow.getData();

                if (countNulls(firstdata) == data.length) {
                    return null;
                }

                convertToType(session, data, nodes[LEFT].nodeDataTypes,
                              nodes[RIGHT].nodeDataTypes);

                it = index.findFirstRow(session, store, data);

                if (opType == OpTypes.EQUAL) {
                    if (it.hasNext()) {
                        return subquery.getTable().getRowCount(store) == 1
                               ? Boolean.TRUE
                               : Boolean.FALSE;
                    } else {
                        return Boolean.FALSE;
                    }
                }

                if (opType == OpTypes.NOT_EQUAL) {
                    return it.hasNext() ? Boolean.FALSE
                                        : Boolean.TRUE;
                }

                lastdata = lastrow.getData();
View Full Code Here

                        table.insertIntoTable(session, result);
                    }

                    if (table.hasLobColumn) {
                        RowIterator it = table.rowIterator(session);

                        while (it.hasNext()) {
                            Row      row  = it.getNextRow();
                            Object[] data = row.getData();

                            session.sessionData.adjustLobUsageCount(table,
                                    data, 1);
                        }
View Full Code Here

    }

    Result executeDeleteTruncateStatement(Session session) {

        PersistentStore store = targetTable.getRowStore(session);
        RowIterator     it    = targetTable.getPrimaryIndex().firstRow(store);

        try {
            while (it.hasNext()) {
                Row row = it.getNextRow();

                session.addDeleteAction((Table) row.getTable(), row, null);
            }

            if (restartIdentity && targetTable.identitySequence != null) {
                targetTable.identitySequence.reset();
            }
        } finally {
            it.release();
        }

        return Result.updateOneResult;
    }
View Full Code Here

                        session, row.getData(), data, c.core.mainCols) == 0) {
                    continue;
                }
            }

            RowIterator refiterator = c.findFkRef(session, row.getData());

            if (!refiterator.hasNext()) {
                refiterator.release();

                continue;
            }

            while (refiterator.hasNext()) {
                Row      refRow  = refiterator.getNextRow();
                Object[] refData = null;

                /** @todo use MATCH */
                if (c.core.refIndex.compareRowNonUnique(
                        session, refRow.getData(), row.getData(),
                        c.core.mainCols) != 0) {
                    break;
                }

                if (delete && refRow.getId() == row.getId()) {
                    continue;
                }

                switch (action) {

                    case SchemaObject.ReferentialAction.CASCADE : {
                        if (delete) {
                            if (navigator.addRow(refRow)) {
                                performReferentialActions(session,
                                                          c.core.refTable,
                                                          navigator, refRow,
                                                          null, null, path);
                            }

                            continue;
                        }

                        refData = c.core.refTable.getEmptyRowData();

                        System.arraycopy(refRow.getData(), 0, refData, 0,
                                         refData.length);

                        for (int j = 0; j < c.core.refCols.length; j++) {
                            refData[c.core.refCols[j]] =
                                data[c.core.mainCols[j]];
                        }

                        break;
                    }
                    case SchemaObject.ReferentialAction.SET_NULL : {
                        refData = c.core.refTable.getEmptyRowData();

                        System.arraycopy(refRow.getData(), 0, refData, 0,
                                         refData.length);

                        for (int j = 0; j < c.core.refCols.length; j++) {
                            refData[c.core.refCols[j]] = null;
                        }

                        break;
                    }
                    case SchemaObject.ReferentialAction.SET_DEFAULT : {
                        refData = c.core.refTable.getEmptyRowData();

                        System.arraycopy(refRow.getData(), 0, refData, 0,
                                         refData.length);

                        for (int j = 0; j < c.core.refCols.length; j++) {
                            ColumnSchema col =
                                c.core.refTable.getColumn(c.core.refCols[j]);

                            refData[c.core.refCols[j]] =
                                col.getDefaultValue(session);
                        }

                        break;
                    }
                    case SchemaObject.ReferentialAction.NO_ACTION :
                    case SchemaObject.ReferentialAction.RESTRICT : {
                        if (navigator.containsDeletedRow(refRow)) {
                            continue;
                        }

                        int errorCode = c.core.deleteAction
                                        == SchemaObject.ReferentialAction
                                            .NO_ACTION ? ErrorCode.X_23504
                                                       : ErrorCode.X_23001;
                        String[] info = new String[] {
                            c.core.refName.name, c.core.refTable.getName().name
                        };

                        refiterator.release();

                        throw Error.error(null, errorCode,
                                          ErrorCode.CONSTRAINT, info);
                    }
                    default :
                        continue;
                }

                refData = navigator.addRow(session, refRow, refData,
                                           table.getColumnTypes(),
                                           c.core.refCols);

                if (!path.add(c)) {
                    continue;
                }

                performReferentialActions(session, c.core.refTable, navigator,
                                          refRow, refData, c.core.refCols,
                                          path);
                path.remove(c);
            }

            refiterator.release();
        }
    }
View Full Code Here

        Row             row   = null;
        PersistentStore store = session.sessionData.getRowStore(this);

        if (hasPrimaryKey()) {
            RowIterator it = getPrimaryIndex().findFirstRow(session, store,
                data, primaryKeyColsSequence);

            row = it.getNextRow();

            it.release();
        } else if (bestIndex == null) {
            RowIterator it = rowIterator(session);

            while (true) {
                row = it.getNextRow();

                if (row == null) {
                    break;
                }

                if (Table.compareRows(
                        session, row.getData(), data, defaultColumnMap,
                        colTypes) == 0) {
                    break;
                }
            }

            it.release();
        } else {
            RowIterator it = bestIndex.findFirstRow(session, store, data);

            while (true) {
                row = it.getNextRow();

                if (row == null) {
                    break;
                }

                Object[] rowdata = row.getData();

                // reached end of range
                if (bestIndex.compareRowNonUnique(
                        session, rowdata, data, bestIndex.getColumns()) != 0) {
                    row = null;

                    break;
                }

                if (Table.compareRows(
                        session, rowdata, data, defaultColumnMap,
                        colTypes) == 0) {
                    break;
                }
            }

            it.release();
        }

        if (row == null) {
            return;
        }
View Full Code Here

        return result;
    }

    public Object[] getValues(Session session) {

        RowIterator it = table.rowIterator(session);

        if (it.hasNext()) {
            Row row = it.getNextRow();

            if (it.hasNext()) {
                throw Error.error(ErrorCode.X_21000);
            }

            return row.getData();
        } else {
View Full Code Here

        PersistentStore store = session.sessionData.getRowStore(this);

        store.setCache(from.store.getCache());

        RowIterator it = from.rowIterator(session);

        try {
            while (it.hasNext()) {
                Row row = it.getNextRow();

                store.indexRow(session, row);
            }
        } catch (Throwable t) {
            store.release();
View Full Code Here

TOP

Related Classes of org.hsqldb.navigator.RowIterator

Copyright © 2018 www.massapicom. 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.