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 7CFEE25C74 for ; Tue, 29 Jan 2019 11:36:00 -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 4eqjSzGAImVg for ; Tue, 29 Jan 2019 11:36:00 -0500 (EST) Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 D5C0925C13 for ; Tue, 29 Jan 2019 11:35:59 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.2 \(3445.102.3\)) Subject: [tarantool-patches] Re: [PATCH] sql: LIKE/LENGTH process '\0' From: "n.pettik" In-Reply-To: <15e143f4-3ea7-c7d6-d8ac-8a0e20b76449@tarantool.org> Date: Tue, 29 Jan 2019 19:35:57 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <1560FF96-FECD-4368-8AF8-F8F2AE7696E3@tarantool.org> References: <15e143f4-3ea7-c7d6-d8ac-8a0e20b76449@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: Ivan Koptelov > Fixes LIKE and LENGTH functions. '\0' now treated as Nit: is treated. > a usual symbol. Strings with '\0' are now processed > entirely. Consider examples: >=20 > LENGTH(CHAR(65,00,65)) =3D=3D 3 > LIKE(CHAR(65,00,65), CHAR(65,00,66)) =3D=3D False Also, I see that smth wrong with text in this mail again. >=20 > Closes #3542 Please, check other functions working with strings. For instance, now I see that replace ignores \0 as well: tarantool> box.sql.execute("select replace(CHAR(65,00,66), char(0), = char(1))") --- - - ["A\0B"] ... > @@ -150,9 +150,13 @@ lengthFunc(sqlite3_context * context, int argc, = sqlite3_value ** argv) > const unsigned char *z =3D = sqlite3_value_text(argv[0]); > if (z =3D=3D 0) > return; > + Nit: don=E2=80=99t abuse empty lines. > len =3D 0; > - while (*z) { > + size_t byte_len =3D = sqlite3_value_bytes(argv[0]); > + const unsigned char *prev_z; > + for (size_t cnt =3D 0; cnt < byte_len; cnt +=3D = (z - prev_z)) { Out of 80. > diff --git a/test/sql-tap/gh-3542-like-len-null-term.test.lua = b/test/sql-tap/gh-3542-like-len-null-term.test.lua > new file mode 100755 > index 000000000..e9ea9ea30 > --- /dev/null > +++ b/test/sql-tap/gh-3542-like-len-null-term.test.lua > @@ -0,0 +1,97 @@ > +#!/usr/bin/env tarantool > +test =3D require("sqltester") > +test:plan(14) > + > +-- gh-3542 - LIKE/LENGTH do not scan if '\0' is encountered. > +-- This test ensures that LIKE and LENGTH functions does NOT stop > +-- string processing if '\0' is encountered. I=E2=80=99d rather put these tests to sql-tap/func.test.lua