From 83503df56a3a590cfe6a814b42049552293e336e Mon Sep 17 00:00:00 2001 From: chertus Date: Fri, 1 Mar 2019 18:32:32 +0300 Subject: [PATCH] fix crach on JOIN with array or tuple --- dbms/src/Interpreters/Join.cpp | 2 +- .../0_stateless/00846_join_using_tuple_crash.reference | 2 ++ .../queries/0_stateless/00846_join_using_tuple_crash.sql | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.reference create mode 100644 dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql diff --git a/dbms/src/Interpreters/Join.cpp b/dbms/src/Interpreters/Join.cpp index e1a30c5778d..59c0c874a72 100644 --- a/dbms/src/Interpreters/Join.cpp +++ b/dbms/src/Interpreters/Join.cpp @@ -300,7 +300,7 @@ void Join::setSampleBlock(const Block & block) if (column.get() != column_no_lc.get()) { materialized_columns.emplace_back(std::move(column_no_lc)); - key_columns[i] = materialized_columns[i].get(); + key_columns[i] = materialized_columns.back().get(); } /// We will join only keys, where all components are not NULL. diff --git a/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.reference b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.reference new file mode 100644 index 00000000000..52f99690ff2 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.reference @@ -0,0 +1,2 @@ +0 (0,0) +0 (0,0) diff --git a/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql new file mode 100644 index 00000000000..3409e67cbfe --- /dev/null +++ b/dbms/tests/queries/0_stateless/00846_join_using_tuple_crash.sql @@ -0,0 +1,7 @@ +SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +USING (a, tup); + +SELECT * FROM (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +GLOBAL ANY FULL OUTER JOIN (SELECT dummy as a, (toUInt8(0), toUInt8(0)) AS tup FROM system.one) +USING (a, tup);