From 69d4120982fa2b7cae35da83532c8318f44bfc8f Mon Sep 17 00:00:00 2001 From: Amos Bird Date: Fri, 12 Feb 2021 10:22:18 +0800 Subject: [PATCH] Disable table function view in expression --- src/Parsers/ASTFunction.cpp | 8 ++++++++ .../0_stateless/01715_table_function_view_fix.reference | 0 .../queries/0_stateless/01715_table_function_view_fix.sql | 1 + 3 files changed, 9 insertions(+) create mode 100644 tests/queries/0_stateless/01715_table_function_view_fix.reference create mode 100644 tests/queries/0_stateless/01715_table_function_view_fix.sql diff --git a/src/Parsers/ASTFunction.cpp b/src/Parsers/ASTFunction.cpp index 806b8e6c5b9..29ac01eefc5 100644 --- a/src/Parsers/ASTFunction.cpp +++ b/src/Parsers/ASTFunction.cpp @@ -15,8 +15,16 @@ namespace DB { +namespace ErrorCodes +{ + extern const int UNEXPECTED_EXPRESSION; +} + void ASTFunction::appendColumnNameImpl(WriteBuffer & ostr) const { + if (name == "view") + throw Exception("Table function view cannot be used as an expression", ErrorCodes::UNEXPECTED_EXPRESSION); + writeString(name, ostr); if (parameters) diff --git a/tests/queries/0_stateless/01715_table_function_view_fix.reference b/tests/queries/0_stateless/01715_table_function_view_fix.reference new file mode 100644 index 00000000000..e69de29bb2d diff --git a/tests/queries/0_stateless/01715_table_function_view_fix.sql b/tests/queries/0_stateless/01715_table_function_view_fix.sql new file mode 100644 index 00000000000..21da116f6ba --- /dev/null +++ b/tests/queries/0_stateless/01715_table_function_view_fix.sql @@ -0,0 +1 @@ +SELECT view(SELECT 1); -- { serverError 183 }