Skip to content

Commit

Permalink
Backport #52517 to 23.6: Fix lightweight delete after drop of projection
Browse files Browse the repository at this point in the history
  • Loading branch information
robot-clickhouse committed Aug 29, 2023
1 parent 6008384 commit a1a89ab
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Storages/MergeTree/MergeTreeData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5683,6 +5683,10 @@ bool MergeTreeData::supportsLightweightDelete() const
auto lock = lockParts();
for (const auto & part : data_parts_by_info)
{
if (part->getState() == MergeTreeDataPartState::Outdated
|| part->getState() == MergeTreeDataPartState::Deleting)
continue;

if (!part->supportLightweightDeleteMutate())
return false;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
99
20 changes: 20 additions & 0 deletions tests/queries/0_stateless/02792_drop_projection_lwd.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
SET mutations_sync = 2;

DROP TABLE IF EXISTS t_projections_lwd;

CREATE TABLE t_projections_lwd (a UInt32, b UInt32, PROJECTION p (SELECT * ORDER BY b)) ENGINE = MergeTree ORDER BY a;

INSERT INTO t_projections_lwd SELECT number, number FROM numbers(100);

-- LWD does not work, as expected
DELETE FROM t_projections_lwd WHERE a = 1; -- { serverError BAD_ARGUMENTS }
KILL MUTATION WHERE database = currentDatabase() AND table = 't_projections_lwd' SYNC FORMAT Null;

-- drop projection
ALTER TABLE t_projections_lwd DROP projection p;

DELETE FROM t_projections_lwd WHERE a = 2;

SELECT count() FROM t_projections_lwd;

DROP TABLE t_projections_lwd;

0 comments on commit a1a89ab

Please sign in to comment.