Beispiel #1
0
 /**
  * Update a list of rows in this table.
  *
  * @param prepared the prepared statement
  * @param session the session
  * @param rows a list of row pairs of the form old row, new row, old row, new row,...
  */
 public void updateRows(Prepared prepared, Session session, RowList rows) {
   // in case we need to undo the update
   int rollback = session.getUndoLogPos();
   // remove the old rows
   int rowScanCount = 0;
   for (rows.reset(); rows.hasNext(); ) {
     if ((++rowScanCount & 127) == 0) {
       prepared.checkCanceled();
     }
     Row o = rows.next();
     rows.next();
     removeRow(session, o);
     session.log(this, UndoLogRecord.DELETE, o);
   }
   // add the new rows
   for (rows.reset(); rows.hasNext(); ) {
     if ((++rowScanCount & 127) == 0) {
       prepared.checkCanceled();
     }
     rows.next();
     Row n = rows.next();
     try {
       addRow(session, n);
     } catch (DbException e) {
       if (e.getErrorCode() == ErrorCode.CONCURRENT_UPDATE_1) {
         session.rollbackTo(rollback, false);
       }
       throw e;
     }
     session.log(this, UndoLogRecord.INSERT, n);
   }
 }