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 482E32B095 for ; Thu, 18 Apr 2019 13:54:59 -0400 (EDT) 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 kTPuphhtnvBV for ; Thu, 18 Apr 2019 13:54:59 -0400 (EDT) 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 049582A798 for ; Thu, 18 Apr 2019 13:54:59 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH 6/9] sql: make comparison predicate return boolean From: "n.pettik" In-Reply-To: Date: Thu, 18 Apr 2019 20:54:57 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: References: <68c506297763a91d8caaccfddd54a696331c000a.1555252410.git.korablev@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: Vladislav Shpilevoy > On 16 Apr 2019, at 17:12, Vladislav Shpilevoy = wrote: >=20 > Thanks for the patch! See 3 comments below. >=20 > On 14/04/2019 18:04, Nikita Pettik wrote: >>=20 >> diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c >> index 10794b18e..43d4262e5 100644 >> --- a/src/box/sql/vdbe.c >> +++ b/src/box/sql/vdbe.c >> @@ -2273,8 +2273,8 @@ case OP_Ge: { /* same as TK_GE, = jump, in1, in3 */ >> if ((pOp->opcode=3D=3DOP_Eq)=3D=3Dres2) break; >> } >> memAboutToChange(p, pOut); >> - MemSetTypeFlag(pOut, MEM_Int); >> - pOut->u.i =3D res2; >> + MemSetTypeFlag(pOut, MEM_Bool); >> + pOut->u.b =3D res2; >=20 > 1. Please, update the comments about SQL_STOREP2 and SQL_KEEPNULL. > They still say the result is stored as int 1/0. Do you mean these comments (?) : diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 43d4262e5..b28e9b4ea 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -2061,8 +2061,8 @@ case OP_Cast: { /* in1 */ * registers P1 and P3. * * If both SQL_STOREP2 and SQL_KEEPNULL flags are set then the - * content of r[P2] is only changed if the new value is NULL or 0 = (false). - * In other words, a prior r[P2] value will not be overwritten by 1 = (true). + * content of r[P2] is only changed if the new value is NULL or false. + * In other words, a prior r[P2] value will not be overwritten by true. */ /* Opcode: Ne P1 P2 P3 P4 P5 * Synopsis: IF r[P3]!=3Dr[P1] @@ -2072,15 +2072,15 @@ case OP_Cast: { /* in1 */ * additional information. * * If both SQL_STOREP2 and SQL_KEEPNULL flags are set then the - * content of r[P2] is only changed if the new value is NULL or 1 = (true). - * In other words, a prior r[P2] value will not be overwritten by 0 = (false). + * content of r[P2] is only changed if the new value is NULL or true. + * In other words, a prior r[P2] value will not be overwritten by = false. */ /* Opcode: Lt P1 P2 P3 P4 P5 * Synopsis: IF r[P3]=20 >> REGISTER_TRACE(pOp->p2, pOut); >> } else { >> VdbeBranchTaken(res!=3D0, (pOp->p5 & SQL_NULLEQ)?2:3); >> diff --git a/test/sql-tap/aggnested.test.lua = b/test/sql-tap/aggnested.test.lua >> index 656576b70..67a9ba891 100755 >> --- a/test/sql-tap/aggnested.test.lua >> +++ b/test/sql-tap/aggnested.test.lua >> @@ -215,7 +215,7 @@ test:do_execsql_test("aggnested-3.2-2", >> ]], >> { >> -- >> - 0 >> + "" >=20 > 2. Why? There 'sum' was selected. It can not return text. I guess because nulls are converted this way in execsql function. SUM() now is not called at all (in previous test version it was called with 0 as arg), so query returns NULL. >> @@ -227,13 +227,13 @@ test:do_execsql_test("aggnested-3.3", >> INSERT INTO t1 VALUES(4469,2),(4469,1); >> CREATE TABLE t2 (value2 INT PRIMARY KEY); >> INSERT INTO t2 VALUES(1); >> - SELECT (SELECT sum(value2=3Dvalue1) FROM t2), max(value1) >> + SELECT (SELECT sum(value1) FROM t2 where value1=3Dvalue2), = max(value1) >> FROM t1 >> GROUP BY id1; >> ]], >> { >> -- >> - 0, 2 >> + "", 2 >=20 > 3. The same. >=20 >> -- >> }) >>=20