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

fix:ipv4 column append problem #101

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clickhouse/columns/ip4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ ColumnIPv4::ColumnIPv4(ColumnRef data)
}

void ColumnIPv4::Append(const std::string& str) {
in_addr_t addr = inet_addr(str.c_str());
if (addr == INADDR_NONE) {
struct in_addr addr;
if (inet_aton(str.c_str(),&addr) == 0) {
throw std::runtime_error("invalid IPv4 format, ip: " + str);
}
data_->Append(htonl(addr));
data_->Append(htonl(addr.s_addr));
}

void ColumnIPv4::Append(uint32_t ip) {
Expand Down
1 change: 1 addition & 0 deletions tests/simple/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ inline void IPExample(Client &client) {

auto v4 = std::make_shared<ColumnIPv4>();
v4->Append("127.0.0.1");
v4->Append("255.255.255.255");
v4->Append(3585395774);
v4->Append(0);

Expand Down