Sandeep, December 06, 2016 - 10:17 am UTC
Hi Connor,
Thank you for the response.
One more confusion !
Just speaking in a crude way, about LOCK.
1] I want to modify a data
2] This block is not there in memory
3] I read the block into memory
4] Another person trying to modify the same
5] But the second person will find the data locked by me
This makes clear to some extent what is the use of LOCK
But I am not understanding at what point I am using the Latching mechanism, or in other words I know I am locking a db block, but when I am latching or locking a shared memory location ?
Is it something like the lock (transaction id) which is present in the block header, is escalating into a latch to protect the shared memory location, to which the block is read into, from modification. As one modification initiated by me is already in progress ?
Could you please help understanding ?
Thanks and Regards,
Sandeep
December 07, 2016 - 2:29 pm UTC
Each row on a table (in the block) has a "lock byte" - a single byte that indicates the active transaction on that block.
(which is why MAXTRANS is 255)
So when trying to lock a row, we can see from the lock byte that a row is locked.