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’t see any point in renaming function:
’sql_clear_stat_spaces’ -> ’sql_clear_stat_tables’.
I would even say that ‘spaces’ is more appropriate name,
since stat tables in fact are Tarantool’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\"=%Q",
-    zType, zName);
- sqlite3NestedParse(pParse, "DELETE FROM \"_sql_stat4\" WHERE \"%s\"=%Q",
-    zType, zName);
+    if (idx_name != NULL) {
+        sqlite3NestedParse(parse,
+                    "DELETE FROM \"_sql_stat1\" WHERE (\"idx\"=%Q AND "
+                    "\"tbl\"=%Q)",
+                    idx_name, table_name);
+        sqlite3NestedParse(parse,
+                    "DELETE FROM \"_sql_stat4\" WHERE (\"idx\"=%Q AND "
+                    "\"tbl\"=%Q)",
+                    idx_name, table_name);
+    } else {
+        sqlite3NestedParse(parse,
+                    "DELETE FROM \"_sql_stat1\" WHERE \"tbl\"=%Q",
+                    table_name);
+        sqlite3NestedParse(parse,
+                    "DELETE FROM \"_sql_stat4\" WHERE \"tbl\"=%Q",
+                    table_name);
+        }
 }