[tarantool-patches] Re: [PATCH v1 1/1] sql: create CHAR_LENGTH() and CHARACTER_LENGTH()

n.pettik korablev at tarantool.org
Tue May 21 15:58:55 MSK 2019



> On 8 May 2019, at 16:15, imeevma at tarantool.org wrote:
> 
> 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:

“
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]”)
“

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’t 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);
 }
 
-/*
+/**
  * 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 = require("sqltester")
> -test:plan(25)
> +test:plan(37)
> 
> --!./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)”)

Add test involving invalid utf8 characters.





More information about the Tarantool-patches mailing list