Merge pull request #10105 from azat/distributed-insert-types-differs

Fix SIGSEGV on INSERT into Distributed on different struct with underlying
This commit is contained in:
alexey-milovidov 2020-04-08 05:36:02 +03:00 committed by GitHub
commit dad892e9d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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;