Skip to content

Commit

Permalink
Fix problem on 32bit devices when upgrading
Browse files Browse the repository at this point in the history
  • Loading branch information
jedelbo committed Feb 26, 2021
1 parent 6698fec commit 32bf01c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
### Fixed
* <How to hit and notice issue? what was the impact?> ([#????](https://github.com/realm/realm-core/issues/????), since v?.?.?)
* Support upgrading from file format 5. ([#7089](https://github.com/realm/realm-cocoa/issues/7089), since v6.0.0)
* On 32bit devices you may get exception with "No such object" when upgrading to v10.* ([#7314](https://github.com/realm/realm-java/issues/7314), since v10.0.0)

### Breaking changes
* None.
Expand Down
6 changes: 3 additions & 3 deletions src/realm/cluster_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,13 +277,13 @@ ref_type ClusterNodeInner::insert(ObjKey key, const FieldValues& init_values, Cl
size_t new_ref_ndx = child_info.ndx + 1;

int64_t split_key_value = state.split_key + child_info.offset;
size_t sz = node_size();
uint64_t sz = node_size();
if (sz < cluster_node_size) {
if (m_keys.is_attached()) {
m_keys.insert(new_ref_ndx, split_key_value);
}
else {
if (size_t(split_key_value) != sz << m_shift_factor) {
if (uint64_t(split_key_value) != sz << m_shift_factor) {
ensure_general_form();
m_keys.insert(new_ref_ndx, split_key_value);
}
Expand Down Expand Up @@ -527,7 +527,7 @@ void ClusterNodeInner::add(ref_type ref, int64_t key_value)
m_keys.add(key_value);
}
else {
if (size_t(key_value) != (node_size() << m_shift_factor)) {
if (uint64_t(key_value) != (uint64_t(node_size()) << m_shift_factor)) {
ensure_general_form();
m_keys.add(key_value);
}
Expand Down
11 changes: 11 additions & 0 deletions test/test_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5644,4 +5644,15 @@ TEST(Table_SortEncrypted)
// std::cout << "time: " << duration_cast<microseconds>(t2 - t1).count() << " us" << std::endl;
}

TEST(Table_RebuildTable)
{
Group g;
auto t = g.add_table("foo");
auto id = t->add_column(type_Int, "id");
for (int64_t i = 1; i < 8; i++) {
t->create_object().set(id, i);
}
t->set_primary_key_column(id);
}

#endif // TEST_TABLE

0 comments on commit 32bf01c

Please sign in to comment.