[tarantool-patches] Re: [PATCH v1 1/1] sql: remove _sql_stat1 and _sql_stat4 system tables

  • From: Vladimir Davydov <vdavydov.dev@xxxxxxxxx>
  • To: imeevma@xxxxxxxxxxxxx
  • Date: Wed, 3 Apr 2019 11:35:54 +0300

On Tue, Apr 02, 2019 at 12:25:49PM +0300, imeevma@xxxxxxxxxxxxx wrote:

These tables won't be used anymore and should be deleted.

Please mention that this breaks backward compatibility.

diff --git a/src/box/sql.c b/src/box/sql.c
index 4fac020..7beeee1 100644
--- a/src/box/sql.c
+++ b/src/box/sql.c
@@ -87,7 +87,7 @@ sql_load_schema()
       * statistics (_sql_stat1 and _sql_stat4). Thus, we can
       * skip statistics loading.
       */
-     struct space *stat = space_by_id(BOX_SQL_STAT1_ID);
+     struct space *stat = space_by_name("_sql_stat1");

I don't understand this change: even though you removed the tables you
still expect them to be accessible by name here and in a few other
places. At any rate, the comment above needs to be refreshed.

      assert(stat != NULL);
      if (stat->def->field_count == 0)
              return;
@@ -2478,19 +2460,17 @@ sql_drop_index(struct Parse *parse_context, struct 
SrcList *index_name_list,
              }
              goto exit_drop_index;
      }
-     struct index *index = space_index(space, index_id);
-     assert(index != NULL);
 
      /*
       * Generate code to remove entry from _index space
       * But firstly, delete statistics since schema
       * changes after DDL.
       */
-     sql_clear_stat_spaces(parse_context, table_name, index->def->name);
      int record_reg = ++parse_context->nMem;
      int space_id_reg = ++parse_context->nMem;
+     int index_id_reg =++parse_context->nMem;

Nit: a space is missing.

Anyway, this change looks like it doesn't have anything to do with stat
tables removal. If so, please factor it out into a separate patch with a
proper justification.

      sqlVdbeAddOp2(v, OP_Integer, space->def->id, space_id_reg);
-     sqlVdbeAddOp2(v, OP_Integer, index_id, space_id_reg + 1);
+     sqlVdbeAddOp2(v, OP_Integer, index_id, index_id_reg);
      sqlVdbeAddOp3(v, OP_MakeRecord, space_id_reg, 2, record_reg);
      sqlVdbeAddOp2(v, OP_SDelete, BOX_INDEX_ID, record_reg);
      sqlVdbeChangeP5(v, OPFLAG_NCHANGE);

Other related posts: