Skip to content

Added checks in ColumnFixedString::Append #59

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

Closed
wants to merge 4 commits into from
Closed
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Minor: fixed composing exception message
  • Loading branch information
Enmk authored Nov 10, 2020
commit 3327677cfac2dd89a79061d44ca2e83b717acab0
5 changes: 3 additions & 2 deletions clickhouse/columns/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ ColumnFixedString::ColumnFixedString(size_t n)

void ColumnFixedString::Append(std::string_view str) {
if (str.size() != string_size_) {
throw std::runtime_error("Expected string of length " + std::to_string(string_size_) + ", received \"" + str + "\"");
throw std::runtime_error("Expected string of length " + std::to_string(string_size_) + ", received \"" + std::string(str) + "\"");
}
if (data_.capacity() - data_.size() < str.size())
{
// round up to the next block size
const auto new_size = (((data_.size() + string_size_) / DEFAULT_BLOCK_SIZE) + 1) * DEFAULT_BLOCK_SIZE;
const auto new_size = (((data_.size() +
_size_) / DEFAULT_BLOCK_SIZE) + 1) * DEFAULT_BLOCK_SIZE;
data_.reserve(new_size);
}

Expand Down