private VarKeyNode updateRecord(int index, DBRecord record) throws IOException {

		Field key = record.getKeyField();
		int keyLen = key.length();

		int offset = getRecordKeyOffset(index);
		int oldLen = getFullRecordLength(index) - keyLen;
		int len = record.length();

		// Check for use of indirect chained record node(s)
		int maxRecordLength = ((buffer.length() - HEADER_SIZE) >> 2) - ENTRY_SIZE - keyLen; // min 4 records per node
		boolean wasIndirect = hasIndirectStorage(index);
		boolean useIndirect = (len > maxRecordLength);

		if (useIndirect) {
			// Store record in chained buffers
			len = 4;
			ChainedBuffer chainedBuffer = null;
			if (wasIndirect) {
				chainedBuffer =
					new ChainedBuffer(nodeMgr.getBufferMgr(), buffer.getInt(offset + keyLen));
				chainedBuffer.setSize(record.length(), false);
			}
			else {
				chainedBuffer = new ChainedBuffer(record.length(), nodeMgr.getBufferMgr());
				buffer.putInt(offset + keyLen + oldLen - 4, chainedBuffer.getId()); // assumes old len is always > 4
				enableIndirectStorage(index, true);
			}
			record.write(chainedBuffer, 0);
		}
		else if (wasIndirect) {
			removeChainedBuffer(buffer.getInt(offset + keyLen));
			enableIndirectStorage(index, false);
		}

		// See if updated record will fit in current buffer
		if (useIndirect || len <= (getFreeSpace() + oldLen)) {

			// Overwrite record data - move other data if needed			
			int dataShift = oldLen - len;
			if (dataShift != 0) {
				offset = moveRecords(index + 1, dataShift);
				putRecordKeyOffset(index, offset);
				key.write(buffer, offset);
			}
			if (!useIndirect) {
				record.write(buffer, offset + keyLen);
			}
			return getRoot();
		}

		// Insufficient room for updated record	- remove and re-add
		VarKeyRecordNode leaf = deleteRecord(key, null).getLeafNode(key);
		return leaf.putRecord(record, null);
	}
Updates the record at the given index. 
@param index record index
@param record new record
@return root node which may have changed.
@throws IOException thrown if IO error occurs
Ghidra/Framework/DB/src/main/java/db/VarKeyRecordNode.java