Fix SIGSEGV on INSERT into Distributed on different struct with underlying

This commit is contained in:
Azat Khuzhin 2020-04-08 02:02:16 +03:00
parent 7a69664e7e
commit b2fa9d8750
3 changed files with 15 additions and 1 deletions

View File

@ -305,7 +305,9 @@ ThreadPool::Job DistributedBlockOutputStream::runWritingJob(DistributedBlockOutp
job.local_context = std::make_unique<Context>(context); job.local_context = std::make_unique<Context>(context);
InterpreterInsertQuery interp(query_ast, *job.local_context); InterpreterInsertQuery interp(query_ast, *job.local_context);
job.stream = interp.execute().out; auto block_io = interp.execute();
assertBlocksHaveEqualStructure(block_io.out->getHeader(), shard_block, "flushing shard block for " + storage.getStorageID().getNameForLogs());
job.stream = block_io.out;
job.stream->writePrefix(); job.stream->writePrefix();
} }
@ -544,6 +546,9 @@ void DistributedBlockOutputStream::writeToLocal(const Block & block, const size_
InterpreterInsertQuery interp(query_ast, context); InterpreterInsertQuery interp(query_ast, context);
auto block_io = interp.execute(); auto block_io = interp.execute();
assertBlocksHaveEqualStructure(block_io.out->getHeader(), block, "flushing " + storage.getStorageID().getNameForLogs());
block_io.out->writePrefix(); block_io.out->writePrefix();
for (size_t i = 0; i < repeats; ++i) for (size_t i = 0; i < repeats; ++i)

View File

@ -0,0 +1,9 @@
DROP TABLE IF EXISTS dist_00967;
DROP TABLE IF EXISTS underlying_00967;
CREATE TABLE dist_00967 (key UInt64) Engine=Distributed('test_shard_localhost', currentDatabase(), underlying_00967);
-- fails for TinyLog()/MergeTree()/... but not for Memory()
CREATE TABLE underlying_00967 (key Nullable(UInt64)) Engine=TinyLog();
INSERT INTO dist_00967 SELECT toUInt64(number) FROM system.numbers LIMIT 1; -- { serverError 171; }
SELECT * FROM dist_00967;