Skip to content

Instantly share code, notes, and snippets.

@elliotchance
Created December 4, 2019 22:54
Show Gist options
  • Save elliotchance/52d19775e2b334a5993509bac961b8be to your computer and use it in GitHub Desktop.
Save elliotchance/52d19775e2b334a5993509bac961b8be to your computer and use it in GitHub Desktop.
class ReadCommittedTransaction(Transaction):
def record_is_locked(self, record):
return record['expired_xid'] != 0 and \
row['expired_xid'] in self.table.active_xids
def record_is_visible(self, record):
# The record was created in active transaction that is not our
# own.
if record['created_xid'] in self.table.active_xids and \
record['created_xid'] != self.xid:
return False
# The record is expired or and no transaction holds it that is
# our own.
if record['expired_xid'] != 0 and \
(record['expired_xid'] not in self.table.active_xids or \
record['expired_xid'] == self.xid):
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment