Skip to content

Commit

Permalink
Merge pull request #57284 from ClickHouse/cherrypick/23.10/eb6fba9f65…
Browse files Browse the repository at this point in the history
…812c8cf2c5ad6ba925c635d76cc157

Cherry pick #57147 to 23.10: Fix segfault after ALTER UPDATE with Nullable MATERIALIZED column
  • Loading branch information
robot-ch-test-poll committed Nov 28, 2023
2 parents fd74e74 + eb6fba9 commit 599be68
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
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",
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,3 @@
0 0 false
1 1 true
0 0 false
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
DROP TABLE IF EXISTS crash_02919;

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

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

DROP TABLE crash_02919;

0 comments on commit 599be68

Please sign in to comment.