Tarantool development patches archive
 help / color / mirror / Atom feed
From: Hollow111 <hollow653@gmail.com>
To: korablev@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH] sql: analyze on VIEW lead to an assertion
Date: Thu, 03 May 2018 17:19:11 +0000	[thread overview]
Message-ID: <CAEi+_aqM2HGSn47mU+4ASOfwQhvZt_m+K9kr6aBpYCe7MMMAPA@mail.gmail.com> (raw)
In-Reply-To: <CAEi+_arjNJ+WR0MBtdmLzOUV309j7zoQaW4fhyK6E9irS2i6QQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2361 bytes --]

I'm sorry it was wrong diff if the patch

diff --git a/src/box/sql/analyze.c b/src/box/sql/analyze.c
index f0054c5..6ac035b 100644
--- a/src/box/sql/analyze.c
+++ b/src/box/sql/analyze.c
@@ -1123,6 +1123,8 @@ analyzeDatabase(Parse * pParse)
  iTab = pParse->nTab;
  for (k = sqliteHashFirst(&pSchema->tblHash); k; k = sqliteHashNext(k)) {
  Table *pTab = (Table *) sqliteHashData(k);
+ if (space_is_view(pTab))
+ continue;
  analyzeOneTable(pParse, pTab, 0, iStatCur, iMem, iTab);
  }
  loadAnalysis(pParse);
@@ -1179,8 +1181,12 @@ sqlite3Analyze(Parse * pParse, Token * pName)
  /* Form 2:  Analyze table named */
  z = sqlite3NameFromToken(db, pName);
  if (z) {
- if ((pTab = sqlite3LocateTable(pParse, 0, z)) != 0) {
- analyzeTable(pParse, pTab, 0);
+ if ((pTab = sqlite3LocateTable(pParse, 0, z)) != NULL) {
+ if (space_is_view(pTab))
+ sqlite3ErrorMsg(pParse, "VIEW isn't "
+ "allowed to be analyzed");
+ else
+ analyzeTable(pParse, pTab, 0);
  }
  }
  sqlite3DbFree(db, z);
diff --git a/test/sql-tap/analyzeD.test.lua b/test/sql-tap/analyzeD.test.lua
index 8fdadf5..ef6aced 100755
--- a/test/sql-tap/analyzeD.test.lua
+++ b/test/sql-tap/analyzeD.test.lua
@@ -1,6 +1,6 @@
 #!/usr/bin/env tarantool
 test = require("sqltester")
-test:plan(9)
+test:plan(15)

 testprefix = "analyzeD"

@@ -139,5 +139,66 @@ test:do_execsql_test(
         -- </1.8>
    })

+test:do_catchsql_test(
+ "analyzeD-1.9",
+ [[
+ CREATE TABLE table1(id INT PRIMARY KEY, a INT);
+ CREATE VIEW v AS SELECT * FROM table1;
+ ANALYZE;
+ ]], {
+ -- <analyzeD-1.9>
+ 0
+ -- <analyzeD-1.9>
+ })
+
+test:do_execsql_test(
+ "analyzeD-1.10",
+ [[
+ SELECT * FROM "_sql_stat4" WHERE "tbl" = 'v';
+ ]], {
+ -- <analyzeD-1.10>
+
+ -- <analyzeD-1.10>
+ })
+
+test:do_execsql_test(
+ "analyzeD-1.11",
+ [[
+ SELECT * FROM "_sql_stat1" WHERE "tbl" = 'v';
+ ]], {
+ -- <analyzeD-1.11>
+
+ -- <analyzeD-1.11>
+ })
+
+test:do_catchsql_test(
+ "analyzeD-1.12",
+ [[
+ ANALYZE v;
+ ]], {
+ -- <analyzeD-1.12>
+ 1, "VIEW isn't allowed to be analyzed"
+ -- <analyzeD-1.12>
+ })
+
+test:do_execsql_test(
+ "analyzeD-1.13",
+ [[
+ SELECT * FROM "_sql_stat4" WHERE "tbl" = 'v';
+ ]], {
+ -- <analyzeD-1.13>
+
+ -- <analyzeD-1.13>
+ })
+
+test:do_execsql_test(
+ "analyzeD-1.14",
+ [[
+ SELECT * FROM "_sql_stat1" WHERE "tbl" = 'v';
+ ]], {
+ -- <analyzeD-1.14>
+
+ -- <analyzeD-1.14>
+ })

 test:finish_test()

[-- Attachment #2: Type: text/html, Size: 6598 bytes --]

  reply	other threads:[~2018-05-03 17:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-02 13:25 [tarantool-patches] " N.Tatunov
2018-05-02 23:33 ` [tarantool-patches] " n.pettik
2018-05-03 17:16   ` Hollow111
2018-05-03 17:19     ` Hollow111 [this message]
2018-05-03 18:28       ` n.pettik
2018-05-15 15:56         ` 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=CAEi+_aqM2HGSn47mU+4ASOfwQhvZt_m+K9kr6aBpYCe7MMMAPA@mail.gmail.com \
    --to=hollow653@gmail.com \
    --cc=korablev@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH] sql: analyze on VIEW lead to an assertion' \
    /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