From fb8e37f60f218ad9e09c362de02b8a44466a4cb2 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Wed, 6 Mar 2019 02:37:41 +0300 Subject: [PATCH] Fix segfault in function "replicate" --- dbms/src/Functions/replicate.cpp | 2 +- dbms/tests/queries/0_stateless/00914_replicate.reference | 1 + dbms/tests/queries/0_stateless/00914_replicate.sql | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 dbms/tests/queries/0_stateless/00914_replicate.reference create mode 100644 dbms/tests/queries/0_stateless/00914_replicate.sql diff --git a/dbms/src/Functions/replicate.cpp b/dbms/src/Functions/replicate.cpp index 756b745ccde..054106cfd5a 100644 --- a/dbms/src/Functions/replicate.cpp +++ b/dbms/src/Functions/replicate.cpp @@ -54,7 +54,7 @@ public: array_column = checkAndGetColumn(temp_column.get()); } block.getByPosition(result).column - = ColumnArray::create(first_column->replicate(array_column->getOffsets()), array_column->getOffsetsPtr()); + = ColumnArray::create(first_column->replicate(array_column->getOffsets())->convertToFullColumnIfConst(), array_column->getOffsetsPtr()); } }; diff --git a/dbms/tests/queries/0_stateless/00914_replicate.reference b/dbms/tests/queries/0_stateless/00914_replicate.reference new file mode 100644 index 00000000000..8932f7fcd7b --- /dev/null +++ b/dbms/tests/queries/0_stateless/00914_replicate.reference @@ -0,0 +1 @@ +[[\'a\']] diff --git a/dbms/tests/queries/0_stateless/00914_replicate.sql b/dbms/tests/queries/0_stateless/00914_replicate.sql new file mode 100644 index 00000000000..4147df0ad45 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00914_replicate.sql @@ -0,0 +1 @@ +SELECT CAST(replicate(['a'], [1]) AS String);