|
回滚段中存储了
1: 修改前的数据
2:UNDO 操作(也就是你的所谓指令)
3:关联的block
4: 其他
数据回滚的时候,根据回滚段内容(指令+数据+block)去做修改block
关于指令也好,数据也好,在回滚段中不过是数据结构的一部分而已!
你可以看做一个结构 st
st.v1 = update
st.v2 = 数据
当然还有其他很多内容
数据库当然知道,如果是非 当前会话来获取数据的时候就返回 st.v2 不就结了,干吗有分析一说
如果你有兴趣研究,可以去dump undo block
顺便给点 consistent read 的提示:
:
1. Read the Data Block.
2. Read the Row Header.
3. Check the Lock Byte to determine whether there's an ITL entry.
4. Read the ITL entry to determine the Transaction ID (Xid).
5. Read the Transaction Table using the Transaction ID. If the transaction has been committed and has a System Commit Number less than the query's System Change Number, update the status of the block (block cleanout) and start over at step 1.
6. Read the last undo block (Uba).
7. Compare the block transaction ID with the transaction table transaction ID. If the Transaction ID in the undo block doesn't equal the Transaction ID from the Transaction Table, then issue ORA-1555, Snapshot Too Old.
8. If the Transaction IDs are identical, make a copy of the data block in memory. Starting with the head undo entry, apply the changes to the copied data block.
9. If the tail undo entry (the actual first undo entry in the chain, or the last in the chain going backwards!) indicates another data block address, read the indicated undo block into memory and repeat steps 7 and 8 until the undo entries don't contain a value for the data block address.
10. When there's no "previous data block address," the transaction has been completely undone.
11. If the undo entry contains:
a. a pointer to a previous transaction undo block address, read the Transaction ID in the previous transaction undo block header and read the appropriate Transaction Table entry. Return to step 5.
b. an ITL record, restore the ITL record to the data block. Return to step 4. |
|