コード例 #1
0
  /** @todo test skips some equal rows because it relies on getPos() */
  int compareRowForInsert(Row newRow, Row existingRow) {

    // only allow new inserts over rows deleted by the same session
    if (newRow.rowAction != null && !canRead(newRow.rowAction.session, existingRow)) {
      return newRow.getPos() - existingRow.getPos();
    }

    return 0;
  }
コード例 #2
0
  void deleteRows(Object[] list, int start, int limit, boolean commit) {

    for (int i = start; i < limit; i++) {
      RowAction rowact = (RowAction) list[i];

      if (rowact.type == RowActionBase.ACTION_DELETE_FINAL) {
        try {
          rowact.type = RowActionBase.ACTION_DELETE_COMMITTED;

          PersistentStore store = rowact.session.sessionData.getRowStore(rowact.table);
          Row row = rowact.memoryRow;

          if (row == null) {
            row = (Row) store.get(rowact.getPos(), false);
          }

          if (commit && rowact.table.hasLobColumn) {
            Object[] data = row.getData();

            rowact.session.sessionData.removeLobUsageCount(rowact.table, data);
          }

          store.delete(row);
          store.remove(row.getPos());
        } catch (HsqlException e) {

          //                    throw unexpectedException(e.getMessage());
        }
      }
    }
  }
コード例 #3
0
  /**
   * Compare two rows of the table for inserting rows into unique indexes
   *
   * @param a data
   * @param b data
   * @return comparison result, -1,0,+1
   * @throws HsqlException
   */
  private int compareRowUnique(Session session, Row left, Row right) throws HsqlException {

    Object[] a = left.getData();
    Object[] b = right.getData();
    int j = 0;
    boolean hasNull = false;

    for (; j < colIndex.length; j++) {
      Object currentvalue = a[colIndex[j]];
      int i = Column.compare(collation, currentvalue, b[colIndex[j]], colType[j]);

      if (i != 0) {
        return i;
      }

      if (currentvalue == null) {
        hasNull = true;
      }
    }

    if (isUnique && !useRowId && !hasNull) {
      return 0;
    }

    for (j = 0; j < pkCols.length; j++) {
      Object currentvalue = a[pkCols[j]];
      int i = Column.compare(collation, currentvalue, b[pkCols[j]], pkTypes[j]);

      if (i != 0) {
        return i;
      }
    }

    if (useRowId) {
      int difference = left.getPos() - right.getPos();

      if (difference < 0) {
        difference = -1;
      } else if (difference > 0) {
        difference = 1;
      }

      return difference;
    }

    return 0;
  }
コード例 #4
0
    public long getRowId() {

      return currentRow == null
          ? 0
          : ((long) rangeVar.rangeTable.getId() << 32) + ((long) currentRow.getPos());
    }