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

Backport #50585 to 23.5: Fix Log family table return wrong rows count after truncate #50787

Merged
merged 1 commit into from
Jun 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions src/Storages/StorageLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ void StorageLog::truncate(const ASTPtr &, const StorageMetadataPtr &, ContextPtr

marks_loaded = true;
num_marks_saved = 0;
total_rows = 0;
total_bytes = 0;
getContext()->dropMMappedFileCache();
}

Expand Down
2 changes: 2 additions & 0 deletions src/Storages/StorageStripeLog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ void StorageStripeLog::truncate(const ASTPtr &, const StorageMetadataPtr &, Cont

indices_loaded = true;
num_indices_saved = 0;
total_rows = 0;
total_bytes = 0;
getContext()->dropMMappedFileCache();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
0
0
26 changes: 26 additions & 0 deletions tests/queries/0_stateless/02771_log_faminy_truncate_count.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
DROP TABLE IF EXISTS test_log;
CREATE TABLE test_log
(
`crypto_name` String,
`trade_date` Date
)
ENGINE = Log;

INSERT INTO test_log (crypto_name, trade_date) VALUES ('abc', '2021-01-01'), ('def', '2022-02-02');

TRUNCATE TABLE test_log;
SELECT count() FROM test_log;

DROP TABLE IF EXISTS test_log;
CREATE TABLE test_log
(
`crypto_name` String,
`trade_date` Date
)
ENGINE = StripeLog;

INSERT INTO test_log (crypto_name, trade_date) VALUES ('abc', '2021-01-01'), ('def', '2022-02-02');

TRUNCATE TABLE test_log;
SELECT count() FROM test_log;
DROP TABLE test_log;