From: imeevma@tarantool.org To: korablev@tarantool.org Cc: tarantool-patches@freelists.org, kostja@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 [thread overview] Message-ID: <9bac4bd5266de1adb9f0c496732408c5d437554a.1550250721.git.imeevma@gmail.com> (raw) In-Reply-To: <cover.1550250721.git.imeevma@gmail.com> 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( -- </select1-6.22> }) - 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; ]], { -- <select1-6.23> - "b", "d" + 1,"no such column: X" -- </select1-6.23> }) 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; ]], { -- <select4-6.3> "", 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; ]], { -- <select4-6.3.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( -- </tkt2822-3.2> }) --- 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; - ]], { - -- <tkt2822-3.3> - 1, 3, 9, 2, 6, 18, 3, 9, 27, 4, 12, 36, 5, 15, 45, 6, 18, 54 - -- </tkt2822-3.3> - }) - test:do_test( "tkt2822-3.4", function() @@ -295,61 +282,6 @@ test:do_execsql_test( -- </tkt2822-6.1> }) -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 - ]], { - -- <tkt2822-6.2> - 1, 7, 1, 8, 7, 2, 9, 2 - -- </tkt2822-6.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 - ]], { - -- <tkt2822-6.3> - 1, 7, 1, 8, 7, 2, 9, 2 - -- </tkt2822-6.3> - }) - -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 - ]], { - -- <tkt2822-6.4> - 7, 2, 9, 2, 1, 7, 1, 8 - -- </tkt2822-6.4> - }) - -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 - ]], { - -- <tkt2822-6.5> - 1, 7, 1, 8, 7, 2, 9, 2 - -- </tkt2822-6.5> - }) - -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 - ]], { - -- <tkt2822-6.6> - 7, 2, 9, 2, 1, 7, 1, 8 - -- </tkt2822-6.6> - }) - -- 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( -- </view-3.4> }) - -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; - ]], { - -- <view-3.5> - "B", 2, "B", 3, "B", 5, "B", 6 - -- </view-3.5> - }) - -- 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", [[ -- </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 - -- </10.7.3> -}) - -- # Test COLLATE clauses attached to ORDER BY. -- # -- insert_into_tree { -- 2.7.4
next prev parent reply other threads:[~2019-02-15 17:14 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-02-15 17:14 [tarantool-patches] [PATCH v2 0/2] sql: use diag_set() for errors in SQL imeevma 2019-02-15 17:14 ` imeevma [this message] 2019-02-15 17:14 ` [tarantool-patches] [PATCH v2 2/2] sql: rework "no such object" and "object exists" errors imeevma 2019-02-18 12:14 ` [tarantool-patches] " n.pettik 2019-02-19 15:04 ` Konstantin Osipov 2019-02-18 16:51 ` [tarantool-patches] Re: [PATCH v2 0/2] sql: use diag_set() for errors in SQL Kirill Yukhin
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=9bac4bd5266de1adb9f0c496732408c5d437554a.1550250721.git.imeevma@gmail.com \ --to=imeevma@tarantool.org \ --cc=korablev@tarantool.org \ --cc=kostja@tarantool.org \ --cc=tarantool-patches@freelists.org \ --subject='Re: [tarantool-patches] [PATCH v2 1/2] sql: remove field suppressErr from struct sql' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox