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 69C2E2A28A for ; Tue, 16 Apr 2019 10:12:45 -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 wniAK1OU6-aE for ; Tue, 16 Apr 2019 10:12:45 -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 0CCF629F39 for ; Tue, 16 Apr 2019 10:12:45 -0400 (EDT) Subject: [tarantool-patches] Re: [PATCH 9/9] sql: make accept only boolean References: <103cef3d31c59d1b869a7675a01ed2e6279a47ef.1555252410.git.korablev@tarantool.org> From: Vladislav Shpilevoy Message-ID: Date: Tue, 16 Apr 2019 17:12:41 +0300 MIME-Version: 1.0 In-Reply-To: <103cef3d31c59d1b869a7675a01ed2e6279a47ef.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: Nikita Pettik , tarantool-patches@freelists.org Cc: kostja@tarantool.org Thanks for the patch! See 4 comments below. On 14/04/2019 18:04, Nikita Pettik wrote: > is a predicate used as a part of WHERE and > JOIN clauses. ANSI SQL states that must > accept only boolean arguments. In our SQL it is implemented as > bytecode instruction OP_If which in turn carries out logic of > conditional jump. Since it can be involved in executing other routines > different from , 1. Which other routines? What is a valid case of OP_If with non-boolean value in check? > we pass to it additional argument > when generating bytecode for WHERE and JOIN clauses. When VDBE performs > OP_If and detects such flag, it checks passed argument to be boolean. > > Closes #3723 2. In addition, it fixes https://github.com/tarantool/tarantool/issues/3651, doesn't it? > diff --git a/test/sql-tap/e_delete.test.lua b/test/sql-tap/e_delete.test.lua > index a58dc87c7..374a7d3e4 100755 > --- a/test/sql-tap/e_delete.test.lua > +++ b/test/sql-tap/e_delete.test.lua > @@ -89,15 +89,15 @@ test:do_delete_tests("e_delete-1.1", { > -- NULL are retained. > -- > test:do_delete_tests("e_delete-1.2", { > - {1, "DELETE FROM t3 WHERE 1 ; SELECT x FROM t3", {}}, > - {2, "DELETE FROM t4 WHERE 0 ; SELECT x FROM t4", {1, 2, 3, 4, 5}}, > - {3, "DELETE FROM t4 WHERE 0.0 ; SELECT x FROM t4", {1, 2, 3, 4, 5}}, > + {1, "DELETE FROM t3 WHERE true ; SELECT x FROM t3", {}}, > + {2, "DELETE FROM t4 WHERE false ; SELECT x FROM t4", {1, 2, 3, 4, 5}}, > + {3, "DELETE FROM t4 WHERE false ; SELECT x FROM t4", {1, 2, 3, 4, 5}}, 3. The last two lines are exactly the same. Why not to drop one? > {4, "DELETE FROM t4 WHERE NULL ; SELECT x FROM t4", {1, 2, 3, 4, 5}}, > {5, "DELETE FROM t4 WHERE y!='two'; SELECT x FROM t4", {2}}, > {6, "DELETE FROM t4 WHERE y='two' ; SELECT x FROM t4", {}}, > {7, "DELETE FROM t5 WHERE x=(SELECT max(x) FROM t5);SELECT x FROM t5", {1, 2, 3, 4}}, > {8, "DELETE FROM t5 WHERE (SELECT max(x) FROM t4) ;SELECT x FROM t5", {1, 2, 3, 4}}, > - {9, "DELETE FROM t5 WHERE (SELECT max(x) FROM t6) ;SELECT x FROM t5", {}}, > + {9, "DELETE FROM t5 WHERE (SELECT max(x) FROM t6) != 0 ;SELECT x FROM t5", {}}, > {10, "DELETE FROM t6 WHERE y>'seven' ; SELECT y FROM t6", {"one", "four", "five"}}, > }) > > diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua > index 970eeeed9..e47b0f43d 100755 > --- a/test/sql-tap/e_select1.test.lua > +++ b/test/sql-tap/e_select1.test.lua > @@ -448,15 +448,15 @@ test:do_select_tests( > -- true are included from the dataset. > -- > local data ={ > - {"1"," SELECT * FROM t1 JOIN_PATTERN t2 ON (1) ",t1_cross_t2}, > - {"2"," SELECT * FROM t1 JOIN_PATTERN t2 ON (0) ",{}}, > + {"1"," SELECT * FROM t1 JOIN_PATTERN t2 ON (true) ",t1_cross_t2}, > + {"2"," SELECT * FROM t1 JOIN_PATTERN t2 ON (false) ",{}}, > {"3"," SELECT * FROM t1 JOIN_PATTERN t2 ON (NULL) ",{}}, > - {"6"," SELECT * FROM t1 JOIN_PATTERN t2 ON (0.9) ",t1_cross_t2}, > - {"7"," SELECT * FROM t1 JOIN_PATTERN t2 ON ('0.9') ",t1_cross_t2}, > - {"8"," SELECT * FROM t1 JOIN_PATTERN t2 ON (0.0) ",{}}, > + {"6"," SELECT * FROM t1 JOIN_PATTERN t2 ON (true) ",t1_cross_t2}, > + {"7"," SELECT * FROM t1 JOIN_PATTERN t2 ON (true) ",t1_cross_t2}, > + {"8"," SELECT * FROM t1 JOIN_PATTERN t2 ON (true) ",t1_cross_t2}, 4. The same. 3 duplicates.