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 616B82728F for ; Fri, 15 Feb 2019 12:14:53 -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 cJawizgC0Lwu for ; Fri, 15 Feb 2019 12:14:53 -0500 (EST) Received: from smtpng1.m.smailru.net (smtpng1.m.smailru.net [94.100.181.251]) (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 C956C285A2 for ; Fri, 15 Feb 2019 12:14:52 -0500 (EST) From: imeevma@tarantool.org Subject: [tarantool-patches] [PATCH v2 1/2] sql: remove field suppressErr from struct sql Date: Fri, 15 Feb 2019 20:14:50 +0300 Message-Id: <9bac4bd5266de1adb9f0c496732408c5d437554a.1550250721.git.imeevma@gmail.com> In-Reply-To: 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: korablev@tarantool.org Cc: tarantool-patches@freelists.org, kostja@tarantool.org The suppressErr field was used to indicate that most of the errors during the parsing should be suppressed. There was only one feature that used it. After deleting this feature, it became obvious that this field had become unused and should be removed. The feature in question is: allow to use names and aliases from input in ORDER BY clause of UNION or INTERSECT. After deleting of this feature, requests like the one below become invalid: SELECT 1 AS a UNION ALL SELECT 2 AS b ORDER BY b; Part of #3965 --- src/box/sql/resolve.c | 6 ---- src/box/sql/sqlInt.h | 1 - src/box/sql/util.c | 12 +++---- test/sql-tap/e_select1.test.lua | 26 +++++++-------- test/sql-tap/select1.test.lua | 4 +-- test/sql-tap/select4.test.lua | 8 ++--- test/sql-tap/selectB.test.lua | 52 +++++++++--------------------- test/sql-tap/tkt2822.test.lua | 70 +---------------------------------------- test/sql-tap/view.test.lua | 18 +---------- test/sql-tap/with1.test.lua | 13 +------- 10 files changed, 39 insertions(+), 171 deletions(-) diff --git a/src/box/sql/resolve.c b/src/box/sql/resolve.c index 3b5e5fc..a1212aa 100644 --- a/src/box/sql/resolve.c +++ b/src/box/sql/resolve.c @@ -866,9 +866,7 @@ resolveOrderByTermToExprList(Parse * pParse, /* Parsing context for error messag int i; /* Loop counter */ ExprList *pEList; /* The columns of the result set */ NameContext nc; /* Name context for resolving pE */ - sql *db; /* Database connection */ int rc; /* Return code from subprocedures */ - u8 savedSuppErr; /* Saved value of db->suppressErr */ assert(sqlExprIsInteger(pE, &i) == 0); pEList = pSelect->pEList; @@ -881,11 +879,7 @@ resolveOrderByTermToExprList(Parse * pParse, /* Parsing context for error messag nc.pEList = pEList; nc.ncFlags = NC_AllowAgg; nc.nErr = 0; - db = pParse->db; - savedSuppErr = db->suppressErr; - db->suppressErr = 1; rc = sqlResolveExprNames(&nc, pE); - db->suppressErr = savedSuppErr; if (rc) return 0; diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index e9a1fd1..f6ac827 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -1514,7 +1514,6 @@ struct sql { u8 mallocFailed; /* True if we have seen a malloc failure */ u8 bBenignMalloc; /* Do not require OOMs if true */ u8 dfltLockMode; /* Default locking-mode for attached dbs */ - u8 suppressErr; /* Do not issue error messages if true */ u8 mTrace; /* zero or more sql_TRACE flags */ u32 magic; /* Magic number for detect library misuse */ /** Value returned by sql_row_count(). */ diff --git a/src/box/sql/util.c b/src/box/sql/util.c index dadae18..0673cd5 100644 --- a/src/box/sql/util.c +++ b/src/box/sql/util.c @@ -236,14 +236,10 @@ sqlErrorMsg(Parse * pParse, const char *zFormat, ...) va_start(ap, zFormat); zMsg = sqlVMPrintf(db, zFormat, ap); va_end(ap); - if (db->suppressErr) { - sqlDbFree(db, zMsg); - } else { - pParse->nErr++; - sqlDbFree(db, pParse->zErrMsg); - pParse->zErrMsg = zMsg; - pParse->rc = SQL_ERROR; - } + pParse->nErr++; + sqlDbFree(db, pParse->zErrMsg); + pParse->zErrMsg = zMsg; + pParse->rc = SQL_ERROR; } /* diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua index 271fa15..bd98528 100755 --- a/test/sql-tap/e_select1.test.lua +++ b/test/sql-tap/e_select1.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(520) +test:plan(516) --!./tcltestrunner.lua -- 2010 July 16 @@ -2063,17 +2063,15 @@ test:do_select_tests( "e_select-8.13", { {"1", "SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7 ORDER BY a", {1, 2, 3, 4, 5, 6}}, - {"2", "SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7 ORDER BY c", {1, 2, 3, 4, 5, 6}}, - {"3", "SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7 ORDER BY e", {1, 2, 3, 4, 5, 6}}, - {"4", "SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7 ORDER BY 1", {1, 2, 3, 4, 5, 6}}, - {"5", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY b ", {"f", 1, "c", 4, 4, "c", 1, "f"}}, - {"6", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 2 ", {"f", 1, "c", 4, 4, "c", 1, "f"}}, - {"7", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY a ", {1, "f", 4, "c", "c", 4, "f", 1}}, - {"8", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 1 ", {1, "f", 4, "c", "c", 4, "f", 1}}, - {"9", "SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 ", {"f", 2, "c", 5, 4, "c", 1, "f"}}, - {"10", "SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 2 ", {"f", 2, "c", 5, 4, "c", 1, "f"}}, - {"11", "SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 ", {2, "f", 5, "c", "c", 5, "f", 2}}, - {"12", "SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 1 ", {2, "f", 5, "c", "c", 5, "f", 2}}, + {"2", "SELECT a FROM d5 UNION ALL SELECT c FROM d6 UNION ALL SELECT e FROM d7 ORDER BY 1", {1, 2, 3, 4, 5, 6}}, + {"3", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY b ", {"f", 1, "c", 4, 4, "c", 1, "f"}}, + {"4", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 2 ", {"f", 1, "c", 4, 4, "c", 1, "f"}}, + {"5", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY a ", {1, "f", 4, "c", "c", 4, "f", 1}}, + {"6", "SELECT a, b FROM d5 UNION ALL SELECT b, a FROM d5 ORDER BY 1 ", {1, "f", 4, "c", "c", 4, "f", 1}}, + {"7", "SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 ", {"f", 2, "c", 5, 4, "c", 1, "f"}}, + {"8", "SELECT a, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 2 ", {"f", 2, "c", 5, 4, "c", 1, "f"}}, + {"9", "SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY a+1 ", {2, "f", 5, "c", "c", 5, "f", 2}}, + {"10", "SELECT a+1, b FROM d5 UNION ALL SELECT b, a+1 FROM d5 ORDER BY 1 ", {2, "f", 5, "c", "c", 5, "f", 2}}, }) -- EVIDENCE-OF: R-39265-04070 If no matching expression can be found in @@ -2101,9 +2099,7 @@ end test:do_select_tests( "e_select-8.15", { - {"1", "SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY a, d ", {1, "e", 1, "f", 4, "b", 4, "c"}}, - {"2", "SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY c-1, b ", {1, "e", 1, "f", 4, "b", 4, "c"}}, - {"3", "SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY 1, 2 ", {1, "e", 1, "f", 4, "b", 4, "c"}}, + {"1", "SELECT a, b FROM d5 UNION ALL SELECT c-1, d FROM d6 ORDER BY 1, 2 ", {1, "e", 1, "f", 4, "b", 4, "c"}}, }) --------------------------------------------------------------------------- diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua index bacc2b5..1aa157c 100755 --- a/test/sql-tap/select1.test.lua +++ b/test/sql-tap/select1.test.lua @@ -1382,7 +1382,7 @@ test:do_catchsql2_test( -- }) - test:do_execsql_test( + test:do_catchsql_test( "select1-6.23", [[ SELECT a FROM t6 WHERE b IN @@ -1391,7 +1391,7 @@ test:do_catchsql2_test( ORDER BY a; ]], { -- - "b", "d" + 1,"no such column: X" -- }) diff --git a/test/sql-tap/select4.test.lua b/test/sql-tap/select4.test.lua index dd2d68b..22dc599 100755 --- a/test/sql-tap/select4.test.lua +++ b/test/sql-tap/select4.test.lua @@ -631,8 +631,8 @@ test:do_execsql_test( "select4-6.3", [[ SELECT NULL UNION SELECT NULL UNION - SELECT 1 UNION SELECT 2 as "X" - ORDER BY x; + SELECT 1 UNION SELECT 2 + ORDER BY 1; ]], { -- "", 1, 2 @@ -643,8 +643,8 @@ test:do_execsql_test( "select4-6.3.1", [[ SELECT NULL UNION ALL SELECT NULL UNION ALL - SELECT 1 UNION ALL SELECT 2 as "X" - ORDER BY x; + SELECT 1 UNION ALL SELECT 2 + ORDER BY 1; ]], { -- "", "", 1, 2 diff --git a/test/sql-tap/selectB.test.lua b/test/sql-tap/selectB.test.lua index f280d35..7f57cd2 100755 --- a/test/sql-tap/selectB.test.lua +++ b/test/sql-tap/selectB.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(170) +test:plan(162) --!./tcltestrunner.lua -- 2008 June 24 @@ -318,28 +318,6 @@ for ii = 3, 6, 1 do test:do_execsql_test( "selectB-"..ii..".9", [[ - SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) - EXCEPT - SELECT c FROM t1 - ORDER BY c DESC - ]], { - 27, 24, 15, 9 - }) - - test:do_execsql_test( - "selectB-"..ii..".10", - [[ - SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) - UNION - SELECT c FROM t1 - ORDER BY c DESC - ]], { - 27, 24, 18, 15, 12, 9, 6 - }) - - test:do_execsql_test( - "selectB-"..ii..".11", - [[ SELECT c FROM t1 UNION SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) @@ -349,7 +327,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".12", + "selectB-"..ii..".10", [[ SELECT c FROM t1 UNION SELECT e FROM t2 UNION ALL SELECT f FROM t2 ORDER BY c @@ -358,7 +336,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".13", + "selectB-"..ii..".11", [[ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) UNION @@ -369,7 +347,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".14", + "selectB-"..ii..".12", [[ SELECT c FROM t1 INTERSECT @@ -380,7 +358,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".15", + "selectB-"..ii..".13", [[ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) INTERSECT @@ -391,7 +369,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".16", + "selectB-"..ii..".14", [[ SELECT * FROM (SELECT e FROM t2 UNION ALL SELECT f FROM t2) INTERSECT @@ -402,7 +380,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".17", + "selectB-"..ii..".15", [[ SELECT * FROM ( SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4 @@ -412,7 +390,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".18", + "selectB-"..ii..".16", [[ SELECT * FROM ( SELECT a FROM t1 UNION ALL SELECT d FROM t2 LIMIT 4 OFFSET 2 @@ -422,7 +400,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".19", + "selectB-"..ii..".17", [[ SELECT * FROM ( SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2 @@ -432,7 +410,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".20", + "selectB-"..ii..".18", [[ SELECT DISTINCT * FROM ( SELECT DISTINCT (a/10) FROM t1 UNION ALL SELECT DISTINCT(d%2) FROM t2 @@ -442,7 +420,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".21", + "selectB-"..ii..".19", [[ SELECT * FROM (SELECT a,b,c FROM t1 UNION ALL SELECT d,e,f FROM t2) ORDER BY a+b ]], { @@ -450,7 +428,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".22", + "selectB-"..ii..".20", [[ SELECT * FROM (SELECT 345 UNION ALL SELECT d FROM t2) ORDER BY 1; ]], { @@ -458,7 +436,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".23", + "selectB-"..ii..".21", [[ SELECT x, y FROM ( SELECT a AS x, b AS y FROM t1 @@ -472,7 +450,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".24", + "selectB-"..ii..".22", [[ SELECT x, y FROM ( SELECT a AS x, b AS y FROM t1 @@ -486,7 +464,7 @@ for ii = 3, 6, 1 do }) test:do_execsql_test( - "selectB-"..ii..".25", + "selectB-"..ii..".23", [[ SELECT x+y FROM ( SELECT a AS x, b AS y FROM t1 diff --git a/test/sql-tap/tkt2822.test.lua b/test/sql-tap/tkt2822.test.lua index 250a196..4212cbd 100755 --- a/test/sql-tap/tkt2822.test.lua +++ b/test/sql-tap/tkt2822.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(36) +test:plan(30) --!./tcltestrunner.lua -- 2007 Dec 4 @@ -163,19 +163,6 @@ test:do_execsql_test( -- }) --- Test that if a match cannot be found in the leftmost SELECT, an --- attempt is made to find a match in subsequent SELECT statements. --- -test:do_execsql_test( - "tkt2822-3.3", - [[ - SELECT a, b, c FROM t1 UNION ALL SELECT a AS x, b, c FROM t2 ORDER BY x; - ]], { - -- - 1, 3, 9, 2, 6, 18, 3, 9, 27, 4, 12, 36, 5, 15, 45, 6, 18, 54 - -- - }) - test:do_test( "tkt2822-3.4", function() @@ -295,61 +282,6 @@ test:do_execsql_test( -- }) -test:do_execsql_test( - "tkt2822-6.2", - [[ - SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b - ORDER BY PX, YX - ]], { - -- - 1, 7, 1, 8, 7, 2, 9, 2 - -- - }) - -test:do_execsql_test( - "tkt2822-6.3", - [[ - SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b - ORDER BY XX, QX - ]], { - -- - 1, 7, 1, 8, 7, 2, 9, 2 - -- - }) - -test:do_execsql_test( - "tkt2822-6.4", - [[ - SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b - ORDER BY QX, XX - ]], { - -- - 7, 2, 9, 2, 1, 7, 1, 8 - -- - }) - -test:do_execsql_test( - "tkt2822-6.5", - [[ - SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b - ORDER BY t6b.x, QX - ]], { - -- - 1, 7, 1, 8, 7, 2, 9, 2 - -- - }) - -test:do_execsql_test( - "tkt2822-6.6", - [[ - SELECT p PX, q QX FROM t6a UNION ALL SELECT x XX, y YX FROM t6b - ORDER BY t6a.q, XX - ]], { - -- - 7, 2, 9, 2, 1, 7, 1, 8 - -- - }) - -- More error message tests. This is really more of a test of the -- %r ordinal value formatting capablity added to sql_snprintf() -- by ticket #2822. diff --git a/test/sql-tap/view.test.lua b/test/sql-tap/view.test.lua index 81dc9a4..0824d9d 100755 --- a/test/sql-tap/view.test.lua +++ b/test/sql-tap/view.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(74) +test:plan(73) --!./tcltestrunner.lua -- 2002 February 26 @@ -325,22 +325,6 @@ test:do_execsql2_test( -- }) - -test:do_execsql2_test( - "view-3.5", - [[ - CREATE VIEW v4 AS - SELECT a, b FROM t1 - UNION - SELECT b AS x, a AS y FROM t1 - ORDER BY x, y; - SELECT b FROM v4 ORDER BY b LIMIT 4; - ]], { - -- - "B", 2, "B", 3, "B", 5, "B", 6 - -- - }) - -- X(237, "X!cmd", [=[["ifcapable","compound"]]=]) test:do_catchsql_test( "view-4.1", diff --git a/test/sql-tap/with1.test.lua b/test/sql-tap/with1.test.lua index 0ec745e..7896483 100755 --- a/test/sql-tap/with1.test.lua +++ b/test/sql-tap/with1.test.lua @@ -1,6 +1,6 @@ #!/usr/bin/env tarantool test = require("sqltester") -test:plan(65) +test:plan(64) --!./tcltestrunner.lua -- 2014 January 11 @@ -797,17 +797,6 @@ test:do_execsql_test("10.7.2", [[ -- }) -test:do_execsql_test("10.7.3", [[ - WITH t(a) AS ( - SELECT 1 AS b UNION ALL SELECT a+1 AS c FROM t WHERE a<5 ORDER BY c - ) - SELECT * FROM t -]], { - -- <10.7.3> - 1, 2, 3, 4, 5 - -- -}) - -- # Test COLLATE clauses attached to ORDER BY. -- # -- insert_into_tree { -- 2.7.4