From afcd6f9f093677ae2f73294885862877e5de2e49 Mon Sep 17 00:00:00 2001 From: Ivan Blinkov Date: Thu, 6 Dec 2018 17:30:10 +0300 Subject: [PATCH] Make substring function name case-insensitive + add two aliases #3704 --- dbms/src/Functions/substring.cpp | 4 +++- .../0_stateless/00765_sql_compatibility_aliases.reference | 3 +++ .../queries/0_stateless/00765_sql_compatibility_aliases.sql | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dbms/src/Functions/substring.cpp b/dbms/src/Functions/substring.cpp index e0a6d707243..7263f3ec595 100644 --- a/dbms/src/Functions/substring.cpp +++ b/dbms/src/Functions/substring.cpp @@ -166,7 +166,9 @@ public: void registerFunctionSubstring(FunctionFactory & factory) { - factory.registerFunction(); + factory.registerFunction(FunctionFactory::CaseInsensitive); + factory.registerAlias("substr", FunctionSubstring::name, FunctionFactory::CaseInsensitive); + factory.registerAlias("mid", FunctionSubstring::name, FunctionFactory::CaseInsensitive); /// from MySQL dialect } } diff --git a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference index 439957db622..152c2182d69 100644 --- a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference +++ b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.reference @@ -4,3 +4,6 @@ foo FOO baz 2 +fo +oo +o diff --git a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql index 791231b9598..85b33efa485 100644 --- a/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql +++ b/dbms/tests/queries/0_stateless/00765_sql_compatibility_aliases.sql @@ -6,3 +6,6 @@ select LOWER('Foo'); select UPPER('Foo'); select REPLACE('bar', 'r', 'z'); select Locate('foo', 'o'); +select SUBSTRING('foo', 1, 2); +select Substr('foo', 2); +select mid('foo', 3);