Merge pull request #4161 from yandex/fix-file-engine-bad-code

Removed bad code in StorageFile
This commit is contained in:
alexey-milovidov 2019-01-27 19:33:13 +03:00 committed by GitHub
commit 1c8a34f2fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 10 deletions

View File

@ -121,7 +121,7 @@ public:
{
if (storage.use_table_fd)
{
storage.rwlock.lock();
unique_lock = std::unique_lock(storage.rwlock);
/// We could use common ReadBuffer and WriteBuffer in storage to leverage cache
/// and add ability to seek unseekable files, but cache sync isn't supported.
@ -141,7 +141,7 @@ public:
}
else
{
storage.rwlock.lock_shared();
shared_lock = std::shared_lock(storage.rwlock);
read_buf = std::make_unique<ReadBufferFromFile>(storage.path);
}
@ -149,14 +149,6 @@ public:
reader = FormatFactory::instance().getInput(storage.format_name, *read_buf, storage.getSampleBlock(), context, max_block_size);
}
~StorageFileBlockInputStream() override
{
if (storage.use_table_fd)
storage.rwlock.unlock();
else
storage.rwlock.unlock_shared();
}
String getName() const override
{
return storage.getName();
@ -184,6 +176,9 @@ private:
Block sample_block;
std::unique_ptr<ReadBufferFromFileDescriptor> read_buf;
BlockInputStreamPtr reader;
std::shared_lock<std::shared_mutex> shared_lock;
std::unique_lock<std::shared_mutex> unique_lock;
};

View File

@ -0,0 +1,6 @@
DROP TABLE IF EXISTS test.file;
CREATE TABLE test.file (number UInt64) ENGINE = File(TSV);
SELECT * FROM test.file; -- { serverError 107 }
INSERT INTO test.file VALUES (1);
SELECT * FROM test.file;
DROP TABLE test.file;