From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from localhost (localhost [127.0.0.1]) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTP id EEC0F2EFE7 for ; Tue, 21 May 2019 08:58:58 -0400 (EDT) Received: from turing.freelists.org ([127.0.0.1]) by localhost (turing.freelists.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ZCQyf-bw6-X5 for ; Tue, 21 May 2019 08:58:58 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by turing.freelists.org (Avenir Technologies Mail Multiplex) with ESMTPS id 38DB12EFAA for ; Tue, 21 May 2019 08:58:57 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: create CHAR_LENGTH() and CHARACTER_LENGTH() From: "n.pettik" In-Reply-To: <7b8049e47b931a2014b92e26436dc264d56231c9.1557321237.git.imeevma@gmail.com> Date: Tue, 21 May 2019 15:58:55 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <78A05ED7-1BE9-4DF6-A96C-AD763D7CC969@tarantool.org> References: <7b8049e47b931a2014b92e26436dc264d56231c9.1557321237.git.imeevma@gmail.com> Sender: tarantool-patches-bounce@freelists.org Errors-to: tarantool-patches-bounce@freelists.org Reply-To: tarantool-patches@freelists.org List-Help: List-Unsubscribe: List-software: Ecartis version 1.0.0 List-Id: tarantool-patches List-Subscribe: List-Owner: List-post: List-Archive: To: tarantool-patches@freelists.org Cc: Imeev Mergen > On 8 May 2019, at 16:15, imeevma@tarantool.org wrote: >=20 > This patch creates SQL functions CHARACTER_LENGTH() and > CHAR_LENGTH(). These functions work the same way. Each of them > takes only one argument of type TEXT and returns its length. I see your message in issue description: =E2=80=9C About this function, it was decided that it would be better to implement it as "{CHAR_LENGTH | CHARACTER_LENGTH} (character value expression)" (without "[USING CHARACTERS]=E2=80=9D) =E2=80=9C Could you please provide explanation of this decision? What then is the difference between length() and char_length()? I see that char_length() in your implementation doesn=E2=80=99t tolerate NULLs. Is it OK? Could you check this fact using ANSI spec? > /* > + * Implementation of the char_length() and character_length() > + * functions. > + */ Nit: diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 01c271cab..b5fdc6f20 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -132,7 +132,7 @@ typeofFunc(sql_context * context, int NotUsed, = sql_value ** argv) sql_result_text(context, z, -1, SQL_STATIC); } =20 -/* +/** * Implementation of the char_length() and character_length() * functions. */ > diff --git a/test/sql-tap/func3.test.lua b/test/sql-tap/func3.test.lua > index 6d6411c..a3a548b 100755 > --- a/test/sql-tap/func3.test.lua > +++ b/test/sql-tap/func3.test.lua > @@ -1,6 +1,6 @@ > #!/usr/bin/env tarantool > test =3D require("sqltester") > -test:plan(25) > +test:plan(37) >=20 > --!./tcltestrunner.lua > -- 2010 August 27 > @@ -284,6 +284,134 @@ test:do_test( > return test:execsql "EXPLAIN SELECT = likely(min(1.0+'2.0',4*11))" > end, test:execsql "EXPLAIN SELECT min(1.0+'2.0',4*11)=E2=80=9D) Add test involving invalid utf8 characters.