/** for result tables */
  void reindex(Session session, Index index) {

    setAccessor(index, null);

    RowIterator it = table.rowIterator(this);

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

      // may need to clear the node before insert
      index.insert(session, this, row);
    }
  }
  boolean insertIndexNodes(Index primaryIndex, Index newIndex) {

    int position = newIndex.getPosition();
    RowIterator it = primaryIndex.firstRow(this, false);
    int rowCount = 0;
    HsqlException error = null;

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

        ((RowAVL) row).insertNode(position);

        // count before inserting
        rowCount++;

        newIndex.insert(null, this, row);
      }

      return true;
    } catch (java.lang.OutOfMemoryError e) {
      error = Error.error(ErrorCode.OUT_OF_MEMORY);
    } catch (HsqlException e) {
      error = e;
    }

    // backtrack on error
    // rowCount rows have been modified
    it = primaryIndex.firstRow(this, false);

    for (int i = 0; i < rowCount; i++) {
      Row row = it.getNextRow();
      NodeAVL backnode = ((RowAVL) row).getNode(0);
      int j = position;

      while (--j > 0) {
        backnode = backnode.nNext;
      }

      backnode.nNext = backnode.nNext.nNext;
    }

    throw error;
  }