Fix ColumnIPv4 byte-order documentation and add IP round-trip tests - #570
Merged
Merged
Conversation
`ColumnIPv4::Append(uint32_t)` was documented as taking a host-order value, but it has always interpreted its argument as `in_addr::s_addr` (network byte order), as the existing unit test already asserted. Correct the documentation rather than the behaviour, so existing callers are not silently broken. Rename the `htonl`/`ntohl` calls in `ColumnIPv4` so they read in the direction they actually convert: incoming `s_addr` values are converted to the host-order integer that ClickHouse stores natively, and `At()` converts back. This is behaviour-neutral since both functions perform the same byte swap. Add `ClientCase.IPv4RoundTrip` / `IPv6RoundTrip`, which insert addresses through every `Append` overload and compare against the server's `toString()`, the only authoritative check of byte order. Also fix `MakeIPv4s()`: the previous list had a wrong comment, lacked an actual `255.255.255.255` and contained a duplicate.
joe-clickhouse
approved these changes
Sep 28, 2026
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.
Summary
ColumnIPv4::Append(uint32_t)was documented as taking a value in host byte order, but it has always interpreted its argument asin_addr::s_addr(network byte order). The existing unit test inut/columns_ut.cppalready asserted this (Append(3585395774)→"62.204.180.213"). This PR fixes the documentation rather than the behaviour, so existing callers are not silently broken.Fixes #521