示例#1
0
 private void removeTemporaryLobs(boolean onTimeout) {
   if (temporaryLobs != null) {
     for (Value v : temporaryLobs) {
       if (!v.isLinkedToTable()) {
         v.remove();
       }
     }
     temporaryLobs.clear();
   }
   if (temporaryResultLobs != null && temporaryResultLobs.size() > 0) {
     long keepYoungerThan = System.currentTimeMillis() - database.getSettings().lobTimeout;
     while (temporaryResultLobs.size() > 0) {
       TimeoutValue tv = temporaryResultLobs.getFirst();
       if (onTimeout && tv.created >= keepYoungerThan) {
         break;
       }
       Value v = temporaryResultLobs.removeFirst().value;
       if (!v.isLinkedToTable()) {
         v.remove();
       }
     }
   }
 }
示例#2
0
  @Override
  public void add(Session session, Row row) {
    if (mainIndexColumn == -1) {
      if (row.getKey() == 0) {
        row.setKey(++lastKey);
      }
    } else {
      long c = row.getValue(mainIndexColumn).getLong();
      row.setKey(c);
    }

    if (mvTable.getContainsLargeObject()) {
      for (int i = 0, len = row.getColumnCount(); i < len; i++) {
        Value v = row.getValue(i);
        Value v2 = v.copy(database, getId());
        if (v2.isLinkedToTable()) {
          session.removeAtCommitStop(v2);
        }
        if (v != v2) {
          row.setValue(i, v2);
        }
      }
    }

    TransactionMap<Value, Value> map = getMap(session);
    Value key = ValueLong.get(row.getKey());
    Value old = map.getLatest(key);
    if (old != null) {
      String sql = "PRIMARY KEY ON " + table.getSQL();
      if (mainIndexColumn >= 0 && mainIndexColumn < indexColumns.length) {
        sql += "(" + indexColumns[mainIndexColumn].getSQL() + ")";
      }
      DbException e = DbException.get(ErrorCode.DUPLICATE_KEY_1, sql);
      e.setSource(this);
      throw e;
    }
    try {
      map.put(key, ValueArray.get(row.getValueList()));
    } catch (IllegalStateException e) {
      throw mvTable.convertException(e);
    }
    lastKey = Math.max(lastKey, row.getKey());
  }
示例#3
0
 @Override
 public void remove(Session session, Row row) {
   if (mvTable.getContainsLargeObject()) {
     for (int i = 0, len = row.getColumnCount(); i < len; i++) {
       Value v = row.getValue(i);
       if (v.isLinkedToTable()) {
         session.removeAtCommit(v);
       }
     }
   }
   TransactionMap<Value, Value> map = getMap(session);
   try {
     Value old = map.remove(ValueLong.get(row.getKey()));
     if (old == null) {
       throw DbException.get(
           ErrorCode.ROW_NOT_FOUND_WHEN_DELETING_1, getSQL() + ": " + row.getKey());
     }
   } catch (IllegalStateException e) {
     throw mvTable.convertException(e);
   }
 }
示例#4
0
 /**
  * Remember that the given LOB value must be removed at commit.
  *
  * @param v the value
  */
 public void removeAtCommit(Value v) {
   if (SysProperties.CHECK && !v.isLinkedToTable()) {
     DbException.throwInternalError();
   }
 }