/** * Lock the given rows. * * @param forUpdateRows the rows to lock */ public void lockRows(ArrayList<Row> forUpdateRows) { for (Row row : forUpdateRows) { Row newRow = row.getCopy(); table.removeRow(session, row); table.addRow(session, newRow); } }
private void addMeta(ServerSession session, DbObject obj) { int id = obj.getId(); if (id > 0 && !starting && !obj.isTemporary()) { Row r = meta.getTemplateRow(); MetaRecord rec = new MetaRecord(obj); rec.setRecord(r); synchronized (objectIds) { objectIds.set(id); } // if (SysProperties.CHECK) { // verifyMetaLocked(session); // } meta.addRow(session, r); } }
@Override public void replicationCommit(long validKey, boolean autoCommit) { if (validKey != -1) { if (transaction != null) { transaction.replicationPrepareCommit(validKey); } if (lastRow != null) { Table table = lastIndex.getTable(); Row oldRow = lastIndex.getRow(this, validKey); // 已经修正过了 if (oldRow != null && oldRow.getValueList() == lastRow.getValueList()) { if (autoCommit) commit(); return; } if (oldRow != null) table.removeRow(this, oldRow); table.removeRow(this, lastRow); if (oldRow != null) { oldRow.setKey(lastRow.getKey()); table.addRow(this, oldRow); } lastRow.setKey(validKey); table.addRow(this, lastRow); } } if (autoCommit) { commit(); } }
@Override public void addRow(Value[] values) { Row newRow = table.getTemplateRow(); setCurrentRowNumber(++rowNumber); for (int j = 0, len = columns.length; j < len; j++) { Column c = columns[j]; int index = c.getColumnId(); try { Value v = c.convert(values[j]); newRow.setValue(index, v); } catch (DbException ex) { throw setRow(ex, rowNumber, getSQL(values)); } } table.validateConvertUpdateSequence(session, newRow); boolean done = table.fireBeforeRow(session, null, newRow); if (!done) { table.addRow(session, newRow); table.fireAfterRow(session, null, newRow, false); } }
if (!done) { table.lock(session, true, false); table.addRow(session, row); table.fireAfterRow(session, null, row, false);
table.addRow(session, newRow); table.fireAfterRow(session, null, newRow, false);