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 C576129F39 for ; Tue, 16 Apr 2019 10:12:58 -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 WPXX9_cjlxAx for ; Tue, 16 Apr 2019 10:12:58 -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 7F19C25313 for ; Tue, 16 Apr 2019 10:12:58 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 6/9] sql: make comparison predicate return boolean References: <68c506297763a91d8caaccfddd54a696331c000a.1555252410.git.korablev@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Tue, 16 Apr 2019 17:12:55 +0300 MIME-Version: 1.0 In-Reply-To: <68c506297763a91d8caaccfddd54a696331c000a.1555252410.git.korablev@tarantool.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit 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, Nikita Pettik Cc: kostja@tarantool.org Thanks for the patch! See 3 comments below. On 14/04/2019 18:04, Nikita Pettik wrote: > According to ANSI SQL result of comparison predicates must be BOOLEAN. > Before introduction of BOOLEAN type they returned 0 and 1. Now we can > change those values to false and true respectively. > > Part of #3723 > --- > src/box/sql/expr.c | 1 + > src/box/sql/vdbe.c | 4 ++-- > test/sql-tap/aggnested.test.lua | 10 +++++----- > test/sql-tap/identifier_case.test.lua | 10 +++++----- > test/sql-tap/tkt3346.test.lua | 2 +- > test/sql/types.result | 20 ++++++++++---------- > 6 files changed, 24 insertions(+), 23 deletions(-) > > 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==OP_Eq)==res2) break; > } > memAboutToChange(p, pOut); > - MemSetTypeFlag(pOut, MEM_Int); > - pOut->u.i = res2; > + MemSetTypeFlag(pOut, MEM_Bool); > + pOut->u.b = res2; 1. Please, update the comments about SQL_STOREP2 and SQL_KEEPNULL. They still say the result is stored as int 1/0. > REGISTER_TRACE(pOp->p2, pOut); > } else { > VdbeBranchTaken(res!=0, (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 > + "" 2. Why? There 'sum' was selected. It can not return text. > -- > }) > > @@ -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=value1) FROM t2), max(value1) > + SELECT (SELECT sum(value1) FROM t2 where value1=value2), max(value1) > FROM t1 > GROUP BY id1; > ]], > { > -- > - 0, 2 > + "", 2 3. The same. > -- > }) >