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 EA0E6221F0 for ; Mon, 24 Dec 2018 09:01:56 -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 Voil2PxN9dLf for ; Mon, 24 Dec 2018 09:01:56 -0500 (EST) Received: from smtp1.mail.ru (smtp1.mail.ru [94.100.179.111]) (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 AABAC221D4 for ; Mon, 24 Dec 2018 09:01:56 -0500 (EST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.0 \(3445.100.39\)) Subject: [tarantool-patches] Re: [PATCH v2 4/6] sql: fix "PRAGMA case_sensitive_like" result From: "n.pettik" In-Reply-To: Date: Mon, 24 Dec 2018 16:01:54 +0200 Content-Transfer-Encoding: quoted-printable Message-Id: <23926231-FF7A-4562-A8BA-A3E96E422CAA@tarantool.org> References: 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 > diff --git a/src/box/sql/pragma.c b/src/box/sql/pragma.c > index f34e7b8..9390f6f 100644 > --- a/src/box/sql/pragma.c > +++ b/src/box/sql/pragma.c > @@ -591,13 +591,20 @@ sqlite3Pragma(Parse * pParse, Token * pId, = /* First part of [schema.]id field */ > * depending on the RHS. > */ > case PragTyp_CASE_SENSITIVE_LIKE:{ > - if (zRight) { > - int is_like_ci =3D > - !(sqlite3GetBoolean(zRight, 0)); > - sqlite3RegisterLikeFunctions(db, = is_like_ci); > - } > - break; > + int mask =3D pPragma->iArg; > + if (zRight =3D=3D NULL) { > + returnSingleInt(v, > + (user_session->sql_flags & mask) = !=3D 0); > + } else { > + int is_like_ci =3D !(sqlite3GetBoolean(zRight, = 0)); > + if (!is_like_ci) > + user_session->sql_flags |=3D mask; > + else > + user_session->sql_flags &=3D ~mask; > + sqlite3RegisterLikeFunctions(db, is_like_ci); > } Nit: since pragma is called =E2=80=98case_sensitive_like=E2=80=99, I = would revert variable meaning: +++ b/src/box/sql/pragma.c @@ -602,12 +602,12 @@ sqlite3Pragma(Parse * pParse, Token * pId, = /* First part of [schema.]id field */ returnSingleInt(v, (user_session->sql_flags & mask) = !=3D 0); } else { - int is_like_ci =3D !(sqlite3GetBoolean(zRight, = 0)); - if (!is_like_ci) + bool is_like_cs =3D sqlite3GetBoolean(zRight, = 0); + if (is_like_cs) user_session->sql_flags |=3D mask; else user_session->sql_flags &=3D ~mask; - sqlite3RegisterLikeFunctions(db, is_like_ci); + sqlite3RegisterLikeFunctions(db, ! is_like_cs); Also, the same question here: why you didn=E2=80=99t make it be of type =E2=80=98flag=E2=80=99? The only difference in additional call of = sqlite3RegisterLikeFunctions. > + break; > + } >=20 > case PragTyp_DEFAULT_ENGINE: { > if (zRight =3D=3D NULL) { > diff --git a/src/box/sql/pragma.h b/src/box/sql/pragma.h > index 59e0e1e..11a2e05 100644 > --- a/src/box/sql/pragma.h > +++ b/src/box/sql/pragma.h > @@ -94,9 +94,9 @@ static const PragmaName aPragmaName[] =3D { > /* iArg: */ 0}, > { /* zName: */ "case_sensitive_like", > /* ePragTyp: */ PragTyp_CASE_SENSITIVE_LIKE, > - /* ePragFlg: */ PragFlg_NoColumns, > + /* ePragFlg: */ PragFlg_Result0 | PragFlg_NoColumns1, > /* ColNames: */ 0, 0, > - /* iArg: */ 0}, > + /* iArg: */ SQLITE_LikeIsCaseSens}, Lets avoid using =E2=80=99sqlite=E2=80=99 prefixes for added code.