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 80CF42B65A for ; Thu, 18 Apr 2019 13:55:49 -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 09W7bPm2tw3p for ; Thu, 18 Apr 2019 13:55:49 -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 3EADF249D5 for ; Thu, 18 Apr 2019 13:55:49 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: [tarantool-patches] Re: [PATCH 9/9] sql: make accept only boolean From: "n.pettik" In-Reply-To: Date: Thu, 18 Apr 2019 20:55:46 +0300 Content-Transfer-Encoding: quoted-printable Message-Id: <6DC565F1-23AA-49CA-BB2C-AA60EE9E3593@tarantool.org> References: <103cef3d31c59d1b869a7675a01ed2e6279a47ef.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 >> 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 ,=20 >=20 > 1. Which other routines? What is a valid case of OP_If with = non-boolean > value in check? For instance, to verify that register containing LIMIT value is > 0. It is quite hard to track values which come to this opcode, so we can=E2=80=99t be sure that it always accepts booleans. >> 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. >>=20 >> Closes #3723 >=20 > 2. In addition, it fixes = https://github.com/tarantool/tarantool/issues/3651, > doesn't it? It does, added label. >> 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}}, >=20 > 3. The last two lines are exactly the same. Why not to drop one? Ok, dropped. >> {4, "DELETE FROM t4 WHERE NULL ; SELECT x FROM t4", {1, 2, 3, = 4, 5}}, >> {5, "DELETE FROM t4 WHERE y!=3D'two'; SELECT x FROM t4", {2}}, >> {6, "DELETE FROM t4 WHERE y=3D'two' ; SELECT x FROM t4", {}}, >> {7, "DELETE FROM t5 WHERE x=3D(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) !=3D 0 = ;SELECT x FROM t5", {}}, >> {10, "DELETE FROM t6 WHERE y>'seven' ; SELECT y FROM t6", {"one", = "four", "five"}}, >> }) >>=20 >> 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 =3D{ >> - {"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}, >=20 > 4. The same. 3 duplicates. Removed duplicates.