{{ message }}
Repository navigation
Fix pathological scan memory for NULLs trailing an overflow string (#24897) - #24918
Merged
Merged
Conversation
…uckdb#24897) Uncompressed VARCHAR overflow strings are stored with a negative dictionary offset, and a NULL copies the previous row's offset verbatim to make its delta-computed length 0. This copies the sign too, so a NULL following an overflow string inherits its negative offset and FetchStringFromDict routes it to ReadOverflowString, allocating a full pinned copy of the big string per trailing NULL (~STANDARD_VECTOR_SIZE copies per vector, tag OVERFLOW_STRINGS). A NULL that copied a marker has a negative offset but a computed length of 0, whereas a real overflow string always has length BIG_STRING_MARKER_SIZE. Short- circuit the negative branch when the length is 0 and return an empty string. This is a scan-side fix at the single choke point, so it also repairs already- written databases with no storage-format change.
duckdb-draftbot
marked this pull request as draft
August 20, 2026 14:04
mdlavin
marked this pull request as ready for review
August 20, 2026 14:19
2 tasks done
taniabogatsch
approved these changes
Aug 25, 2026
Member
8 of 9 tasks
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

This is a a backport of #24898. The testcase needed to avoid the use of
include_segment_infowhich does not exist in 1.5.xUncompressed VARCHAR overflow strings are stored with a negative dictionary offset, and a NULL copies the previous row's offset verbatim to make its delta-computed length 0. This copies the sign too, so a NULL following an overflow string inherits its negative offset and FetchStringFromDict routes it to ReadOverflowString, allocating a full pinned copy of the big string per trailing NULL (~STANDARD_VECTOR_SIZE copies per vector, tag OVERFLOW_STRINGS).
A NULL that copied a marker has a negative offset but a computed length of 0, whereas a real overflow string always has length BIG_STRING_MARKER_SIZE. Short- circuit the negative branch when the length is 0 and return an empty string. This is a scan-side fix at the single choke point, so it also repairs already- written databases with no storage-format change.