|
@@ -1,6 +1,6 @@
|
|
|
From 80368f8ba7a8bab13440463a254888311efe3986 Mon Sep 17 00:00:00 2001
|
|
|
From: Stephan Hartmann <stha09@googlemail.com>
|
|
|
-Date: Tue, 04 May 2021 15:00:19 +0000
|
|
|
+Date: Tue, 4 May 2021 15:00:19 +0000
|
|
|
Subject: [PATCH] sql: make VirtualCursor standard layout type
|
|
|
|
|
|
sql::recover::VirtualCursor needs to be a standard layout type, but
|
|
@@ -12,12 +12,19 @@ raw pointers.
|
|
|
Bug: 1189788
|
|
|
Change-Id: Ia6dc388cc5ef1c0f2afc75f8ca45b9f12687ca9c
|
|
|
---
|
|
|
+ sql/recover_module/btree.cc | 21 +++++++++++++++------
|
|
|
+ sql/recover_module/btree.h | 17 +++++++++++++----
|
|
|
+ sql/recover_module/cursor.cc | 24 ++++++++++++------------
|
|
|
+ sql/recover_module/cursor.h | 2 +-
|
|
|
+ sql/recover_module/pager.cc | 7 +++----
|
|
|
+ sql/recover_module/pager.h | 5 +++--
|
|
|
+ 6 files changed, 47 insertions(+), 29 deletions(-)
|
|
|
|
|
|
diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
|
|
|
-index 9ecaafe..839318a 100644
|
|
|
+index 9ecaafe8a3..839318abf9 100644
|
|
|
--- a/sql/recover_module/btree.cc
|
|
|
+++ b/sql/recover_module/btree.cc
|
|
|
-@@ -135,16 +135,25 @@
|
|
|
+@@ -135,16 +135,25 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
|
|
|
"Move the destructor to the .cc file if it's non-trival");
|
|
|
#endif // !DCHECK_IS_ON()
|
|
|
|
|
@@ -50,10 +57,10 @@ index 9ecaafe..839318a 100644
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
DCHECK(CanAdvance());
|
|
|
diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
|
|
|
-index d76d076..33114b0 100644
|
|
|
+index d76d076bf6..33114b01fa 100644
|
|
|
--- a/sql/recover_module/btree.h
|
|
|
+++ b/sql/recover_module/btree.h
|
|
|
-@@ -102,7 +102,7 @@
|
|
|
+@@ -102,7 +102,7 @@ class LeafPageDecoder {
|
|
|
//
|
|
|
// |db_reader| must have been used to read an inner page of a table B-tree.
|
|
|
// |db_reader| must outlive this instance.
|
|
@@ -62,7 +69,7 @@ index d76d076..33114b0 100644
|
|
|
~LeafPageDecoder() noexcept = default;
|
|
|
|
|
|
LeafPageDecoder(const LeafPageDecoder&) = delete;
|
|
|
-@@ -150,6 +150,15 @@
|
|
|
+@@ -150,6 +150,15 @@ class LeafPageDecoder {
|
|
|
// read as long as CanAdvance() returns true.
|
|
|
bool TryAdvance();
|
|
|
|
|
@@ -78,7 +85,7 @@ index d76d076..33114b0 100644
|
|
|
// True if the given reader may point to an inner page in a table B-tree.
|
|
|
//
|
|
|
// The last ReadPage() call on |db_reader| must have succeeded.
|
|
|
-@@ -163,14 +172,14 @@
|
|
|
+@@ -163,14 +172,14 @@ class LeafPageDecoder {
|
|
|
static int ComputeCellCount(DatabasePageReader* db_reader);
|
|
|
|
|
|
// The number of the B-tree page this reader is reading.
|
|
@@ -97,10 +104,10 @@ index d76d076..33114b0 100644
|
|
|
// The reader's cursor state.
|
|
|
//
|
|
|
diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
|
|
|
-index 0029ff9..42548bc 100644
|
|
|
+index 0029ff9295..42548bc4b5 100644
|
|
|
--- a/sql/recover_module/cursor.cc
|
|
|
+++ b/sql/recover_module/cursor.cc
|
|
|
-@@ -26,7 +26,7 @@
|
|
|
+@@ -26,7 +26,7 @@ VirtualCursor::~VirtualCursor() {
|
|
|
int VirtualCursor::First() {
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
inner_decoders_.clear();
|
|
@@ -109,7 +116,7 @@ index 0029ff9..42548bc 100644
|
|
|
|
|
|
AppendPageDecoder(table_->root_page_id());
|
|
|
return Next();
|
|
|
-@@ -36,18 +36,18 @@
|
|
|
+@@ -36,18 +36,18 @@ int VirtualCursor::Next() {
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
record_reader_.Reset();
|
|
|
|
|
@@ -135,7 +142,7 @@ index 0029ff9..42548bc 100644
|
|
|
continue;
|
|
|
}
|
|
|
if (!record_reader_.Initialize())
|
|
|
-@@ -99,13 +99,13 @@
|
|
|
+@@ -99,13 +99,13 @@ int VirtualCursor::ReadColumn(int column_index,
|
|
|
int64_t VirtualCursor::RowId() {
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
DCHECK(record_reader_.IsInitialized());
|
|
@@ -152,7 +159,7 @@ index 0029ff9..42548bc 100644
|
|
|
<< __func__
|
|
|
<< " must only be called when the current path has no leaf decoder";
|
|
|
|
|
|
-@@ -113,7 +113,7 @@
|
|
|
+@@ -113,7 +113,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
|
|
|
return;
|
|
|
|
|
|
if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
|
|
@@ -162,10 +169,10 @@ index 0029ff9..42548bc 100644
|
|
|
}
|
|
|
|
|
|
diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
|
|
|
-index afcd690..b15c31d 100644
|
|
|
+index afcd6900e1..b15c31d425 100644
|
|
|
--- a/sql/recover_module/cursor.h
|
|
|
+++ b/sql/recover_module/cursor.h
|
|
|
-@@ -129,7 +129,7 @@
|
|
|
+@@ -129,7 +129,7 @@ class VirtualCursor {
|
|
|
std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
|
|
|
|
|
|
// Decodes the leaf page containing records.
|
|
@@ -175,10 +182,10 @@ index afcd690..b15c31d 100644
|
|
|
SEQUENCE_CHECKER(sequence_checker_);
|
|
|
};
|
|
|
diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
|
|
|
-index 58e75de..5fe9620 100644
|
|
|
+index 58e75de270..5fe96204e5 100644
|
|
|
--- a/sql/recover_module/pager.cc
|
|
|
+++ b/sql/recover_module/pager.cc
|
|
|
-@@ -23,8 +23,7 @@
|
|
|
+@@ -23,8 +23,7 @@ static_assert(DatabasePageReader::kMaxPageId <= std::numeric_limits<int>::max(),
|
|
|
"ints are not appropriate for representing page IDs");
|
|
|
|
|
|
DatabasePageReader::DatabasePageReader(VirtualTable* table)
|
|
@@ -188,7 +195,7 @@ index 58e75de..5fe9620 100644
|
|
|
DCHECK(table != nullptr);
|
|
|
DCHECK(IsValidPageSize(table->page_size()));
|
|
|
}
|
|
|
-@@ -57,8 +56,8 @@
|
|
|
+@@ -57,8 +56,8 @@ int DatabasePageReader::ReadPage(int page_id) {
|
|
|
std::numeric_limits<int64_t>::max(),
|
|
|
"The |read_offset| computation above may overflow");
|
|
|
|
|
@@ -200,7 +207,7 @@ index 58e75de..5fe9620 100644
|
|
|
// |page_id_| needs to be set to kInvalidPageId if the read failed.
|
|
|
// Otherwise, future ReadPage() calls with the previous |page_id_| value
|
|
|
diff --git a/sql/recover_module/pager.h b/sql/recover_module/pager.h
|
|
|
-index 0e388ddc..99314e3 100644
|
|
|
+index 0e388ddc3b..99314e30ff 100644
|
|
|
--- a/sql/recover_module/pager.h
|
|
|
+++ b/sql/recover_module/pager.h
|
|
|
@@ -5,6 +5,7 @@
|
|
@@ -211,7 +218,7 @@ index 0e388ddc..99314e3 100644
|
|
|
#include <cstdint>
|
|
|
#include <memory>
|
|
|
|
|
|
-@@ -70,7 +71,7 @@
|
|
|
+@@ -70,7 +71,7 @@ class DatabasePageReader {
|
|
|
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
|
|
|
DCHECK_NE(page_id_, kInvalidPageId)
|
|
|
<< "Successful ReadPage() required before accessing pager state";
|
|
@@ -220,7 +227,7 @@ index 0e388ddc..99314e3 100644
|
|
|
}
|
|
|
|
|
|
// The number of bytes in the page read by the last ReadPage() call.
|
|
|
-@@ -137,7 +138,7 @@
|
|
|
+@@ -137,7 +138,7 @@ class DatabasePageReader {
|
|
|
int page_id_ = kInvalidPageId;
|
|
|
// Stores the bytes of the last page successfully read by ReadPage().
|
|
|
// The content is undefined if the last call to ReadPage() did not succeed.
|