Fix bitNot for String to return a zero-terminated string#80791
Merged
azat merged 1 commit intoClickHouse:masterfrom May 26, 2025
Merged
Fix bitNot for String to return a zero-terminated string#80791azat merged 1 commit intoClickHouse:masterfrom
bitNot for String to return a zero-terminated string#80791azat merged 1 commit intoClickHouse:masterfrom
Conversation
Previuosly, due to bitNot() ignores row boundaries, it inverts the NUL
byte as well, but some code relies on the fact that String are NUL
terminated, i.e. the following will fail in debug build:
SELECT hex(any(bitNot('foo')))
With chassert() from StringValueCompatibility::getDataAtWithTerminatingZero():
Logical error: 'res.data[res.size] == '\0'
Restore NUL byte after the inversion.
Contributor
Algunenano
approved these changes
May 26, 2025
Member
Algunenano
left a comment
There was a problem hiding this comment.
LGTM. Eventhough it's tagged as a breaking change so it gets a prominent place in the changelog, I think this should be backported. Lots of code relies on the fact that Strings are null terminated
Member
Author
|
Agree, added |
Member
Author
|
All CI failures are unrelated and will be fixed by #80386 |
Member
Author
BTW initially I did not add the |
Merged
via the queue into
ClickHouse:master
with commit May 26, 2025
ab28be9
109 of 130 checks passed
robot-ch-test-poll2
added a commit
that referenced
this pull request
May 26, 2025
Cherry pick #80791 to 24.8: Fix bitNot() for String to return a zero-terminated string
This was referenced May 26, 2025
robot-ch-test-poll2
added a commit
that referenced
this pull request
May 26, 2025
Cherry pick #80791 to 25.3: Fix bitNot() for String to return a zero-terminated string
This was referenced May 26, 2025
robot-ch-test-poll2
added a commit
that referenced
this pull request
May 26, 2025
Cherry pick #80791 to 25.4: Fix bitNot() for String to return a zero-terminated string
This was referenced May 26, 2025
robot-ch-test-poll2
added a commit
that referenced
this pull request
May 26, 2025
Cherry pick #80791 to 25.5: Fix bitNot() for String to return a zero-terminated string
Algunenano
added a commit
that referenced
this pull request
May 28, 2025
Backport #80791 to 25.5: Fix bitNot() for String to return a zero-terminated string
azat
added a commit
that referenced
this pull request
Jun 1, 2025
Backport #80791 to 25.4: Fix bitNot() for String to return a zero-terminated string
bitNot for String to return a zero-terminated string
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.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix bitNot() for String to return a zero-terminated string
Previuosly, due to
bitNotignoring row boundaries, it inverts the NUL byte as well, but some code relies on the fact that String are NUL terminated, i.e. the following will fail in debug build:With chassert() from StringValueCompatibility::getDataAtWithTerminatingZero():
Restore NUL byte after the inversion.
Fixes: #80774
Note, I used the
Backward Incompatible Changeto underline this fix in changelogs, since who knows what could be broken in case of non-zero terminated strings