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 EB7642A6B8 for ; Sat, 23 Mar 2019 08:58:47 -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 MTm34SJlroBP for ; Sat, 23 Mar 2019 08:58:47 -0400 (EDT) Received: from smtpng2.m.smailru.net (smtpng2.m.smailru.net [94.100.179.3]) (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 647422A69F for ; Sat, 23 Mar 2019 08:58:46 -0400 (EDT) Date: Sat, 23 Mar 2019 15:58:42 +0300 From: Mergen Imeev Subject: [tarantool-patches] Re: [PATCH v1 1/1] sql: ban ANALYZE statement Message-ID: <20190323125841.GA9101@tarantool.org> References: <5B3DB7B4-92A8-40B5-91F3-6A74B431652A@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5B3DB7B4-92A8-40B5-91F3-6A74B431652A@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: "n.pettik" Cc: tarantool-patches@freelists.org Hi! Thank ypu for review! Diff and new version below. On Fri, Mar 22, 2019 at 07:58:13PM +0300, n.pettik wrote: > > > /////////////////////////////////// ANALYZE /////////////////////////////////// > > -cmd ::= ANALYZE. {sqlAnalyze(pParse, 0);} > > -cmd ::= ANALYZE nm(X). {sqlAnalyze(pParse, &X);} > > +cmd ::= ANALYZE. {} > > +cmd ::= ANALYZE nm(X). {(void)X;} > > Could you remove this statement from parser? > Since it does nothing, it may turn out to be confusing. > Fixed. Diff: diff --git a/extra/addopcodes.sh b/extra/addopcodes.sh index 0304259..c25f1e4 100755 --- a/extra/addopcodes.sh +++ b/extra/addopcodes.sh @@ -49,6 +49,7 @@ extras=" \ SELECT_COLUMN \ ASTERISK \ SPAN \ + ANALYZE \ SPACE \ ILLEGAL \ " diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c index fbd56fa..be7bd55 100644 --- a/extra/mkkeywordhash.c +++ b/extra/mkkeywordhash.c @@ -101,7 +101,7 @@ static Keyword aKeywordTable[] = { { "AFTER", "TK_AFTER", TRIGGER, false }, { "ALL", "TK_ALL", ALWAYS, true }, { "ALTER", "TK_ALTER", ALTER, true }, - { "ANALYZE", "TK_ANALYZE", ALWAYS, true }, + { "ANALYZE", "TK_STANDARD", RESERVED, true }, { "AND", "TK_AND", ALWAYS, true }, { "AS", "TK_AS", ALWAYS, true }, { "ASC", "TK_ASC", ALWAYS, true }, diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index 03787d9..dfbb006 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1447,10 +1447,6 @@ cmd ::= DROP TRIGGER ifexists(NOERR) fullname(X). { sql_drop_trigger(pParse,X,NOERR); } -/////////////////////////////////// ANALYZE /////////////////////////////////// -cmd ::= ANALYZE. {} -cmd ::= ANALYZE nm(X). {(void)X;} - //////////////////////// ALTER TABLE table ... //////////////////////////////// cmd ::= ALTER TABLE fullname(X) RENAME TO nm(Z). { sql_alter_table_rename(pParse,X,&Z); diff --git a/test/sql-tap/gh-3350-skip-scan.test.lua b/test/sql-tap/gh-3350-skip-scan.test.lua index 4cecfe0..c326f7c 100755 --- a/test/sql-tap/gh-3350-skip-scan.test.lua +++ b/test/sql-tap/gh-3350-skip-scan.test.lua @@ -32,7 +32,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t1 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t1 WHERE a < 'aaad'; DROP TABLE t1; ]], { @@ -49,7 +49,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t2 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t2 WHERE f < 500; DROP TABLE t2; ]], { @@ -68,7 +68,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t3 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t3 WHERE f < 500; DROP INDEX i31 on t3; DROP TABLE t3; @@ -93,11 +93,11 @@ test:do_execsql_test( INSERT INTO t1 VALUES(5, 'def',567,8,9); INSERT INTO t1 VALUES(6, 'def',345,9,10); INSERT INTO t1 VALUES(7, 'bcd',100,6,11); - ANALYZE; + -- ANALYZE; DELETE FROM "_sql_stat1"; DELETE FROM "_sql_stat4"; INSERT INTO "_sql_stat1" VALUES('T1','T1ABC','10000 5000 2000 10'); - ANALYZE t2; + -- ANALYZE t2; SELECT a,b,c,d FROM t1 WHERE b=345; ]], { "abc", 345, 7, 8, "def", 345, 9, 10 diff --git a/test/sql-tap/whereG.test.lua b/test/sql-tap/whereG.test.lua index bb9cf39..2d7592b 100755 --- a/test/sql-tap/whereG.test.lua +++ b/test/sql-tap/whereG.test.lua @@ -449,7 +449,7 @@ test:do_execsql_test( test:do_execsql_test( "7.3", [[ - ANALYZE; + -- ANALYZE; EXPLAIN QUERY PLAN SELECT name FROM people WHERE height>=180; ]], -- {0,0,0,"SEARCH TABLE PEOPLE USING COVERING INDEX PEOPLE_IDX1" .. diff --git a/test/sql/row-count.result b/test/sql/row-count.result index b75298f..58374e6 100644 --- a/test/sql/row-count.result +++ b/test/sql/row-count.result @@ -179,9 +179,7 @@ box.sql.execute("SELECT ROW_COUNT();") --- - - [0] ... -box.sql.execute("ANALYZE;") ---- -... +-- box.sql.execute("ANALYZE;") box.sql.execute("SELECT ROW_COUNT();") --- - - [0] diff --git a/test/sql/row-count.test.lua b/test/sql/row-count.test.lua index 89476c7..5cf6348 100644 --- a/test/sql/row-count.test.lua +++ b/test/sql/row-count.test.lua @@ -61,7 +61,7 @@ box.sql.execute("COMMIT;") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("COMMIT;") box.sql.execute("SELECT ROW_COUNT();") -box.sql.execute("ANALYZE;") +-- box.sql.execute("ANALYZE;") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("EXPLAIN QUERY PLAN INSERT INTO t1 VALUES ('b'), ('c'), ('d');") box.sql.execute("SELECT ROW_COUNT();") diff --git a/test/sql/triggers.result b/test/sql/triggers.result index 826e998..7fa8611 100644 --- a/test/sql/triggers.result +++ b/test/sql/triggers.result @@ -275,10 +275,8 @@ box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- - error: A multi-statement transaction can not use multiple storage engines ... --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE m;") ---- -... +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE m;") box.sql.execute("DROP TABLE m;") --- ... @@ -311,10 +309,8 @@ box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- - error: A multi-statement transaction can not use multiple storage engines ... --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE n;") ---- -... +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE n;") box.sql.execute("DROP TABLE m;") --- ... diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua index b22b4f9..6618a41 100644 --- a/test/sql/triggers.test.lua +++ b/test/sql/triggers.test.lua @@ -109,8 +109,8 @@ box.sql.execute("INSERT INTO m VALUES (0, '0');") box.sql.execute("INSERT INTO n VALUES (0, '',null);") box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE m;") +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE m;") box.sql.execute("DROP TABLE m;") box.sql.execute("DROP TABLE n;") @@ -125,8 +125,8 @@ box.sql.execute("INSERT INTO m VALUES (0, '0');") box.sql.execute("INSERT INTO n VALUES (0, '',null);") box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE n;") +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE n;") box.sql.execute("DROP TABLE m;") box.sql.execute("DROP TABLE n;") New version: commit 50a9e64f2cd9c28893f113504b0e399f35a11151 Author: Mergen Imeev Date: Fri Mar 22 19:08:53 2019 +0300 sql: ban ANALYZE statement At this point, an ANALYZE statement can lead to many problems. It was decided to temporarily ban this statement. Closes #4069 diff --git a/extra/addopcodes.sh b/extra/addopcodes.sh index 0304259..c25f1e4 100755 --- a/extra/addopcodes.sh +++ b/extra/addopcodes.sh @@ -49,6 +49,7 @@ extras=" \ SELECT_COLUMN \ ASTERISK \ SPAN \ + ANALYZE \ SPACE \ ILLEGAL \ " diff --git a/extra/mkkeywordhash.c b/extra/mkkeywordhash.c index fbd56fa..be7bd55 100644 --- a/extra/mkkeywordhash.c +++ b/extra/mkkeywordhash.c @@ -101,7 +101,7 @@ static Keyword aKeywordTable[] = { { "AFTER", "TK_AFTER", TRIGGER, false }, { "ALL", "TK_ALL", ALWAYS, true }, { "ALTER", "TK_ALTER", ALTER, true }, - { "ANALYZE", "TK_ANALYZE", ALWAYS, true }, + { "ANALYZE", "TK_STANDARD", RESERVED, true }, { "AND", "TK_AND", ALWAYS, true }, { "AS", "TK_AS", ALWAYS, true }, { "ASC", "TK_ASC", ALWAYS, true }, diff --git a/src/box/box.cc b/src/box/box.cc index f7ce33a..7d89055 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -2139,8 +2139,6 @@ box_cfg_xc(void) /* Follow replica */ replicaset_follow(); - sql_load_schema(); - fiber_gc(); is_box_configured = true; diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index b27651c..dfbb006 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -1447,10 +1447,6 @@ cmd ::= DROP TRIGGER ifexists(NOERR) fullname(X). { sql_drop_trigger(pParse,X,NOERR); } -/////////////////////////////////// ANALYZE /////////////////////////////////// -cmd ::= ANALYZE. {sqlAnalyze(pParse, 0);} -cmd ::= ANALYZE nm(X). {sqlAnalyze(pParse, &X);} - //////////////////////// ALTER TABLE table ... //////////////////////////////// cmd ::= ALTER TABLE fullname(X) RENAME TO nm(Z). { sql_alter_table_rename(pParse,X,&Z); diff --git a/src/box/sql/sqlInt.h b/src/box/sql/sqlInt.h index 8967ea3..aebd131 100644 --- a/src/box/sql/sqlInt.h +++ b/src/box/sql/sqlInt.h @@ -4492,7 +4492,6 @@ char* rename_trigger(sql *, char const *, char const *, bool *); */ struct coll * sql_get_coll_seq(Parse *parser, const char *name, uint32_t *coll_id); -void sqlAnalyze(Parse *, Token *); /** * This function returns average size of tuple in given index. diff --git a/test/sql-tap/gh-3350-skip-scan.test.lua b/test/sql-tap/gh-3350-skip-scan.test.lua index 4cecfe0..c326f7c 100755 --- a/test/sql-tap/gh-3350-skip-scan.test.lua +++ b/test/sql-tap/gh-3350-skip-scan.test.lua @@ -32,7 +32,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t1 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t1 WHERE a < 'aaad'; DROP TABLE t1; ]], { @@ -49,7 +49,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t2 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t2 WHERE f < 500; DROP TABLE t2; ]], { @@ -68,7 +68,7 @@ test:do_execsql_test( (SELECT int_to_char(0), 'xyz', 'zyx', '*', 0, 0 UNION ALL SELECT int_to_char(f+1), b, c, d, (e+1) % 2, f+1 FROM data WHERE f<1024) INSERT INTO t3 SELECT a, b, c, d, e, f FROM data; - ANALYZE; + -- ANALYZE; SELECT COUNT(*) FROM t3 WHERE f < 500; DROP INDEX i31 on t3; DROP TABLE t3; @@ -93,11 +93,11 @@ test:do_execsql_test( INSERT INTO t1 VALUES(5, 'def',567,8,9); INSERT INTO t1 VALUES(6, 'def',345,9,10); INSERT INTO t1 VALUES(7, 'bcd',100,6,11); - ANALYZE; + -- ANALYZE; DELETE FROM "_sql_stat1"; DELETE FROM "_sql_stat4"; INSERT INTO "_sql_stat1" VALUES('T1','T1ABC','10000 5000 2000 10'); - ANALYZE t2; + -- ANALYZE t2; SELECT a,b,c,d FROM t1 WHERE b=345; ]], { "abc", 345, 7, 8, "def", 345, 9, 10 diff --git a/test/sql-tap/suite.ini b/test/sql-tap/suite.ini index bb49289..95207f4 100644 --- a/test/sql-tap/suite.ini +++ b/test/sql-tap/suite.ini @@ -8,6 +8,18 @@ disabled = selectA.test.lua ; date.test.lua ; tkt-bd484a090c.test.lua ; tkt3791.test.lua ; + analyze1.test.lua ; + analyze3.test.lua ; + analyze4.test.lua ; + analyze5.test.lua ; + analyze6.test.lua ; + analyze7.test.lua ; + analyze8.test.lua ; + analyze9.test.lua ; + analyzeC.test.lua ; + analyzeD.test.lua ; + analyzeE.test.lua ; + analyzeF.test.lua ; lua_libs = lua/sqltester.lua ../sql/lua/sql_tokenizer.lua ../box/lua/identifier.lua is_parallel = True diff --git a/test/sql-tap/whereG.test.lua b/test/sql-tap/whereG.test.lua index 155c906..2d7592b 100755 --- a/test/sql-tap/whereG.test.lua +++ b/test/sql-tap/whereG.test.lua @@ -449,10 +449,12 @@ test:do_execsql_test( test:do_execsql_test( "7.3", [[ - ANALYZE; + -- ANALYZE; EXPLAIN QUERY PLAN SELECT name FROM people WHERE height>=180; ]], - {0,0,0,"SEARCH TABLE PEOPLE USING COVERING INDEX PEOPLE_IDX1" .. - " (ANY(ROLE) AND HEIGHT>?)"}) + -- {0,0,0,"SEARCH TABLE PEOPLE USING COVERING INDEX PEOPLE_IDX1" .. + -- " (ANY(ROLE) AND HEIGHT>?)"} + {0,0,0,"SCAN TABLE PEOPLE" } + ) test:finish_test() diff --git a/test/sql/row-count.result b/test/sql/row-count.result index b75298f..58374e6 100644 --- a/test/sql/row-count.result +++ b/test/sql/row-count.result @@ -179,9 +179,7 @@ box.sql.execute("SELECT ROW_COUNT();") --- - - [0] ... -box.sql.execute("ANALYZE;") ---- -... +-- box.sql.execute("ANALYZE;") box.sql.execute("SELECT ROW_COUNT();") --- - - [0] diff --git a/test/sql/row-count.test.lua b/test/sql/row-count.test.lua index 89476c7..5cf6348 100644 --- a/test/sql/row-count.test.lua +++ b/test/sql/row-count.test.lua @@ -61,7 +61,7 @@ box.sql.execute("COMMIT;") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("COMMIT;") box.sql.execute("SELECT ROW_COUNT();") -box.sql.execute("ANALYZE;") +-- box.sql.execute("ANALYZE;") box.sql.execute("SELECT ROW_COUNT();") box.sql.execute("EXPLAIN QUERY PLAN INSERT INTO t1 VALUES ('b'), ('c'), ('d');") box.sql.execute("SELECT ROW_COUNT();") diff --git a/test/sql/suite.ini b/test/sql/suite.ini index ce6ccb7..bfe0fa0 100644 --- a/test/sql/suite.ini +++ b/test/sql/suite.ini @@ -7,3 +7,4 @@ config = engine.cfg is_parallel = True lua_libs = lua/sql_tokenizer.lua release_disabled = errinj.test.lua view_delayed_wal.test.lua sql-debug.test.lua +disabled = sql-statN-index-drop.test.lua diff --git a/test/sql/triggers.result b/test/sql/triggers.result index 826e998..7fa8611 100644 --- a/test/sql/triggers.result +++ b/test/sql/triggers.result @@ -275,10 +275,8 @@ box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- - error: A multi-statement transaction can not use multiple storage engines ... --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE m;") ---- -... +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE m;") box.sql.execute("DROP TABLE m;") --- ... @@ -311,10 +309,8 @@ box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- - error: A multi-statement transaction can not use multiple storage engines ... --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE n;") ---- -... +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE n;") box.sql.execute("DROP TABLE m;") --- ... diff --git a/test/sql/triggers.test.lua b/test/sql/triggers.test.lua index b22b4f9..6618a41 100644 --- a/test/sql/triggers.test.lua +++ b/test/sql/triggers.test.lua @@ -109,8 +109,8 @@ box.sql.execute("INSERT INTO m VALUES (0, '0');") box.sql.execute("INSERT INTO n VALUES (0, '',null);") box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE m;") +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE m;") box.sql.execute("DROP TABLE m;") box.sql.execute("DROP TABLE n;") @@ -125,8 +125,8 @@ box.sql.execute("INSERT INTO m VALUES (0, '0');") box.sql.execute("INSERT INTO n VALUES (0, '',null);") box.sql.execute("UPDATE m SET s1 = 'The Rain In Spain';") --- ANALYZE operates with _sql_stat{1,4} tables should work -box.sql.execute("ANALYZE n;") +-- ANALYZE banned in gh-4069 +-- box.sql.execute("ANALYZE n;") box.sql.execute("DROP TABLE m;") box.sql.execute("DROP TABLE n;")