Fixed error with empty TinyLog table; added a test from Nickolay Kovalev #2563

This commit is contained in:
Alexey Milovidov 2018-07-07 22:02:10 +03:00
parent b714d87de7
commit d2a44248cd
3 changed files with 19 additions and 0 deletions

View File

@ -245,6 +245,10 @@ void TinyLogBlockOutputStream::writeSuffix()
return;
done = true;
/// If nothing was written - leave the table in initial state.
if (streams.empty())
return;
/// Finish write.
for (auto & stream : streams)
stream.second->finalize();

View File

@ -0,0 +1,14 @@
DROP TABLE IF EXISTS test.empty;
DROP TABLE IF EXISTS test.data;
CREATE TABLE test.empty (value Int8) ENGINE = TinyLog;
CREATE TABLE test.data (value Int8) ENGINE = TinyLog;
INSERT INTO test.data SELECT * FROM empty;
SELECT * FROM test.data;
INSERT INTO test.data SELECT 1;
SELECT * FROM test.data;
DROP TABLE test.empty;
DROP TABLE test.data;