Merge pull request #9106 from CurtizJ/fix-range-reader

Fix segfault in MergeTreeRangeReader
This commit is contained in:
Anton Popov 2020-02-14 17:59:43 +03:00 committed by GitHub
commit 1162c22063
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -333,8 +333,8 @@ void MergeTreeRangeReader::ReadResult::optimize()
filter_holder_original = std::move(filter_holder);
filter = new_filter.get();
filter_holder = std::move(new_filter);
need_filter = true;
}
need_filter = true;
}
/// Another guess, if it's worth filtering at PREWHERE
else if (countBytesInResultFilter(filter->getData()) < 0.6 * filter->size())

View File

@ -0,0 +1,11 @@
drop table if exists t;
create table t (a Int) engine = MergeTree order by a;
-- some magic to satisfy conditions to run optimizations in MergeTreeRangeReader
insert into t select number < 20 ? 0 : 1 from numbers(50);
alter table t add column s String default 'foo';
select s from t prewhere a != 1 where rand() % 2 = 0 limit 1;
drop table t;