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

n.pettik korablev at tarantool.org
Thu Jun 6 21:55:31 MSK 2019



> On 29 May 2019, at 20:57, Mergen Imeev <imeevma at tarantool.org> wrote:
> 
> Hi! Thank you for review! My answers and new version below.
> 
> On Tue, May 21, 2019 at 03:58:55PM +0300, n.pettik wrote:
>> 
>> 
>>> 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?
> Since this issue is not of primary importance, after some
> discussion it was decided that it would be too troublesome to
> create these functions with the support of “[USING CHARACTERS]”.
> 
>> What then is the difference between length() and char_length()?
>> 
> I think the most noticeable difference is that the CHAR_LENGTH and
> CHARACTER_LENGTH functions are described in ANSI, but LENGTH is
> not.

So the name is the only difference? Why don’t you use lengthFunc then
as an implementation? I guess the main purpose of the ticket not to add
just another one synonym, but follow ANSI syntax of function invocation
including USING clause.

>>> 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.
>> 
> Sorry, I could not understand what it means. Do you mean
> something like this (not exactly invalid characters, but
> still):
> tarantool> box.execute("SELECT CHAR_LENGTH('\u{12345}');")
> ---
> - metadata:
>  - name: !!binary Q0hBUl9MRU5HVEgoJ/CSjYUnKQ==
>    type: integer
>  rows:
>  - [1]
> ...
> 
> I'm not sure if this should be added.
> I added a test with utf8 characters.

See sql-tap/badutf1.test.lua





More information about the Tarantool-patches mailing list