Add type conversion for StorageJoin (previously led to SIGSEGV)

Found with fuzzer under UBsan [1]:

  [1]: https://clickhouse-test-reports.s3.yandex.net/21579/61d40c3600ba6a1c6d6c0cf4919a3cdaebb3a31f/fuzzer_ubsan/report.html#fail1
This commit is contained in:
Azat Khuzhin 2021-03-11 22:35:49 +03:00
parent b30a0c68da
commit c2372420ee
3 changed files with 16 additions and 0 deletions

View File

@ -854,6 +854,13 @@ JoinPtr SelectQueryExpressionAnalyzer::makeTableJoin(
return join;
}
}
else
{
const ColumnsWithTypeAndName & right_sample_columns = subquery_for_join.sample_block.getColumnsWithTypeAndName();
bool need_convert = syntax->analyzed_join->applyJoinKeyConvert(left_sample_columns, right_sample_columns);
if (need_convert)
subquery_for_join.addJoinActions(std::make_shared<ExpressionActions>(syntax->analyzed_join->rightConvertingActions()));
}
return subquery_for_join.join;
}

View File

@ -2,3 +2,4 @@
2 22 92 82 123457
1 11 91 81 123456
2 22 92 82 123457
11 1 91 81 123456

View File

@ -36,5 +36,13 @@ from (
) js1
SEMI LEFT JOIN joinbug_join using id2;
/* type conversion */
SELECT * FROM
(
SELECT toUInt32(11) AS id2
) AS js1
SEMI LEFT JOIN joinbug_join USING (id2);
DROP TABLE joinbug;
DROP TABLE joinbug_join;