Skip to content

Fix NullableT append exception guarantee#535

Merged
slabko merged 1 commit into
masterfrom
fix-nullable-append-exception-safety
Jul 9, 2026
Merged

Fix NullableT append exception guarantee#535
slabko merged 1 commit into
masterfrom
fix-nullable-append-exception-safety

Conversation

@slabko

@slabko slabko commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Fixes #376

@slabko slabko requested a review from mzitnik as a code owner July 8, 2026 14:39
@slabko slabko changed the title Fix NullableT append exception safety Fix NullableT append exception guarantee Jul 8, 2026
@mshustov mshustov requested a review from Copilot July 9, 2026 07:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes exception-safety for ColumnNullableT::Append(...) so that if the nested column’s Append() throws, the nullable column does not end up with an extra (incorrect) null-flag entry. This addresses the inconsistent-size/invalid-access behavior described in PR #376.

Changes:

  • Add rollback logic to ColumnNullableT::Append(...) to erase the last null-flag when nested append throws.
  • Apply the same rollback behavior to the ColumnNullableT<ColumnJSON> specialization.
  • Add a unit test covering the regression case using ColumnFixedString throwing validation errors.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
ut/Column_ut.cpp Adds a regression test ensuring nullable size/nulls/nested sizes remain consistent when nested append throws.
clickhouse/columns/nullable.h Adds exception rollback to keep nulls_ consistent if nested append fails.
clickhouse/columns/json.h Mirrors the rollback behavior for the ColumnJSON nullable specialization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 97 to +99
inline void Append(ValueType value) {
ColumnNullable::Append(!value.has_value());
if (value.has_value()) {
typed_nested_data_->Append(std::move(*value));
} else {
typed_nested_data_->Append(typename ValueType::value_type{});
try {
typed_nested_data_->Append(typename ValueType::value_type{});
}
} catch (...) {
Nulls()->template As<ColumnUInt8>()->Erase(Size() - 1);
@slabko slabko merged commit 1106659 into master Jul 9, 2026
79 checks passed
@slabko slabko deleted the fix-nullable-append-exception-safety branch July 9, 2026 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants