-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
jiangzhe
committed
Jan 14, 2025
1 parent
845bf60
commit f8db485
Showing
8 changed files
with
258 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
use crate::buffer::page::PageID; | ||
use crate::buffer::BufferPool; | ||
use crate::row::RowID; | ||
use crate::table::TableID; | ||
use crate::trx::redo::RedoEntry; | ||
use crate::trx::undo::SharedUndoEntry; | ||
use crate::trx::ActiveTrx; | ||
|
||
pub struct Statement { | ||
pub trx: ActiveTrx, | ||
// statement-level undo logs. | ||
pub undo: Vec<SharedUndoEntry>, | ||
// statement-level redo logs. | ||
pub redo: Vec<RedoEntry>, | ||
} | ||
|
||
impl Statement { | ||
#[inline] | ||
pub fn new(trx: ActiveTrx) -> Self { | ||
Statement { | ||
trx, | ||
undo: vec![], | ||
redo: vec![], | ||
} | ||
} | ||
|
||
#[inline] | ||
pub fn commit(mut self) -> ActiveTrx { | ||
self.trx.trx_undo.extend(self.undo.drain(..)); | ||
self.trx.trx_redo.extend(self.redo.drain(..)); | ||
self.trx | ||
} | ||
|
||
#[inline] | ||
pub fn rollback<P: BufferPool>(self, buf_pool: &P) -> ActiveTrx { | ||
todo!(); | ||
} | ||
|
||
#[inline] | ||
pub fn last_undo_entry(&self) -> Option<&SharedUndoEntry> { | ||
self.undo.last() | ||
} | ||
|
||
#[inline] | ||
pub fn load_active_insert_page(&mut self, table_id: TableID) -> Option<(PageID, RowID)> { | ||
self.trx | ||
.session | ||
.as_mut() | ||
.and_then(|session| session.load_active_insert_page(table_id)) | ||
} | ||
|
||
#[inline] | ||
pub fn save_active_insert_page(&mut self, table_id: TableID, page_id: PageID, row_id: RowID) { | ||
if let Some(session) = self.trx.session.as_mut() { | ||
session.save_active_insert_page(table_id, page_id, row_id); | ||
} | ||
} | ||
} |
Oops, something went wrong.