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 segfault after ALTER UPDATE with Nullable MATERIALIZED column #57147

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Interpreters/MutationsInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -690,9 +690,15 @@ void MutationsInterpreter::prepare(bool dry_run)
{
if (column.default_desc.kind == ColumnDefaultKind::Materialized)
{
auto type_literal = std::make_shared<ASTLiteral>(column.type->getName());

auto materialized_column = makeASTFunction("_CAST",
davenger marked this conversation as resolved.
Show resolved Hide resolved
column.default_desc.expression->clone(),
type_literal);

stages.back().column_to_updated.emplace(
column.name,
column.default_desc.expression->clone());
materialized_column);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1 1
0 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
DROP TABLE IF EXISTS crash_02919;

CREATE TABLE crash_02919 (
b Int64,
c Int64 MATERIALIZED b
)
ENGINE = MergeTree
ORDER BY tuple();

INSERT INTO crash_02919 VALUES (1);
SELECT b, c FROM crash_02919;
ALTER TABLE crash_02919 UPDATE b = 0 WHERE 1=1 SETTINGS mutations_sync = 1;
SELECT b, c FROM crash_02919;

DROP TABLE crash_02919;