summaryrefslogtreecommitdiffstats
path: root/sql-make-VirtualCursor-standard-layout-type.patch
diff options
context:
space:
mode:
authorJustKidding <jk@vin.ovh>2022-02-03 21:02:23 -0500
committerJustKidding <jk@vin.ovh>2022-02-03 21:02:23 -0500
commit8341144248a36f9e8a384ed630a48485575b1523 (patch)
tree061f580a4abcbd009be667371fb6e17bc40e0173 /sql-make-VirtualCursor-standard-layout-type.patch
parent1a132b256b3723dce209e2125976ea7c83e437b7 (diff)
downloadungoogled-chromium-8341144248a36f9e8a384ed630a48485575b1523.tar.gz
ungoogled-chromium-8341144248a36f9e8a384ed630a48485575b1523.tar.bz2
ungoogled-chromium-8341144248a36f9e8a384ed630a48485575b1523.zip
upgpkg: ungoogled-chromium 98.0.4758.80-1
upstream release
Diffstat (limited to 'sql-make-VirtualCursor-standard-layout-type.patch')
-rw-r--r--sql-make-VirtualCursor-standard-layout-type.patch94
1 files changed, 47 insertions, 47 deletions
diff --git a/sql-make-VirtualCursor-standard-layout-type.patch b/sql-make-VirtualCursor-standard-layout-type.patch
index c1c68f1..3364d41 100644
--- a/sql-make-VirtualCursor-standard-layout-type.patch
+++ b/sql-make-VirtualCursor-standard-layout-type.patch
@@ -1,30 +1,29 @@
-From 80368f8ba7a8bab13440463a254888311efe3986 Mon Sep 17 00:00:00 2001
+From 144479ad7b4287bee4067f95e4218f614798a865 Mon Sep 17 00:00:00 2001
From: Stephan Hartmann <stha09@googlemail.com>
-Date: Tue, 4 May 2021 15:00:19 +0000
+Date: Sun, 16 Jan 2022 19:15:26 +0000
Subject: [PATCH] sql: make VirtualCursor standard layout type
sql::recover::VirtualCursor needs to be a standard layout type, but
has members of type std::unique_ptr. However, std::unique_ptr is not
guaranteed to be standard layout. Compiling with clang combined with
-gcc-11 libstdc++ fails because of this. Replace std::unique_ptr with
-raw pointers.
+gcc-11 libstdc++ fails because of this.
Bug: 1189788
Change-Id: Ia6dc388cc5ef1c0f2afc75f8ca45b9f12687ca9c
---
- sql/recover_module/btree.cc | 21 +++++++++++++++------
- sql/recover_module/btree.h | 17 +++++++++++++----
+ sql/recover_module/btree.cc | 18 ++++++++++++------
+ sql/recover_module/btree.h | 21 +++++++++++++++------
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(-)
+ sql/recover_module/pager.cc | 5 ++---
+ sql/recover_module/pager.h | 6 +++---
+ 6 files changed, 45 insertions(+), 31 deletions(-)
diff --git a/sql/recover_module/btree.cc b/sql/recover_module/btree.cc
-index 9ecaafe8a3..839318abf9 100644
+index cc9420e5c05..f12d8fa32a2 100644
--- a/sql/recover_module/btree.cc
+++ b/sql/recover_module/btree.cc
-@@ -135,16 +135,25 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
+@@ -136,16 +136,22 @@ static_assert(std::is_trivially_destructible<LeafPageDecoder>::value,
"Move the destructor to the .cc file if it's non-trival");
#endif // !DCHECK_IS_ON()
@@ -34,46 +33,47 @@ index 9ecaafe8a3..839318abf9 100644
- cell_count_(ComputeCellCount(db_reader)),
- next_read_index_(0),
- last_record_size_(0) {
++LeafPageDecoder::LeafPageDecoder() noexcept = default;
++
+void LeafPageDecoder::Initialize(DatabasePageReader* db_reader) {
-+ DCHECK(db_reader);
- DCHECK(IsOnValidPage(db_reader));
+ page_id_ = db_reader->page_id();
+ db_reader_ = db_reader;
+ cell_count_ = ComputeCellCount(db_reader);
+ next_read_index_ = 0;
+ last_record_size_ = 0;
+ DCHECK(IsOnValidPage(db_reader));
DCHECK(DatabasePageReader::IsValidPageId(page_id_));
}
+void LeafPageDecoder::Reset() {
+ db_reader_ = nullptr;
-+ page_id_ = 0;
-+ cell_count_ = 0;
-+ next_read_index_ = 0;
-+ last_record_size_ = 0;
+}
+
bool LeafPageDecoder::TryAdvance() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(CanAdvance());
diff --git a/sql/recover_module/btree.h b/sql/recover_module/btree.h
-index d76d076bf6..33114b01fa 100644
+index eaa087a5c52..df0e0c937c0 100644
--- a/sql/recover_module/btree.h
+++ b/sql/recover_module/btree.h
-@@ -102,7 +102,7 @@ class LeafPageDecoder {
+@@ -101,9 +101,7 @@ class LeafPageDecoder {
+ public:
+ // Creates a decoder for a DatabasePageReader's last read page.
//
- // |db_reader| must have been used to read an inner page of a table B-tree.
- // |db_reader| must outlive this instance.
+- // |db_reader| must have been used to read an inner page of a table B-tree.
+- // |db_reader| must outlive this instance.
- explicit LeafPageDecoder(DatabasePageReader* db_reader) noexcept;
-+ explicit LeafPageDecoder() noexcept = default;
++ LeafPageDecoder() noexcept;
~LeafPageDecoder() noexcept = default;
LeafPageDecoder(const LeafPageDecoder&) = delete;
-@@ -150,6 +150,15 @@ class LeafPageDecoder {
+@@ -151,6 +149,17 @@ class LeafPageDecoder {
// read as long as CanAdvance() returns true.
bool TryAdvance();
+ // Initialize with DatabasePageReader
++ // |db_reader| must have been used to read an inner page of a table B-tree.
++ // |db_reader| must outlive this instance.
+ void Initialize(DatabasePageReader* db_reader);
+
+ // Reset internal DatabasePageReader
@@ -85,7 +85,7 @@ index d76d076bf6..33114b01fa 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 @@ class LeafPageDecoder {
+@@ -164,14 +173,14 @@ class LeafPageDecoder {
static int ComputeCellCount(DatabasePageReader* db_reader);
// The number of the B-tree page this reader is reading.
@@ -104,10 +104,10 @@ index d76d076bf6..33114b01fa 100644
// The reader's cursor state.
//
diff --git a/sql/recover_module/cursor.cc b/sql/recover_module/cursor.cc
-index 0029ff9295..42548bc4b5 100644
+index 4f827edf1b4..240de4999fe 100644
--- a/sql/recover_module/cursor.cc
+++ b/sql/recover_module/cursor.cc
-@@ -26,7 +26,7 @@ VirtualCursor::~VirtualCursor() {
+@@ -28,7 +28,7 @@ VirtualCursor::~VirtualCursor() {
int VirtualCursor::First() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
inner_decoders_.clear();
@@ -116,7 +116,7 @@ index 0029ff9295..42548bc4b5 100644
AppendPageDecoder(table_->root_page_id());
return Next();
-@@ -36,18 +36,18 @@ int VirtualCursor::Next() {
+@@ -38,18 +38,18 @@ int VirtualCursor::Next() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
record_reader_.Reset();
@@ -142,7 +142,7 @@ index 0029ff9295..42548bc4b5 100644
continue;
}
if (!record_reader_.Initialize())
-@@ -99,13 +99,13 @@ int VirtualCursor::ReadColumn(int column_index,
+@@ -101,13 +101,13 @@ int VirtualCursor::ReadColumn(int column_index,
int64_t VirtualCursor::RowId() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(record_reader_.IsInitialized());
@@ -159,7 +159,7 @@ index 0029ff9295..42548bc4b5 100644
<< __func__
<< " must only be called when the current path has no leaf decoder";
-@@ -113,7 +113,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
+@@ -115,7 +115,7 @@ void VirtualCursor::AppendPageDecoder(int page_id) {
return;
if (LeafPageDecoder::IsOnValidPage(&db_reader_)) {
@@ -169,10 +169,10 @@ index 0029ff9295..42548bc4b5 100644
}
diff --git a/sql/recover_module/cursor.h b/sql/recover_module/cursor.h
-index afcd6900e1..b15c31d425 100644
+index 845b7852648..cc4e85f83f9 100644
--- a/sql/recover_module/cursor.h
+++ b/sql/recover_module/cursor.h
-@@ -129,7 +129,7 @@ class VirtualCursor {
+@@ -130,7 +130,7 @@ class VirtualCursor {
std::vector<std::unique_ptr<InnerPageDecoder>> inner_decoders_;
// Decodes the leaf page containing records.
@@ -182,7 +182,7 @@ index afcd6900e1..b15c31d425 100644
SEQUENCE_CHECKER(sequence_checker_);
};
diff --git a/sql/recover_module/pager.cc b/sql/recover_module/pager.cc
-index 58e75de270..5fe96204e5 100644
+index 58e75de2704..69d98cef98d 100644
--- a/sql/recover_module/pager.cc
+++ b/sql/recover_module/pager.cc
@@ -23,8 +23,7 @@ static_assert(DatabasePageReader::kMaxPageId <= std::numeric_limits<int>::max(),
@@ -191,34 +191,34 @@ index 58e75de270..5fe96204e5 100644
DatabasePageReader::DatabasePageReader(VirtualTable* table)
- : page_data_(std::make_unique<uint8_t[]>(table->page_size())),
- table_(table) {
-+ : page_data_(), table_(table) {
++ : page_data_(table->page_size()), table_(table) {
DCHECK(table != nullptr);
DCHECK(IsValidPageSize(table->page_size()));
}
-@@ -57,8 +56,8 @@ int DatabasePageReader::ReadPage(int page_id) {
- std::numeric_limits<int64_t>::max(),
+@@ -58,7 +57,7 @@ int DatabasePageReader::ReadPage(int page_id) {
"The |read_offset| computation above may overflow");
-- int sqlite_status =
+ int sqlite_status =
- RawRead(sqlite_file, read_size, read_offset, page_data_.get());
-+ int sqlite_status = RawRead(sqlite_file, read_size, read_offset,
-+ const_cast<uint8_t*>(page_data_.data()));
++ RawRead(sqlite_file, read_size, read_offset, page_data_.data());
// |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 0e388ddc3b..99314e30ff 100644
+index 07cac3cb989..d08f0932fab 100644
--- a/sql/recover_module/pager.h
+++ b/sql/recover_module/pager.h
-@@ -5,6 +5,7 @@
- #ifndef SQL_RECOVER_MODULE_PAGER_H_
+@@ -6,8 +6,8 @@
#define SQL_RECOVER_MODULE_PAGER_H_
-+#include <array>
#include <cstdint>
- #include <memory>
+-#include <memory>
+ #include <ostream>
++#include <vector>
-@@ -70,7 +71,7 @@ class DatabasePageReader {
+ #include "base/check_op.h"
+ #include "base/memory/raw_ptr.h"
+@@ -72,7 +72,7 @@ class DatabasePageReader {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK_NE(page_id_, kInvalidPageId)
<< "Successful ReadPage() required before accessing pager state";
@@ -227,12 +227,12 @@ index 0e388ddc3b..99314e30ff 100644
}
// The number of bytes in the page read by the last ReadPage() call.
-@@ -137,7 +138,7 @@ class DatabasePageReader {
+@@ -139,7 +139,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.
- const std::unique_ptr<uint8_t[]> page_data_;
-+ const std::array<uint8_t, kMaxPageSize> page_data_;
++ std::vector<uint8_t> page_data_;
// Raw pointer usage is acceptable because this instance's owner is expected
// to ensure that the VirtualTable outlives this.
- VirtualTable* const table_;
+ const raw_ptr<VirtualTable> table_;