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 799EC2D10C for ; Mon, 9 Apr 2018 08:16:13 -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 LBXtwOyDKsjB for ; Mon, 9 Apr 2018 08:16:13 -0400 (EDT) Received: from smtp14.mail.ru (smtp14.mail.ru [94.100.181.95]) (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 1501F2CEB0 for ; Mon, 9 Apr 2018 08:16:12 -0400 (EDT) From: "n.pettik" Message-Id: <4E93854E-25F3-45F7-8590-5CD96991E365@tarantool.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_17A802BA-985D-4FB7-B5E4-00522135A683" Mime-Version: 1.0 (Mac OS X Mail 10.3 \(3273\)) Subject: [tarantool-patches] Re: [PATCH 2/2] sql: statistics removal after dropping an index Date: Mon, 9 Apr 2018 15:16:09 +0300 In-Reply-To: References: <1522791436-8221-1-git-send-email-hollow653@gmail.com> <926E041C-FCCB-46B0-B49B-21292CB70813@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: Hollow111 Cc: tarantool-patches@freelists.org --Apple-Mail=_17A802BA-985D-4FB7-B5E4-00522135A683 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Hello. I have noticed that you are using 4 spaces as an indentation. According to our codestyle, we use tab symbol, instead of spaces, which is equal to 8 spaces. Also, I don=E2=80=99t see any point in renaming function: =E2=80=99sql_clear_stat_spaces=E2=80=99 -> =E2=80=99sql_clear_stat_tables=E2= =80=99. I would even say that =E2=80=98spaces=E2=80=99 is more appropriate name, since stat tables in fact are Tarantool=E2=80=99s system spaces. > diff --git a/src/box/sql/build.c b/src/box/sql/build.c > index 92f3cb6..7ca4191 100644 > --- a/src/box/sql/build.c > +++ b/src/box/sql/build.c > @@ -2128,19 +2128,33 @@ sqliteViewResetAll(sqlite3 * db) > /** > * Remove entries from the _sql_stat1 and _sql_stat4 > * system spaces after a DROP INDEX or DROP TABLE command. > - * > - * @param pParse Parsing context. > - * @param zType Type of entry to be deleted: > - * 'idx' or 'tbl' string literal. > - * @param zName Name of index or table. > + *=20 > + * @param parse The parsing context. > + * @param table_name The table to be dropped or > + * the table that contains index to be dropped. > + * @param idx_name Index to be dropped. > */ > static void > -sql_clear_stat_spaces(Parse * pParse, const char *zType, const char = *zName) > +sql_clear_stat_tables(Parse *parse, const char *table_name, > + const char *idx_name) > { > - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat1\" WHERE = \"%s\"=3D%Q", > - zType, zName); > - sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat4\" WHERE = \"%s\"=3D%Q", > - zType, zName); > + if (idx_name !=3D NULL) { > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat1\" WHERE (\"idx\"=3D%Q = AND " > + "\"tbl\"=3D%Q)", > + idx_name, table_name); > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat4\" WHERE (\"idx\"=3D%Q = AND " > + "\"tbl\"=3D%Q)", > + idx_name, table_name); > + } else { > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat1\" WHERE \"tbl\"=3D%Q", > + table_name); > + sqlite3NestedParse(parse, > + "DELETE FROM \"_sql_stat4\" WHERE \"tbl\"=3D%Q", > + table_name); > + } > } >=20 > =20 --Apple-Mail=_17A802BA-985D-4FB7-B5E4-00522135A683 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8 Hello. I have noticed that you are using 4 spaces as an = indentation.
According to our codestyle, we use tab = symbol, instead of spaces,
which is equal to 8 = spaces.

Also, = I don=E2=80=99t see any point in renaming function:
=E2=80=99sql_clear_stat_spaces=E2=80=99 -> = =E2=80=99sql_clear_stat_tables=E2=80=99.
I would = even say that =E2=80=98spaces=E2=80=99 is more appropriate = name,
since stat tables in fact are Tarantool=E2=80=99= s system spaces.

diff --git = a/src/box/sql/build.c b/src/box/sql/build.c
index = 92f3cb6..7ca4191 100644
--- = a/src/box/sql/build.c
+++ = b/src/box/sql/build.c
@@ -2128,19 +2128,33 @@ = sqliteViewResetAll(sqlite3 * db)
 /**
  * Remove entries from the _sql_stat1 and = _sql_stat4
  * system spaces after a DROP = INDEX or DROP TABLE command.
- *
- * @param pParse Parsing context.
- * = @param zType Type of entry to be deleted:
- * 'idx' or = 'tbl' string literal.
- * @param zName Name of = index or table.
+ * 
+ * = @param parse      The parsing context.
+ * @param table_name The table to be dropped or
+ *                =    the table that contains index to be dropped.
+ * @param idx_name   Index to be = dropped.
  */
 static = void
-sql_clear_stat_spaces(Parse * pParse, const = char *zType, const char *zName)
+sql_clear_stat_tables(Parse *parse, const char = *table_name,
+          =             const char = *idx_name)
 {
- = sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat1\" WHERE = \"%s\"=3D%Q",
-    zType, = zName);
- sqlite3NestedParse(pParse, "DELETE FROM = \"_sql_stat4\" WHERE \"%s\"=3D%Q",
- =    zType, zName);
+    = if (idx_name !=3D NULL) {
+      =   sqlite3NestedParse(parse,
+    =                 "DELETE FROM = \"_sql_stat1\" WHERE (\"idx\"=3D%Q AND "
+  =                   = "\"tbl\"=3D%Q)",
+        =             idx_name, = table_name);
+        = sqlite3NestedParse(parse,
+      =               "DELETE FROM = \"_sql_stat4\" WHERE (\"idx\"=3D%Q AND "
+  =                   = "\"tbl\"=3D%Q)",
+        =             idx_name, = table_name);
+    } else {
+        = sqlite3NestedParse(parse,
+      =               "DELETE FROM = \"_sql_stat1\" WHERE \"tbl\"=3D%Q",
+    =                 = table_name);
+        = sqlite3NestedParse(parse,
+      =               "DELETE FROM = \"_sql_stat4\" WHERE \"tbl\"=3D%Q",
+    =                 = table_name);
+        = }
 }

 

= --Apple-Mail=_17A802BA-985D-4FB7-B5E4-00522135A683--