Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBL-6239: Fixed c4doc_getRevisionBody in a 2.x db w/version vectors #2136

Merged
merged 2 commits into from
Sep 16, 2024

Conversation

snej
Copy link
Collaborator

@snej snej commented Sep 12, 2024

VectorRecord didn't properly manage the body column of a doc from a 2.x db that doesn't have the extra column. In such a db the body is the encoded rev tree, not just the current rev. VectorRecord was returning that entire slice from its currentRevisionData method ... and since that wasn't valid Fleece data, getting the root Dict would fail.

I added a new member _bodyDocRange, a slice that's just the current rev within the _bodyDoc. Normally it's the same as _bodyDoc.data(), but in a 2.x doc it encompasses just the current rev body.

Our db upgrade tests didn't catch this because they called c4doc_getProperties but not c4doc_getRevisionBody. I remedied that (which reproduced the bug.)

Fixes CBL-6239

VectorRecord didn't properly manage the `body` column of a doc from a
2.x db that doesn't have the `extra` column. In such a db the body is
the encoded rev tree, not just the current rev. VectorRecord was
returning that entire slice from its currentRevisionData method.

I added a new member _bodyDocRange, a slice that's just the current
rev within the _bodyDoc. Normally it's the same as _bodyDoc.data(),
but in a 2.x doc it encompasses just the current rev body.

Fixes CBL-6239
@snej snej changed the title CBL-6239: Fixed c4doc_getRevisionBody in a 2.x db CBL-6239: Fixed c4doc_getRevisionBody in a 2.x db w/version vectors Sep 12, 2024
@cbl-bot
Copy link

cbl-bot commented Sep 12, 2024

Code Coverage Results:

Type Percentage
branches 65.88
functions 78.75
instantiations 33.19
lines 77.67
regions 73.22

@jianminzhao jianminzhao self-requested a review September 16, 2024 21:33
@jianminzhao jianminzhao merged commit 848e05f into master Sep 16, 2024
9 checks passed
@jianminzhao jianminzhao deleted the fix/CBL-6239-getRevisionBody branch September 16, 2024 21:34
jianminzhao added a commit that referenced this pull request Sep 17, 2024
CBL-5616: Update SG version in docker-compose.yml (#2121)
CBL-6239: Fixed c4doc_getRevisionBody in a 2.x db (#2136)
92fc5cc Make sync work across VV upgrades (#1913)
abe9759 Merge in tag 3.2.0
8009302 Statically link to libstdc++ (#2134)
CBL-6169: DataFile::documentKeys() is not thread-safe (#2132)
CBL-6189: Annotation of thread-safety, filling in the missing ones after the first pass. (#2129)
471e5ec Allow a Timer to destruct itself during its callback (#2124)
b090363 Fixed C4CollectionSpec hash and equality (#2122)
cba409e LogEncoder cleanup (#2130)
cf53ccd Rewritten query translator (#1966)
9f75fab Updated Fleece now that its PR is merged
d6c2091 Update Android NDK even more
47cc9ad Update Jenkins configuration to support C++20
1652943 C++20: use std::ranges, contains() methods, std::size()
f27f8dd Build with C++20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants