From 6fe4640e0b185bbf17dab241da85cbf82f614355 Mon Sep 17 00:00:00 2001 From: chertus Date: Wed, 26 Jun 2019 15:59:25 +0300 Subject: [PATCH] fix ColumnConst.isColumnNullable() and related crash --- dbms/src/Columns/ColumnConst.h | 1 + .../0_stateless/00957_coalesce_const_nullable_crash.reference | 4 ++++ .../0_stateless/00957_coalesce_const_nullable_crash.sql | 4 ++++ 3 files changed, 9 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.reference create mode 100644 dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.sql diff --git a/dbms/src/Columns/ColumnConst.h b/dbms/src/Columns/ColumnConst.h index 05a9562e549..8e95fbdc607 100644 --- a/dbms/src/Columns/ColumnConst.h +++ b/dbms/src/Columns/ColumnConst.h @@ -199,6 +199,7 @@ public: bool onlyNull() const override { return data->isNullAt(0); } bool isColumnConst() const override { return true; } + bool isColumnNullable() const override { return data->isColumnNullable(); } bool isNumeric() const override { return data->isNumeric(); } bool isFixedAndContiguous() const override { return data->isFixedAndContiguous(); } bool valuesHaveFixedSize() const override { return data->valuesHaveFixedSize(); } diff --git a/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.reference b/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.reference new file mode 100644 index 00000000000..437b07c062c --- /dev/null +++ b/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.reference @@ -0,0 +1,4 @@ +1 Nullable(UInt8) +2 Nullable(UInt8) +1 Nullable(UInt8) +\N Nullable(Nothing) diff --git a/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.sql b/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.sql new file mode 100644 index 00000000000..e13b69e6f7a --- /dev/null +++ b/dbms/tests/queries/0_stateless/00957_coalesce_const_nullable_crash.sql @@ -0,0 +1,4 @@ +SELECT coalesce(toNullable(1), toNullable(2)) as x, toTypeName(x); +SELECT coalesce(NULL, toNullable(2)) as x, toTypeName(x); +SELECT coalesce(toNullable(1), NULL) as x, toTypeName(x); +SELECT coalesce(NULL, NULL) as x, toTypeName(x);