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 DA9812715C for ; Wed, 20 Feb 2019 10:47:03 -0500 (EST) 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 9OdWF7ACHFXK for ; Wed, 20 Feb 2019 10:47:03 -0500 (EST) Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (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 96AED21227 for ; Wed, 20 Feb 2019 10:47:03 -0500 (EST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [tarantool-patches] Re: [PATCH] sql: LIKE/LENGTH process '\0' From: "i.koptelov" In-Reply-To: <25649276-74CD-46E7-A1EB-F4CE299E637C@tarantool.org> Date: Wed, 20 Feb 2019 18:47:01 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <427EE913-3E58-413F-A645-DBF83C809334@tarantool.org> References: <15e143f4-3ea7-c7d6-d8ac-8a0e20b76449@tarantool.org> <1560FF96-FECD-4368-8AF8-F8F2AE7696E3@tarantool.org> <07DBA796-6DD4-41DD-8438-104FE3AE05BB@tarantool.org> <4F4E0A7E-199C-4647-A49C-DD0E8A216527@tarantool.org> <8EF5CE57-C6B5-493C-94CC-AA3C88639485@tarantool.org> <7E6CE8AA-512D-4472-9DBD-8159073386C5@tarantool.org> <25649276-74CD-46E7-A1EB-F4CE299E637C@tarantool.org> 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: "n.pettik" Thanks to Alexander, I fixed my patch to use a function from icu to count the length of the string. Changes: diff --git a/src/box/sql/func.c b/src/box/sql/func.c index 233ea2901..8ddb9780f 100644 --- a/src/box/sql/func.c +++ b/src/box/sql/func.c @@ -149,16 +149,7 @@ utf8_char_count(const unsigned char *str, int = byte_len) { int symbol_count =3D 0; for (int i =3D 0; i < byte_len;) { - if ((str[i] & 0x80) =3D=3D 0) - i +=3D 1; - else if ((str[i] & 0xe0) =3D=3D 0xc0) - i +=3D 2; - else if ((str[i] & 0xf0) =3D=3D 0xe0) - i +=3D 3; - else if ((str[i] & 0xf8) =3D=3D 0xf0) - i +=3D 4; - else - i +=3D 1; + U8_FWD_1_UNSAFE(str, i); symbol_count++; } return symbol_count; diff --git a/test/sql-tap/badutf1.test.lua = b/test/sql-tap/badutf1.test.lua index 67c1071b3..d104efaa9 100755 --- a/test/sql-tap/badutf1.test.lua +++ b/test/sql-tap/badutf1.test.lua @@ -255,7 +255,7 @@ test:do_test( return test:execsql2("SELECT = length('\x61\xc0\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80') AS x") end, { -- - "X", 11 + "X", 12 -- }) =20 @@ -265,7 +265,7 @@ test:do_test( return test:execsql2("SELECT = length('\xc0\x80\x80\x80\x80\x80\x80\x80\x80\x80\x80') AS x") end, { -- - "X", 10 + "X", 11 -- }) =20=