mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 20:02:05 +00:00
dbms: fixed exception in TinyLog when it is empty [#METR-12532]
This commit is contained in:
parent
5b954f7dbe
commit
1a73e77463
@ -144,6 +144,8 @@ public:
|
||||
|
||||
Files_t & getFiles();
|
||||
|
||||
std::string full_path() { return path + escapeForFileName(name) + '/';}
|
||||
|
||||
private:
|
||||
String path;
|
||||
String name;
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <DB/Columns/ColumnNested.h>
|
||||
|
||||
#include <DB/Storages/StorageTinyLog.h>
|
||||
|
||||
#include <Poco/DirectoryIterator.h>
|
||||
|
||||
#define DBMS_STORAGE_LOG_DATA_FILE_EXTENSION ".bin"
|
||||
|
||||
@ -61,6 +61,12 @@ Block TinyLogBlockInputStream::readImpl()
|
||||
return res;
|
||||
}
|
||||
|
||||
{
|
||||
/// если в папке нет файлов, то это значит, что таблица пока пуста
|
||||
if (Poco::DirectoryIterator(storage.full_path()) == Poco::DirectoryIterator())
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Если файлы не открыты, то открываем их.
|
||||
if (streams.empty())
|
||||
for (Names::const_iterator it = column_names.begin(); it != column_names.end(); ++it)
|
||||
|
5
dbms/tests/queries/0_stateless/00068_empty_tiny_log.sql
Normal file
5
dbms/tests/queries/0_stateless/00068_empty_tiny_log.sql
Normal file
@ -0,0 +1,5 @@
|
||||
CREATE TABLE IF NOT EXISTS test_empty_tiny_log(A UInt8) Engine = TinyLog;
|
||||
|
||||
SELECT A FROM test_empty_tiny_log;
|
||||
|
||||
DROP TABLE test_empty_tiny_log;
|
Loading…
Reference in New Issue
Block a user