Skip to content

Commit

Permalink
Fix Log family table return wrong rows count after truncate (#50585)
Browse files Browse the repository at this point in the history
* Fix Log family table return wrong rows count after truncate

* fix test

* update test

* update test
  • Loading branch information
ucasfl committed Jun 9, 2023
1 parent 8f9c74d commit ad74189
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Storages/StorageLog.cpp
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
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
@@ -0,0 +1,2 @@
0
0
26 changes: 26 additions & 0 deletions tests/queries/0_stateless/02771_log_faminy_truncate_count.sql
@@ -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;

0 comments on commit ad74189

Please sign in to comment.